McLoughlin I. Applied Speech and Audio
-
Upload
andra-gabriela -
Category
Documents
-
view
22 -
download
5
description
Transcript of McLoughlin I. Applied Speech and Audio
-
MATLABFunctionalityforDigitalSpeechProcessing
MATLABSpeechProcessingCodeMATLABGUIImplementations
1Lecture_3_2012
-
BasicFunctionality readaspeechfile(i.e.,opena.wavspeechfileandreadthespeechsampleintoa
MATLABarray) writeaspeechfile(i.e.,writeaMATLABarrayofspeechsamplesintoa.wav
speechfile) playaMATLABarrayofspeechsamplesasanaudiofile playasequenceofMATLABarraysofspeechsamplesasasequenceofaudiofiles recordaspeechfileintoaMATLABarray plotaspeechfile(MATLABarray)asawaveformusingastripsplotformat plotaspeechfile(MATLABarray)asoneormore4lineplot(s) convertthesamplingrateassociatedwithaspeechfile(MATLABarray)toa
differentsamplingrate highpass filteraspeechfile(MATLABarray)toeliminatehumandlowfrequency
noise plotaframeofspeechanditsassociatedspectrallogmagnitude plotaspectrogramofaspeechfile(MATLABarray) plotmultiplespectrogramsofoneormorespeechfiles(MATLABarrays)
2
-
ReadaSpeechFileintoaMATLABArray
[xin,fs,nbits]=wavread(filename); [xin,fs]=loadwav(filename);
filenameisascii textfora.wavencodedfilewhichcontainsaspeechsignalencodedusinga16bitintegerformat
xin istheMATLABarrayinwhichthespeechsamplesarestored(indoubleprecisionformat)
fs isthesamplingrateoftheinputspeechsignal nbits isthenumberofbitsinwhicheachspeechsampleisencoded
(16inmostcases) programwavread scalesthespeecharray,xin,torange1xin1,
whereasloadwav preservessamplevaluesofthespeechfileandhencearrayxin isscaledtorange32768xin32767
[xin1,fs,nbits]=wavread(s5.wav); [xin2,fs]=loadwav(s5.wav);
3
-
ReadaSpeechFileintoaMATLABArray %test_wavread.m %testwaveread function % %readspeechsamplesfromfile'test_16k.wav'intoarrayx1usingwavread %routine filein='test_16k.wav'; [x1,fs1,nbits]=wavread(filein); %printoutvaluesoffs1,nbits,wavmin1,wavmax1 wavmin1=min(x1); wavmax1=max(x1); fprintf('file:%s,wavmin/wavmax:%6.2f%6.2f,fs1:%d,nbits:%d\n, filein,wavmin1,wavmax1,fs1,nbits); %readspeechsamplesfromsamefileintoarrayx2usingloadwav routine [x2,fs2]=loadwav(filein); %printoutvaluesoffs2,nbits,wavmin2,wavmax2 wavmin2=min(x2); wavmax2=max(x2); fprintf('file:%s,wavmin/wavmax:%d%d,fs2:%d\n',... filein,wavmin2,wavmax2,fs2);TerminalDisplay:file:test_16k.wav,wavmin/wavmax:1.001.00,fs1:16000,nbits:16file:test_16k.wav,wavmin/wavmax:3276832767,fs2:16000 4
-
HelloWorld GUI25
5
-
GUI25InitialScreen
6
-
GUI25EditScreen
7
-
Play/PlotExistingSpeechFile Play_Plot_Speech_GUI25.m
MATLABGUIforbasicoperationsofreadinginafile,playingthespeecharray,andplottingthespeechwaveform
8
-
WriteaSpeechArrayintoaSpeechFile
wavwrite(xout,fs,nbits,filename); savewav(xout,filename,fs);
xout istheMATLABarrayinwhichthespeechsamplesarestored fs isthesamplingrateoftheoutputspeechsignal nbits isthenumberofbitsinwhicheachspeechsampleisencoded filenameistheascii textforthe.wavencodedfileinwhichthe
MATLABsignalarrayistobestored forwavwrite theMATLABarrayxout needstobescaledtotherange
1xin1whereasforsavewav theMATLABarrayxout needstobescaledtotherange32768xout32767
wavwrite(xin1,fs,s5out.1.wav); savewav(xin2,s5out.2.wav,fs);
9
-
WriteaSpeechArrayintoaSpeechFile
%writeoutarrayx1intospeechfileusingwavwrite routine wavwrite(x1,fs1,nbits,'file1out.wav');
%writeoutarrayx2intospeechfileusingsavewav routine savewav(x2,'file2out.wav',fs2);
file1out.wav
file2out.wav
10
-
PlayaSpeechFile sound(x,fs); soundsc(x,fs);
forsoundthespeecharray,x,mustbescaledtotherange1x1
forsoundsc anyscalingofthespeecharraycanbeused fs isthesamplingratefthespeechsignal
[xin,fs]=loadwav(s5.wav);%loadspeechfroms5.wav; xinn =xin/abs(max(xin));%normalizetorangeof1to1; sound(xinn,fs);%playoutnormalizedspeechfile; soundsc(xin,fs);%playoutunnormalized speechfile;
11
-
PlayMultipleSpeechFiles play_multiple_files.m;
sequenceoffilenamesreadinviafilelist,keyboardorfilesearch
Exampleofusagetoplayout3speechfilesinsequence: kbe=filenameentryviafilelist(2),keyboard(1),orfilesearch(0):1;%keyboardchosen
N=numberoffilestobeplayedinagroup:3;%playout3files
i=1;filename:s1.wav; i=2;filename:s2.wav; i=3;filename:s3.wav
12
-
PlayMultipleSpeechFiles
test_play_files.m playthefollowingsequenceoffiles:
Maple_short.wavs1.wavbeep.wavtest_16k.wavbeep.wavs2.wav
13
-
RecordSpeechintoMATLABArray
record_speech.m (callsMATLABfunctionwavrecord.m)
functiony=record_speech(fs,nsec); fs:samplingfrequency nsec:numberofsecondsofrecording y:speechsamplesarraynormalizedtopeakof32767
14
-
RecordSpeechintoMATLABArray record_display_speech_GUI25.m
15
-
PlotSpeechUsingStripsPlot
16
-
PlotSpeechUsingStripsPlot strips_plot_GUI25.m
17
-
PlotSpeechUsing4LinePlot
18
-
SampleRateConversion
y=srconv(x,fsin,fsout); x:inputspeecharray; fsin:inputspeechsamplingrate; fsout:desiredspeechsamplingrate;
Example: [xin,fsin]=loadwav(s5.wav);%fsin=8000; fsout =10000;%desiredsamplingrate; y=srconv(xin,fsin,fsout);
19
-
SampleRateConversion SRC_GUI25.m
20
-
FilterSpeechWaveform
21
-
FilterSpeechWaveform filter_GUI25.m
22
-
PlotSignalandSTFTLogMagnitude
23
-
MultipleSpectraGUI multiple_spectra_GUI25.m
24
-
PlotSpectrogram
25
-
PlotSpectrogram spectrogram_GUI25.m
26
-
PlotMultipleSpectrograms
27