Need help with Code
3 ビュー (過去 30 日間)
古いコメントを表示
I need help figuring out this Matlab program. Please Help
In this part of the exercise, you will analyze the different voiced letter. Let us look at “vowels”. Vowels are the voice segment generated by vocal cord vibrations. These are like triangular wave, which contains not only fundamental frequency but also many harmonics. These harmonics referred as “formant frequencies”. Typical formant frequencies for man, women, and children’s are depicted in following table. Of course, individual voice is different; therefore, frequencies also drift proportionally.
Table-1 Average formant frequencies in Hz
Now, in this part of exercise, you will record your own sound and identify frequencies that might be close to the average values listed in the above Table-1.
Procedure:
Record your sound into the Matlab array. Look into the audio device available in your laptop. Use the following function to see your local default audio setting.
A = audiodevinfo
This function returns a structure in A. Use (.) operator to see different field associated with this structure.
à You have to use audiorecorder to create audio object for it. Use sampling frequency to 8000 Hz and keep recording time for each word about 5 seconds. Read the data into mono sound format and use 8-bits per sound sample. Use recordblocking function to record your into the object.
à Load your record data from the object into the variable rec1, rec2,…., rec5 for your utterances(beat, bat, boot, pot, and but). You can use getaudiodata() function for it.
à Now, visualize the time domain speech using a plot() function.
à The frequency content of the recording can be analyzed by viewing power spectral density of your signal. You can fft() function to convert audio segment into frequency domain. Number of samples you can have about 256 or more power of two. Later, take absolute value and use 20*log10( ) to represent into decibel value. Notice that it contains lots of frequencies and showing noisy behavior.
à You can use psudospectrum for clean measurement of only prominent frequencies in your graph. Use peig() function for it. Pass argument p = 8. Increase the p value to 16 to see more peaks in your spectrum. If result is too off to the observation in Table-1 then try recording again. Carefully observe your psudospectrum of the speech segment. Record peak frequencies into the Table-2.
à Note that individual voices are different. Therefore, you will not have the same numbers as depicted in Table-1. So, 10-15%variations are expected.
Code that is being used(I'm assuming. If it doesn't work with the rest of the program, by all means, use your own):
%% This file generates stereo audio tone at different sampling rate
%% Section of this code generates stereo signal and varify both channel
% working correctly or not.
clc
f = 5000; % Test freq
Fs = 44.1e3; % sampling freq
Ts = 1/Fs; % sampling duration
t = 0:Ts:0.2; % max time
n = 1;
while(n < 5)
y = sin(2*pi*f*t); % sinewave tone
y = [[y;zeros(1,length(y))] [zeros(1,length(y));y]]'; % L and R channel signal
sound(y,Fs); % sound playback
pause(0.4);
n = n+1;
end
% Following section of code verify frequency response of our headphone
% throughout the range of audible frequnencies
clc
clear all;
Fs = 44.1e3; % sampling freq
Ts = 1/Fs; % sampling duration
t = 0:Ts:1; % max simulation time
f = 20;
while(f < 20000)
y = sin(2*pi*f*t); % sinewave tone
y = [y;y]';
sound(y,Fs);pause(1);
fprintf('Frequency Tested: %d\n', f);
if ((f>=20) && (f<300))
f = f + 20;
elseif ((f>=300) && (f<10000))
f = f + 500;
elseif ((f>=10000) && (f<20000))
f = f + 500;
end
end
1 件のコメント
Walter Roberson
2019 年 11 月 20 日
Please be more specific on what you need assistance with. Are you encountering an error message?
回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Simulation, Tuning, and Visualization についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!