Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

matlab 1. Create a new Script file \"run determine longest_word.m\" 2. Load the

ID: 3746432 • Letter: M

Question

matlab

1. Create a new Script file "run determine longest_word.m" 2. Load the audio "my sentence.wav" 3. Segment the words present in the audio file by determining the indices of each word using MATLAB's data cursor in the waveform plot. (You may paste the work you did for Problem 1 Step 4) 4. Determine the duration of each word in seconds. 5. Determine the longest word (highest in terms of seconds) in the sentence you recorded 6. Print the longest word and along with ts duration in seconds using fprintf0

Explanation / Answer

Ans:

clear all; close all; clc;

[my_audio,fs]=audioread('bad_time.wav');

soundsc(my_audio,fs)

figure;

plot(my_audio);

xlabel('Sample Indices');

ylabel('Amplitude in Volts');

title('Original Audio');

one=my_audio(1:200);

two=my_audio(200:500);

three=my_audio(500:850);

four=my_audio(850:end);

repeat_once=[one;one;two;two;three;three;four;four];

soundsc(repeat_once,fs);

audiowrite('repeat_once.wav',repeat_once,fs);

time=(1:length(my_audio))./fs;

figure;

plot(time,my_audio);

xlabel('Time in Seconds');

ylabel('Amplitude');

time_four=length(four)/fs

time_three=length(three)/fs

time_two=length(two)/fs

time_one=length(one)/fs

max_time=max([time_one,time_two,time_three,time_four]);

if(max_time==time_one)

fprintf("Word one is longest word(w.r.t time) : %f ",max_time);

fprintf("%f",one);

fprintf(" ");

elseif(max_time==time_two)

fprintf("Word two is longest word(w.r.t time) : %f ",max_time);

fprintf("%f",two);

fprintf(" ");

elseif(max_time==time_three)

fprintf("Word three is longest word(w.r.t time) : %f ",max_time);

fprintf("%f",three);

fprintf(" ");

elseif(max_time==time_four)

fprintf("Word four is longest word(w.r.t time) : %f ",max_time);

fprintf("%f",four);

fprintf(" ");

end