convert mp3 to wav
15 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hi,
I know that my question has already been asked but my problem is different
I created an Arduino Audio Player that plays wav files from SD through speaker
I want to programatically convert mp3 files to wav using the following settings :
Bit resolution : 8bit
Sampling rate : 16000Hz
Audio channels : mono
PCM format : unsigned 8 bit.
However my internet is pretty slow to upload so I'm intending to do this in Matlab
I created a script that will loop through the mp3 files and convert each one of them
folder = 'C:\Users\Test\Documents\Audio\mp3'; % folder containing mp3 files
files = dir( fullfile(folder,'*.mp3') ); % list of mp3 files in folder
files = {files.name}'; % list of the files (file names)
for i=1:numel(files) % loop through each file
fname = fullfile(dirName,files{i}); % fullname of the file
mp3=audioread(fname);
newfile=strrep(fname,'mp3','wav');
wavwrite(mp3,16000,8,newfile);
end
The files are not correcltly converted and the wav file is full of noise I also get the following warning :
Warning: Data clipped during write to file:song1.wav
> In wavwrite>PCM_Quantize at 280
In wavwrite>write_wavedat at 302
In wavwrite at 139
In convert at 13
Thanks in Advance
2 commentaires
Walter Roberson
le 11 Fév 2018
Which MATLAB release are you using? You are not using one of the newest versions: we can tell because wavewrite() no longer exists. But some of the details of what you need to do changed during the releases during which wavewrite did exist.
Réponses (3)
Walter Roberson
le 11 Fév 2018
Use audiowrite() . It is defined in R2013a https://www.mathworks.com/help/releases/R2013a/matlab/ref/audiowrite.html and permits -1.0 ≤ y ≤ +1.0
0 commentaires
da he
le 20 Avr 2019
Modifié(e) : Walter Roberson
le 13 Juin 2021
The follwing procedures was revised based on Mohamed Amine Messaoudi,which can succes run in matlab2019a
%conver MP3 to wav
folder = 'E:\DL_denoise\clips'; % folder containing mp3 files
files = dir( fullfile(folder,'*.mp3') ); % list of mp3 files in folder
files = {files.name}'; % list of the files (file names)
L=length(files) ;
for i=1:L
[y,Fs]=audioread(files{i});
str1=files{i};
filename=strcat(str1(1:end-3),'wav');
audiowrite(filename,y,Fs); %转写成.wav格式文件 convert to wav
end
0 commentaires
Aayush Gupta
le 13 Juin 2021
[Y fs]= audioread(file);
audiowrite('ConvertAudioFile.wav',Y,fs)
0 commentaires
Voir également
Catégories
En savoir plus sur Audio Processing Algorithm Design dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!