SlideShare a Scribd company logo
1 of 27
Download to read offline
MATLAB Functionality for Digital 
Speech Processing
• MATLAB Speech Processing Code
• MATLAB GUI Implementations
1Lecture_3_2012
Basic Functionality
• read a speech file (i.e., open a .wav speech file and read the speech sample into a 
MATLAB array)
• write a speech file (i.e., write a MATLAB array of speech samples into a .wav 
speech file)
• play a MATLAB array of speech samples as an audio file
• play a sequence of MATLAB arrays of speech samples as a sequence of audio files
• record a speech file into a MATLAB array
• plot a speech file (MATLAB array) as a waveform using a strips plot format
• plot a speech file (MATLAB array) as one or more 4‐line plot(s)
• convert the sampling rate associated with a speech file (MATLAB array) to a 
different sampling rate
• highpass filter a speech file (MATLAB array) to eliminate hum and low frequency 
noise
• plot a frame of speech and its associated spectral log magnitude
• plot a spectrogram of a speech file (MATLAB array)
• plot multiple spectrograms of one or more speech files (MATLAB arrays)
2
Read a Speech File into a MATLAB 
Array
• [xin, fs, nbits] = wavread(filename);
• [xin, fs] = loadwav(filename);
– filename is ascii text for a .wav‐encoded file which contains a speech 
signal encoded using a 16‐bit integer format
– xin is the MATLAB array in which the speech samples are stored (in 
double precision format)
– fs is the sampling rate of the input speech signal
– nbits is the number of bits in which each speech sample is encoded 
(16 in most cases)
– program wavread scales the speech array, xin, to range −1≤xin≤1, 
whereas loadwav preserves sample values of the speech file and 
hence array xin is scaled to range −32768≤xin≤32767
• [xin1, fs, nbits] = wavread(‘s5.wav’);
• [xin2, fs] = loadwav(‘s5.wav’);
3
Read a Speech File into a MATLAB Array
• % test_wavread.m
• % test waveread function
• %
• % read speech samples from file 'test_16k.wav' into array x1 using wavread
• % routine
• filein='test_16k.wav';
• [x1,fs1,nbits]=wavread(filein);
•
• % print out values of fs1, 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);
•
• % read speech samples from same file into array x2 using loadwav routine
• [x2,fs2]=loadwav(filein);
•
• % print out values of fs2, nbits, wavmin2, wavmax2
• wavmin2=min(x2);
• wavmax2=max(x2);
• fprintf('file: %s, wavmin/wavmax: %d %d, fs2: %d n',...
• filein,wavmin2,wavmax2,fs2);
Terminal Display:
file: test_16k.wav, wavmin/wavmax:  ‐1.00   1.00, fs1: 16000, nbits: 16 
file: test_16k.wav, wavmin/wavmax: ‐32768 32767, fs2: 16000 4
HelloWorld GUI25
5
GUI25 Initial Screen
6
GUI25 Edit Screen
7
Play/Plot Existing Speech File
• Play_Plot_Speech_GUI25.m
– MATLAB GUI for basic operations of reading in a 
file, playing the speech array, and plotting the 
speech waveform
8
Write a Speech Array into a Speech 
File
• wavwrite(xout, fs, nbits, filename);
• savewav(xout, filename, fs);
– xout is the MATLAB array in which the speech samples are stored
– fs is the sampling rate of the output speech signal
– nbits is the number of bits in which each speech sample is encoded
– filename is the ascii text for the .wav‐encoded file in which the 
MATLAB signal array is to be stored
– for wavwrite the MATLAB array xout needs to be scaled to the range 
−1≤xin≤1 whereas for savewav the MATLAB array xout needs to be 
scaled to the range −32768≤xout≤32767
• wavwrite(xin1, fs, ‘s5out.1.wav’);
• savewav(xin2, ‘s5out.2.wav’, fs);
9
Write a Speech Array into a Speech File
• % write out array x1 into speech file using wavwrite routine
• wavwrite(x1,fs1,nbits,'file1out.wav');
• % write out array x2 into speech file using savewav routine
• savewav(x2,'file2out.wav',fs2);
file1out.wav
file2out.wav
10
Play a Speech File
• sound(x, fs);
• soundsc(x, fs);
– for sound the speech array, x, must be scaled to the range 
−1≤x≤1 
– for soundsc any scaling of the speech array can be used
– fs is the sampling rate f the speech signal
• [xin, fs] = loadwav(‘s5.wav’);  % load speech from s5.wav;
• xinn = xin/abs(max(xin)); % normalize to range of − 1 to 1;
• sound(xinn, fs); % play out normalized speech file;
• soundsc(xin, fs); % play out unnormalized speech file;
11
Play Multiple Speech Files
• play_multiple_files.m;
– sequence of filenames read in via filelist, keyboard or file 
search
• Example of usage to play out 3 speech files in 
sequence:
– kbe=filename entry via filelist(2), keyboard(1), or file 
search(0):1; % keyboard chosen
– N=number of files to be played in a group:3; % play out 3 
files
– i=1; filename: s1.wav;
– i=2; filename: s2.wav;
– i=3; filename: s3.wav
12
Play Multiple Speech Files
• test_play_files.m
– play the following sequence of files:
Maple_short.wav
s1.wav
beep.wav
test_16k.wav
beep.wav
s2.wav
13
Record Speech into MATLAB Array
• record_speech.m (calls MATLAB function 
wavrecord.m)
• function y=record_speech(fs, nsec);
– fs: sampling frequency
– nsec: number of seconds of recording
– y: speech samples array normalized to peak of 
32767
14
Record Speech into MATLAB Array
• record_display_speech_GUI25.m
15
Plot Speech Using Strips Plot
16
Plot Speech Using Strips Plot
• strips_plot_GUI25.m
17
Plot Speech Using 4‐Line Plot
18
Sample Rate Conversion
• y = srconv(x, fsin, fsout);
– x: input speech array;
– fsin: input speech sampling rate;
– fsout: desired speech sampling rate;
• Example:
– [xin, fsin] = loadwav(‘s5.wav’); % fsin=8000;
– fsout = 10000; % desired sampling rate;
– y = srconv(xin, fsin, fsout);
19
Sample Rate Conversion
• SRC_GUI25.m
20
Filter Speech Waveform
21
Filter Speech Waveform
• filter_GUI25.m
22
Plot Signal and STFT Log Magnitude
23
Multiple Spectra GUI
• multiple_spectra_GUI25.m
24
Plot Spectrogram
25
Plot Spectrogram
• spectrogram_GUI25.m
26
Plot Multiple Spectrograms
27

