speech processing for your voice in Matlab
5 views (last 30 days)
Show older comments
myvoice=audiorecorder
disp('Start Recording')
recordblocking(myvoice,10)
disp('End of Recording')
play(myvoice)
y=getaudiodata(myvoice);
plot(y)
1 Comment
Image Analyst
on 6 Sep 2023
If you have any more questions, then ask them, and attach your data and code to read it in with the paperclip icon after you read this:
Answers (1)
Pooja Kumari
on 20 Sep 2023
Dear Liyan,
It is my understanding that you are facing issue with processing the voice and plotting the audio signal in time and frequency domain in MATLAB.
“audiorecorder” object with “SampleRate” property can be used to store Sampling Frequency i.e., “Fs”. You can refer to the below documentation for more information on “audiorecorder” function:
For converting the time domain audio signal to frequency domain, “fft”(fast fourier transform) function can be used. You can refer to the below document for more information on “fft” function:
Below is the code for your reference:
myvoice = audiorecorder; % "audiorecorder" function is used to record audio data from an input device
recDuration = 10; %time duration is taken as 10 sec
disp('Start Recording')
recordblocking(myvoice,10)
disp('End of Recording')
play(myvoice)
% Get the recorded data
y = getaudiodata(myvoice); %getting the data from recorded sound
Fs = myvoice.SampleRate; % Sample rate
X = fft(y);
f = linspace(0,Fs/2,length(y)/2+1); %Using Nyquist Sampling theorem
X = 20*log10(abs(X(1:length(y)/2+1))); % converting time domain to frequency domain with dB scale.
% Plot the recorded waveform in time domain
t = (0:length(y)-1)/fs;
subplot(2,1,1);
plot(t, y);
xlabel('Time (s)');
ylabel('Amplitude');
title('Time-domain Signal');
% Plotting the frequency-domain spectrum
subplot(2,1,2);
plot(f, X);
xlabel('Frequency (Hz)');
ylabel('Magnitude (dB)');
title('Frequency-domain Spectrum');
I hope this helps!
0 Comments
See Also
Categories
Find more on Audio and Video Data in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!