MATLAB Functionality For Digital Speech Processing
MATLAB Functionality For Digital Speech Processing
Speech Processing
• MATLAB Speech Processing Code
• MATLAB GUI Implementations
Lecture_3_2013 1
Graphical User Interface
2
Basics
Waveform Strips Plot
Graphics
Panel 1
Buttons 1-11
Panel 2 Graphics
Panel 2
Panel 1 Panel 3 5
GUI LITE 2.6 Setup Process
• Create a directory for loading all necessary file folders for creating GUI 26
exercises; i.e., call this directory:
‘matlab_central_speech’
• Define full path to the chosen directory; i.e.,
path_to_speech=‘C:\data\matlab_central_speech’
• Download (from MATLAB Central), and place in the chosen directory, the
following code and data folders:
– functions_lrr; speech_files; highpass_filter_signal; VQ;
– cepstral coefficients; isolated_digit_files; GUI_LITE_26;
• Download (from MATLAB Central) the folder:
‘pathnew_matlab_central.m’
• Run pathnew script to set up path links to GUI LITE 26 and to the
directories above
6
GUI LITE 2.6 Setup Process
• Search for MATLAB Central using web search tool with
search input ‘MATLAB Central’ and go to MATLAB
Central
• Click on File Exchange
• In the File Exchange website type ‘speech processing
exercises’ in the search box
• Find and download each of the folders from the
previous vu-graph;
– find the folder of interest
– click on download
– from the displayed zip file, choose extract and search for
the matlab directory and download all files
7
GUI LITE 2.6 Design Process
• begin with a rough sketch of the GUI 2.6 output, segmented
into button panels, graphics panels, text boxes, and buttons
• create exercise folder; e.g., ‘hello_goodbye_world’
• run program ‘runGUI.m’ to create GUI elements and save as a
GUI file (e.g., filename.mat);
• the software also creates an apps program named
filename_GUI26.m and a Callbacks program (just the GUI
structure) named Callbacks_filename_GUI26.m
• edit the program Callbacks_filename_GUI26.m by adding the
appropriate callback code for each of the graphics panels, text
boxes and button boxes
• run the resulting exercise and loop on GUI design and
Callbacks implementation
8
Hello/Goodbye World Plan
Design Specs:
• 2 Panels (for linking
inputs and outputs)
• 3 Buttons (all
pushbuttons) (for
embedding Callback
code to play two
messages and to close
up the GUI)
9
GUI26 Initial Screen
10
GUI26 Creation for ‘hello_goodbye_world’
• run the program ‘runGUI.m’ and click on the ‘New’ button
• enter values for the number of panels (2), number of graphics
panels (0), number of text boxes (1), and number of buttons (3)
• enter the name for the GUI .mat file (‘hello_goodbye_world’)
• automatically create the set of GUI objects specified above,
using the mouse cursor to define the range and properties of
each object (this step is guided by the program ‘runGUI.m’
• the resulting specifications for the GUI are automatically saved in
the designated .mat file, ‘hello_goodbye_world.mat’
• edit the Callbacks routine,
‘Callbacks_hello_goodbye_world_GUI26.m’, by entering the
MATLAB code for the graphics panels, text boxes and button
boxes 11
GUI26 Callback Code – Button 1
% Callback for button 1 – print out message Hello World
function button1Callback(h,eventdata);
% title box
stitle1=strcat(‘Hello World Using GUI2.5’);
set(titleBox1, ‘String’, stitle1);
set(titleBox1, ‘FontSize’, 25);
% title box
stitle1=strcat(‘Goodbye World Using GUI2.5’);
set(titleBox1, ‘String’, stitle1);
set(titleBox1, ‘FontSize’, 25);
% title box
stitle1=strcat('Close GUI');
set(titleBox1,'String',stitle1);
set(titleBox1,'FontSize',25);
uiwait(msgbox('Closing GUI','Message2','modal'));
% waitfor(errordlg('Closing GUI','Message2'));
% return;
display Goodbye
close(gcf);
end 14
hello_goodbye_world
run:
hello_goodbye_world_GUI26.m
directory:
hello_goodbye_world
15
hello_goodbye_world
Text Box1
Button1 - Pushbutton
Message Box from Code
Button2 - Pushbutton
Button3 - Pushbutton
Panel2 Panel1
16
hello_goodbye_world – GUI
Modifications
• Run program ‘runGUI.m’ to bring up GUI Lite 2.6 editor
• Choose Mod (modify) and select GUI file
‘hello_goodbye_world.mat’ for editing
• Choose ‘Move & Resize Feature’ option
• Choose ‘Button’ option
• Left click inside button to be modified
• Choose new button coordinates by using graphics cursor to
identify lower left and upper right corners of modified
button
• Click ‘Save GUI’ button
• Iterate on other buttons
• Click ‘Quit’ option to terminate GUI Lite 2.6 editor
17
GUI Lite 26 Edit Screen
2 Panels
0 Graphics Panels
1 Text Box
3 Buttons
18
GUI LITE 2.6 Edit Screen
Add Feature
Delete Feature
Feature Index
Save GUI
Save GUI As
Quit
hello_goodbye_world_GUI26.m19
GUI Lite 2.6 Features
• separates GUI design from Callbacks for each
GUI element
• provides a versatile editor for modifying GUI
elements without impacting the Callback
actions
• provides a GUI element indexing feature that
enables the user to identify GUI elements with
the appropriate Callback elements
20
Missing GUIDE Features
21
Pyramid of Learning
Ability to implement
theory and concepts in
working code (MATLAB, C,
C++); algorithms,
applications
Basic understanding of
how theory is applied;
autocorrelation,
waveform coding, …
Mathematics, derivations,
signal processing; e.g.,
STFT, cepstrum, LPC, …
24
MATLAB Exercise Categories
• The speech processing exercises are grouped
into 5 areas, namely:
– Basics of speech processing using MATLAB (5)
– Fundamentals of speech processing (6)
– Representations of speech in time, frequency,
cepstrum and linear prediction domains (22)
– Algorithms for speech processing (7)
– Applications of speech processing (17)
25
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 (lower/higher) sampling rate
• lowpass/highpass/bandpass filter a speech file (MATLAB array) to eliminate DC
offset, hum and low/high 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)
29
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
31
Play Multiple Speech Files
• *play_multiple_files.m;
– sequence of filenames read in via filelist, keyboard or file search
32
Play Multiple Speech Files
• test_play_files.m
– play the following sequence of files:
s2.wav
s3.wav
s4.wav
s5.wav
s6.wav
play_multiple_files_GUI26.m
33
Record Speech into MATLAB Array
• record_speech.m (calls MATLAB function
audiorecorder.m, formally wavrecord.m)
34
Display Speech Waveform
Strips Plot
4-Line Plots
35
Basics
Zoom Waveform Strips Plot
• Plotting and examining speech/audio waveforms is one
of the most useful ways of understanding the
properties of speech and audio signals.
• This MATLAB Exercise displays a speech/audio
waveform as a single running plot of samples (called a
Strips Plot).
• Exercise plots from designated starting sample to
designated ending sample, with a user-specified
number of samples/line.
• Zoom feature to select region of signal for display.
• Plots use either samples or seconds, as specified by the
user.
36
Basics
Waveform Strips Plot
37
Basics
Waveform Strips Plot – Zoom 1
38
Basics
Waveform Strips Plot – Zoom 2
zoom_strips_plot_GUI25.m 39
*Plot Speech Using 4-Line Plot
40
Sampling 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);
41
Sampling Rate Conversion Basics
SRC_GUI25.m 42
Basics
Frame-Based Spectrums
NB_WB_spectra_GUI25.m 44
Basics
Wideband/Narrowband Spectrogram
Spectrogram_GUI25.m 45
*Plot Multiple Spectrograms
46
Fundamentals
47
Representations
• time domain exercises
– windows; features; autocorrelation estimates; amdf
• frequency domain exercises
– phase/magnitude; overlap-add windows; WSOLA
• cepstral domain exercises
– analytical cepstrum; single pole cepstrum; FIR
sequence cepstrums; cepstrum aliasing; cepstrum
liftering; cepstral waterfall
• linear prediction exercises
– LPC frames; LPC error; LPC varying p; LPC varying L;
LSP roots; plot roots
48
Algorithms
• endpoint detector
• Voiced-Unvoiced-Background estimation
method
• autocorrelation pitch detector
• log harmonic spectral waterfall plots
• cepstral pitch detector
• SIFT pitch detector
• formant estimation method
49
Applications – Part 1
• Speech waveform coding;
– statistical properties of speech; quantization
characteristics of a B-bit uniform or mu-law compressed
and quantized speech file; uniform quantization; mu-law
compression; mu-law quantization; Signal-to-Noise Ratio
(SNR) of uniform and mu-law quantizers
• Automatic Gain Control (AGC)
• Adaptive Differential Pulse Code Modulation (ADPCM)
waveform speech coder
• Vector Quantizer (VQ); VQ Cells
• Synthetic vowel synthesizer
50
Applications – Part 2
51
Speech Processing Exercises
• Search for MATLAB Central using local browser
• Click on file exchange; search for speech processing exercises
• Create a directory in which the various speech processing apps and data folders will
be placed (e.g., speech_apps); use the full path in the pathnew routine (see
below); e.g., C:\data\speech_apps
• If loading one or more speech processing exercises, download the following:
• Read_Me which explains the downloading process
• pathnew_matlab_central which links a set of functions and several data sets
to the current path including:
• runGUI – the set of files for creation of GUIs for the various speech apps
• speech_files – set of files used to demonstrate matlab apps capabilities
• functions_lrr – set of matlab functions used by the various matlab apps
• high pass filter signal – filtering function for speech signals
• isolated digit files – training and testing files for isolated digit recognition
• cepstral coefficients – used for vector quantization matlab app
• Be sure to put each of the downloaded folders in the chosen directory so that the
path links will be consistent
52
Summary
• Set of about 60 MATLAB speech processing
exercises
• Exercises aligned with distinct sections in the
textbook TADSP by Rabiner/Schafer
• Each exercise has an associated Graphical User
Interface created using a GUI LITE program and
created expressly for these speech processing
exercises
• GUI LITE design and implementation Callbacks
are in totally separate code packages
53