More Related Content

What's hot

File Handling Python
File Handling PythonFile Handling Python
File Handling PythonAkhil Kaushik
 
Files and file objects (in Python)
Files and file objects (in Python)Files and file objects (in Python)
Files and file objects (in Python)PranavSB
 
Plank
PlankPlank
PlankFNian
 
Python-File handling-slides-pkt
Python-File handling-slides-pktPython-File handling-slides-pkt
Python-File handling-slides-pktPradyumna Tripathy
 
Introduction to R for Learning Analytics Researchers
Introduction to R for Learning Analytics ResearchersIntroduction to R for Learning Analytics Researchers
Introduction to R for Learning Analytics ResearchersVitomir Kovanovic
 

What's hot (7)

File Handling Python
File Handling PythonFile Handling Python
File Handling Python
 
Files and file objects (in Python)
Files and file objects (in Python)Files and file objects (in Python)
Files and file objects (in Python)
 
Plank
PlankPlank
Plank
 
File mangement
File mangementFile mangement
File mangement
 
Tutorial 1
Tutorial 1Tutorial 1
Tutorial 1
 
Python-File handling-slides-pkt
Python-File handling-slides-pktPython-File handling-slides-pkt
Python-File handling-slides-pkt
 
Introduction to R for Learning Analytics Researchers
Introduction to R for Learning Analytics ResearchersIntroduction to R for Learning Analytics Researchers
Introduction to R for Learning Analytics Researchers
 

Similar to Lecture matlab speech_2013

Ry pyconjp2015 karaoke
Ry pyconjp2015 karaokeRy pyconjp2015 karaoke
Ry pyconjp2015 karaokeRenyuan Lyu
 
Immutable Data Structures
Immutable Data StructuresImmutable Data Structures
Immutable Data Structures宇 傅
 
Apache Tika end-to-end
Apache Tika end-to-endApache Tika end-to-end
Apache Tika end-to-endgagravarr
 
Intern Presentation
Intern PresentationIntern Presentation
Intern PresentationApurva Singh
 
