Re: How to apply Fourier transform to speech signals?

• To: mathgroup at smc.vnet.net
• Subject: [mg113732] Re: How to apply Fourier transform to speech signals?
• From: "Nasser M. Abbasi" <nma at 12000.org>
• Date: Tue, 9 Nov 2010 03:54:25 -0500 (EST)

```On 11/8/2010 9:13 PM, hadi motamedi wrote:
> On 11/8/10, Nasser M. Abbasi<nma at 12000.org>  wrote:
>>    one way:
>>
>> --------------------------------
>> (*showing how to load wav sound file, listen to it inside Mathematica
>> and plot its power spectrum. hacked by Nasser M. Abbasi on Nov 7.2010 at
>> the request of hadi motamedi while waiting for coeffe to be ready*)
>>
>> Remove["Global`*"];
>> <<Audio`
>>
>> SetDirectory[ToFileName[Extract["FileName"/.NotebookInformation[EvaluationNotebook[]],{1},FrontEnd`FileName]]];
>>
>> ele=Import["example.wav","Elements"]
>> Out[169]=
>> {AudioChannels,AudioEncoding,Data,SampledSoundList,SampleRate,Sound}
>>
>> In[170]:= (*listen to it *)
>> sound=Import["example.wav","Sound"];
>> EmitSound[sound]
>>
>> In[172]:= Fs=Import["example.wav","SampleRate"]
>> Out[172]= 44100
>>
>> (* now load the samples and do power spectrum *)
>> data=Import["example.wav","Data"];
>> {nChannel,nSamples}=Dimensions[data]
>>
>> Out[174]= {2,324864}
>>
>> Py=Fourier[data[[1,All]]];
>> nUniquePts=Ceiling[(nSamples+1)/2];
>> Py=Py[[Range[1,nUniquePts]]];
>> Py=Abs[Py];
>> Py=Py/nSamples;
>> Py=Py^2;
>> Py=2 Py;
>> Py[[1]]=Py[[1]]/2;(*Py=Y*Conjugate[Y];*)
>> f=(Range[0,nUniquePts-1] Fs)/nSamples;
>>
>> ListPlot[Transpose[{f,Py}],
>>      Joined->True,
>>      PlotRange->All,
>>      PlotLabel->"Power Spectrum of wav file",
>>      AxesLabel->{"Freq. Hz","power"},
>>      ImageSize->400
>> ]
>>
>> -----------------------------------
>>
>> --Nasser
>>
>>

> Thank you very much for your help. Sorry did you have ever tried for
> your code? It seems that it needs some minor modifications to fit real
> case but I am not so expert to do that. Can you please help me to get
> the final result in real case?
>

I do not understand what you mean by "real case".  You ask "How to apply
Fourier transform to speech signals" and I should example using data
read from .wav file. Once you get the data, the rest is just standard
textbook FFT stuff.  This was an example, it is not meant to be
real-life industry strength all purpose application :)

--Nasser

```

• Prev by Date: Writing functions in packages that define values of global variables
• Next by Date: Re: x and y labels in ArrayPlot
• Previous by thread: Re: How to apply Fourier transform to speech signals?
• Next by thread: Tag List Protected error