How to convert an excel file (.csv) to a .wav format/any other audio format file?
68 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Giggs B.
el 11 de Mzo. de 2022
Comentada: Giggs B.
el 14 de Mzo. de 2022
Hi,
I have an excel file which has ~200k data samples stored in one column and I want to convert the data from that file into an audio file. But whenever I use the excel file, there is almost no sound. I want to play it at 40khz frequency.
I am just using this code:
clearvars
a=xlsread('w3.csv'); %read the xls table
figure,plot(a) %this is your signal
xlim([0 200704])
sound(a,40000) %play the signal
audiowrite('w3.wav',a,40000,'BitsPerSample',16);
Can someone help? Thanks.
2 comentarios
Respuesta aceptada
Scott MacKenzie
el 11 de Mzo. de 2022
Editada: Scott MacKenzie
el 11 de Mzo. de 2022
I was able to play your audio data and save it as a .wav file. It's some sort of noise along with a dripping sound. But, I had to first rescale the data to fall between -1 and 1:
clearvars
a = xlsread('temp.csv'); % this is your w3.csv file
a = rescale(a, -1, 1);
figure,plot(a) %this is your signal
xlim([0 200704])
sound(a,40000) %play the signal
audiowrite('w3.wav',a,40000,'BitsPerSample',16);
Más respuestas (1)
Peter Perkins
el 14 de Mzo. de 2022
This
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/926534/image.png)
should give a hint that xlsread is not the right way to go. In this case, you want to use readmatrix:
a = readmatrix("w3.csv")
5 comentarios
Scott MacKenzie
el 14 de Mzo. de 2022
@Giggs B. Hmm, well I'm not sure then. In the code in my answer, if I change xlsread to readmatrix, it works fine.
This sounds like a fairly simple debugging problem. So, for you, it works with xlsread, but it doesn't work with readmatrix. So, try to use both:
n1 = xlsread('3.csv');
n2 = readmatrix('3.csv');
and have a look in n1 and n2 and see what the difference is. That's a good starting point.
Ver también
Categorías
Más información sobre Spreadsheets en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!