Managing large datasets in R – ff examples and concepts
Managing large datasets in R – ff examples and conceptsManaging large datasets in R – ff examples and concepts
Managing large datasets in R – ff examples and conceptsAjay Ohri
 
AdvFS/Advanced File System Ccncepts
AdvFS/Advanced File System CcnceptsAdvFS/Advanced File System Ccncepts
AdvFS/Advanced File System CcnceptsJustin Goldberg
 
Doug Cutting on the State of the Hadoop Ecosystem
Doug Cutting on the State of the Hadoop EcosystemDoug Cutting on the State of the Hadoop Ecosystem
Doug Cutting on the State of the Hadoop EcosystemCloudera, Inc.
 
Text and Speech Analysis
Text and Speech AnalysisText and Speech Analysis
Text and Speech AnalysisLorenzo Monni
 
Language Server Protocol - Why the Hype?
Language Server Protocol - Why the Hype?Language Server Protocol - Why the Hype?
Language Server Protocol - Why the Hype?mikaelbarbero
 
Assignment4.pptx
Assignment4.pptxAssignment4.pptx
Assignment4.pptxjatinchand3
 
Introduction to natural language processing (NLP)
Introduction to natural language processing (NLP)Introduction to natural language processing (NLP)
Introduction to natural language processing (NLP)Alia Hamwi
 
Ppt programming by alyssa marie paral
Ppt programming by alyssa marie paralPpt programming by alyssa marie paral
Ppt programming by alyssa marie paralalyssamarieparal
 

Similar to Lecture matlab speech_2013 (20)

Ry pyconjp2015 karaoke
Ry pyconjp2015 karaokeRy pyconjp2015 karaoke
Ry pyconjp2015 karaoke
 
Immutable Data Structures
Immutable Data StructuresImmutable Data Structures
Immutable Data Structures
 
Apache Tika end-to-end
Apache Tika end-to-endApache Tika end-to-end
Apache Tika end-to-end
 
Intern Presentation
Intern PresentationIntern Presentation
Intern Presentation
 
Rust baksia2014
Rust baksia2014Rust baksia2014
Rust baksia2014
 
Managing large datasets in R – ff examples and concepts
Managing large datasets in R – ff examples and conceptsManaging large datasets in R – ff examples and concepts
Managing large datasets in R – ff examples and concepts
 
NLTK
NLTKNLTK
NLTK
 
Mit6 094 iap10_lec01
Mit6 094 iap10_lec01Mit6 094 iap10_lec01
Mit6 094 iap10_lec01
 
AdvFS/Advanced File System Ccncepts
AdvFS/Advanced File System CcnceptsAdvFS/Advanced File System Ccncepts
AdvFS/Advanced File System Ccncepts
 
Doug Cutting on the State of the Hadoop Ecosystem
Doug Cutting on the State of the Hadoop EcosystemDoug Cutting on the State of the Hadoop Ecosystem
Doug Cutting on the State of the Hadoop Ecosystem
 
Text and Speech Analysis
Text and Speech AnalysisText and Speech Analysis
Text and Speech Analysis
 
Language Server Protocol - Why the Hype?
Language Server Protocol - Why the Hype?Language Server Protocol - Why the Hype?
Language Server Protocol - Why the Hype?
 
firststeps
firststepsfirststeps
firststeps
 
Assignment4.pptx
Assignment4.pptxAssignment4.pptx
Assignment4.pptx
 
محاضرة برنامج التحليل الكمي R program د.هديل القفيدي
محاضرة برنامج التحليل الكمي   R program د.هديل القفيديمحاضرة برنامج التحليل الكمي   R program د.هديل القفيدي
محاضرة برنامج التحليل الكمي R program د.هديل القفيدي
 
Introduction to natural language processing (NLP)
Introduction to natural language processing (NLP)Introduction to natural language processing (NLP)
Introduction to natural language processing (NLP)
 
NLP and LSA getting started
NLP and LSA getting startedNLP and LSA getting started
NLP and LSA getting started
 
Scripting and the shell in LINUX
Scripting and the shell in LINUXScripting and the shell in LINUX
Scripting and the shell in LINUX
 
Ppt programming by alyssa marie paral
Ppt programming by alyssa marie paralPpt programming by alyssa marie paral
Ppt programming by alyssa marie paral
 
Storm
StormStorm
Storm
 

Recently uploaded

UNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its PerformanceUNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its Performancesivaprakash250
 
