How can I change the sampling frequency of audio signal?
Show older comments
Hi,
I am working on a speech recognition , and am aiming to change the sampling frequency of the audio signal. I wrote the following code :
clear y Fs
%Read the data to the MATLAB using audioread.
[y,fs] = audioread(filename);
%Play the audio.
sound(y,fs);
%change the sampling rate
fs2= fs/2;
audiowrite(filename)
%Read the data back into MATLAB using audioread.
[y,fs2] = audioread(filename);
sound(y,fs2);
when I run it I heard the sound twice in different FS together, But the problem is the original sound has been changed because I wrote on it (audiowrite (filename)).
So can some one help me to change the Fs without changing the original one and compare the results by sound instruction and plot instruction .
Accepted Answer
More Answers (2)
Azzi Abdelmalek
on 13 Jun 2015
[y,fs] = audioread(filename);
%change the sampling rate
fs2= 2*fs/3;
audiowrite(filename,y,fs2)
%Read the data back into MATLAB using audioread.
[y,fs2] = audioread(filename);
sound(y,fs2);
1 Comment
Ayush Bhandarkar
on 25 Jan 2023
0 votes
I guess this should work,
[y,fs] = audioread(filename);
left = (:,1);
fs2 = fs/2;
fs3 = fs*2;
% soundsc(left,fs2);
soundsc(left,fs3);
Categories
Find more on Multirate Signal Processing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!