You are on page 1of 7

Lab #2 (Introduction to MATLAB) This lab addresses the following course learning objective(s):

Understand simulation software of MATLAB. Learn how to deal with speech signals.

In this lab, you will learn how to read speech files and how to create a new speech file. In addition, you will see that speech data, once loaded into MATLAB, can be manipulated just like any other vector (or matrix) we have studied so far. 1. Practice basic parts Create your own directory under the C: directory. Do not put space in between words for your directory name (if you still have the directory you created for Lab #1, you do not need to create a new one). Download the MATLABlecture2.m and ENGR320MATLABLecture2.ppt files from the Blackboard website into your directory. The Power Point file explains some basic commands related to this lab. Read it first. Once you understand it, type cd c: \my_directory_name at the command window of MATLAB to make your directory the working directory. Open the downloaded file, MATLABlecture2.m. Run the downloaded program cell by cell (i.e., choose each cell in MATLAB editor and click right mouse button. Choose Evaluate current cell or type F9). Running the file cell by cell, observe what occurs on the command window and put

comments for each line in the MATLABlecture2.m file. Your comments should include your
knowledge about the command in each line. (e.g., what it is for, what will this command cause to happen, etc). One other way to run the downloaded file is by typing the file name at the command window prompt. This will execute all lines in the file. 2. Reading a speech signal 2.1 Download speech files, TCAR01.wav and TDOV02.wav, from our website to your own directory. 2.2 Type the following commands in the MATLAB window.

>> cd 'c:your_directory_names' >> [Sph1,Fs1,Nbits1]=WAVREAD('TCAR01.wav');


2.3 Now you stored a speech file into variable Sph1. Check what Fs and Nbits mean using the help and/or doc commands. On the first subplot, out of 4 possible subplots, plot your

speech file using a in Black line and put the title, Lab2-2.3 result, a speech waveform. Make sure you know how to read a speech file, which is in wav format. Ans.

2.4

After playing the speech file, write down what the speech file says : _____________________________________________________________________________

2.5

Find out the size of your Sph1 variable. To check it, type the command below

>> size(Sph1)
Size

2.6

Flip the loaded speech file as shown below and plot it on the second subplot of the figure started in 2.3. Plot your speech file using a red line and put the title, Lab2-2.6 result, a flipped speech waveform >> y = flipud(Sph1);

3. 3.1

Making a speech signal Load the second speech file, TDOV02.wav. On the third subplot of your figure, plot the new speech file using a blue line. Add the title Lab2-3.1 result, a speech waveform.

3.2

Concatenate the second speech file into the end of the first speech file. Depending on the size of a speech file, you can do it like this: 1) Sph3 = [Sph1; Shp2] if Sph1 and Sph2 are column vectors, or 2) Sph3 = [Sph1, Shp2] if Sph1 and Sph2 are row vectors. The resulting vector, Sph3, will have the new speech formed from Sph1 and Sph2. On the fourth subplot, plot the connected speech file using a green line. Add the title Lab2-3.2 result, a connected speech waveform.

3.3

You can create a new file in .wav format using the new, concatenated speech data. To make the .wav file, write the following command. Check to see whether there is a new speech file, ConnectedSph.wav, in your directory.

>> WAVWRITE(Sph3,Fs1,Nbits1,'ConnectedSph.wav')
4. Manipulating a sampling rate 4.1 The sampling rate of a speech signal can be changed. Perform the commands below make the change. Listen to the generated speech file, Sph1HalfSR.wav. Note that there is a difference between the original speech and the modified speech. (We will learn what the sampling rate is later in class) >> Fs1 = Fs1/2; >> WAVWRITE(Sph1,Fs1,Nbits1,'Sph1HalfSR.wav') 4.2 With a new sampling rate equal to of the original sampling rate, Fs1, create a speech file called Sph1FourthSR.wav. Listen to the speech file, Sph1FourthSR.wav. Note that there is a difference between the original speech and the modified speech

El audio Sph1FourthSR.wav se reproduce 4 veces ms lento que TCAR01.wav. 5. Manipulating a speech signal 5.1 For a stereo speech file, the loaded data size is different. If you read a speech file in stereo, it shows 2 columns of speech data. As you can verify with the size command, speech files Sph1 and Sph2 are one-column data, (i.e., mono speech). You can change them into stereo signals. In other words, you need to duplicate the first column into a second one. Change Sph1 and Sph2 into stereo data files (i.e., 2 column data) and write each one into new speech files called Sph1Stereo.wav and Sph2Stereo.wav

5.2 Play the stereo speech files and listen to them. Do you notice any differences?

En el Ploteo se puede apreciar que la seal sigue siendo la misma. En lo personal, no

existe diferencia audible. 6. Lab report For the lab report, put your comments for MATLABlecture2.m and print out all supporting documents for Steps 2-5. In addition, make a function that satisfies the requirements below and call your function with the two speech files you have. Submit all your test results. 6.1 Your function must take 2 mono speech files (name in text string). 6.2 Your function must return 5 output data. Two outputs are the respective stereo outputs of the two inputs. The third output is the connected speech data the two inputs. Finally, the last two outputs are mono speech data, but with half of the data exchanged with that from the other input signal. Clases de marcha, kinovea

You might also like