Introduction to Serverless with AWS Lambda
Introduction to Serverless with AWS LambdaIntroduction to Serverless with AWS Lambda
Introduction to Serverless with AWS LambdaOmar Fathy
 
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Bookingdharasingh5698
 
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXssuser89054b
 
Thermal Engineering Unit - I & II . ppt
Thermal Engineering  Unit - I & II . pptThermal Engineering  Unit - I & II . ppt
Thermal Engineering Unit - I & II . pptDineshKumar4165
 
Unit 1 - Soil Classification and Compaction.pdf
Unit 1 - Soil Classification and Compaction.pdfUnit 1 - Soil Classification and Compaction.pdf
Unit 1 - Soil Classification and Compaction.pdfRagavanV2
 
2016EF22_0 solar project report rooftop projects
2016EF22_0 solar project report rooftop projects2016EF22_0 solar project report rooftop projects
2016EF22_0 solar project report rooftop projectssmsksolar
 
chapter 5.pptx: drainage and irrigation engineering
chapter 5.pptx: drainage and irrigation engineeringchapter 5.pptx: drainage and irrigation engineering
chapter 5.pptx: drainage and irrigation engineeringmulugeta48
 
Design For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the startDesign For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the startQuintin Balsdon
 
A Study of Urban Area Plan for Pabna Municipality
A Study of Urban Area Plan for Pabna MunicipalityA Study of Urban Area Plan for Pabna Municipality
A Study of Urban Area Plan for Pabna MunicipalityMorshed Ahmed Rahath
 
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...roncy bisnoi
 
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance BookingCall Girls Wakad Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance Bookingroncy bisnoi
 
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756dollysharma2066
 
Unleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leapUnleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leapRishantSharmaFr
 
COST-EFFETIVE and Energy Efficient BUILDINGS ptx
COST-EFFETIVE  and Energy Efficient BUILDINGS ptxCOST-EFFETIVE  and Energy Efficient BUILDINGS ptx
COST-EFFETIVE and Energy Efficient BUILDINGS ptxJIT KUMAR GUPTA
 
Hostel management system project report..pdf
Hostel management system project report..pdfHostel management system project report..pdf
Hostel management system project report..pdfKamal Acharya
 

Recently uploaded (20)

UNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its PerformanceUNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its Performance
 
Introduction to Serverless with AWS Lambda
Introduction to Serverless with AWS LambdaIntroduction to Serverless with AWS Lambda
Introduction to Serverless with AWS Lambda
 
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
 
(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7
(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7
(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7
 
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
 
Thermal Engineering Unit - I & II . ppt
Thermal Engineering  Unit - I & II . pptThermal Engineering  Unit - I & II . ppt
Thermal Engineering Unit - I & II . ppt
 
Unit 1 - Soil Classification and Compaction.pdf
Unit 1 - Soil Classification and Compaction.pdfUnit 1 - Soil Classification and Compaction.pdf
Unit 1 - Soil Classification and Compaction.pdf
 
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
 
2016EF22_0 solar project report rooftop projects
2016EF22_0 solar project report rooftop projects2016EF22_0 solar project report rooftop projects
2016EF22_0 solar project report rooftop projects
 
Call Girls in Netaji Nagar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Netaji Nagar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort ServiceCall Girls in Netaji Nagar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Netaji Nagar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
 
chapter 5.pptx: drainage and irrigation engineering
chapter 5.pptx: drainage and irrigation engineeringchapter 5.pptx: drainage and irrigation engineering
chapter 5.pptx: drainage and irrigation engineering
 
Design For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the startDesign For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the start
 
A Study of Urban Area Plan for Pabna Municipality
A Study of Urban Area Plan for Pabna MunicipalityA Study of Urban Area Plan for Pabna Municipality
A Study of Urban Area Plan for Pabna Municipality
 
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
 
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance BookingCall Girls Wakad Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance Booking
 
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
 
Unleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leapUnleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leap
 
(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7
(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7
(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7
 
COST-EFFETIVE and Energy Efficient BUILDINGS ptx
COST-EFFETIVE  and Energy Efficient BUILDINGS ptxCOST-EFFETIVE  and Energy Efficient BUILDINGS ptx
COST-EFFETIVE and Energy Efficient BUILDINGS ptx
 
Hostel management system project report..pdf
Hostel management system project report..pdfHostel management system project report..pdf
Hostel management system project report..pdf
 

Lecture matlab speech_2013