Uploaded by Waseelkhalid50

LAB # 09

advertisement
LAB # 09
TALHA SHAHZAD ( 20B-015-CE )
DIGITAL SIGNAL PROCESSING (EL-413)
TASKS:
1) You have to record your voice saying “My name is …. My roll no is …… and I am
studying at Usman Institute of Technology” and create .wav file. You have to create a
new .wav file in which speech segments are shuffled or wrapped version of spoken
sentence. (Here you will be implementing speech segmentation.)
PLAN:
In first part, I have recorded my voice using audio recorder, then converted it into double
format to create the audio file my Speech in .wav format.
In the second part, I read the audio file. Then, I made two segments of it. First one is that in which
I am saying ‘my name is Talha’ and the second one is ‘my roll no is 20B-015-CE and I am
studying at Usman institute of technology’. After that I shuffle both by putting the second part
first and first part second.
Then I saved that audio by audio write command.
PSEUDO-CODE:
RECORDING VOICE:
•
•
•
•
•
•
Initialize variable to record audio
Strat recording
Stop recording
Play the recorded voice to confirm recording
Change the format to double
Save the audio file
SEGMENTATION:
•
•
•
•
•
•
Read the audio file
Break into 2 segments
Play both parts
Shuffle them
Play the shuffled audio
Save the shuffled audio
CODE:
RECORDING VOICE:
r = audiorecorder(44100, 16, 1);
record(r); stop(r); p = play(r);
mySpeech = getaudiodata(r);
audiowrite('mySpeech.wav',mySpeech,44100);
LAB # 09
TALHA SHAHZAD ( 20B-015-CE )
SEGMENTATION:
[x,t] = audioread('mySpeech.wav');
segment1 = x (1:66000); sound
(segment1,44100); segment2 = x
(66000:297984); sound (segment2,44100);
shuffled = [segment2,segment1]; sound
(shuffled,t);
audiowrite('Task_01.wav',shuffled,t);
2) YOU HAVE TO ADD THE DISTORTION IN AN ORIGINAL .WAV FILE BY USING A
SIMPLE TIME- DOMAIN OPERATION.
PLAN:
To add distortion, I have used function rand that generated random values. The dimension that
is given to the rand function are same as the dimensions of the audio file. Then, audio file
values and rand generated values are added to create the audio file.
PSEUDO-CODE:
•
•
•
•
Read audio file
Play audio
Generated random number
Add to the audio file
•
Save the audio file Code:
[x,t] = audioread('mySpeech.wav');
sound(x,t); x1 = rand (297984,2); x2 =
x+x1; sound(x2,t);
audiowrite('Task_02.wav',x2,t);
Download