How to convert data file to audio file

Hello. everyone, any one know how to convert data file to audio file (.mp3 or .wav).? I know that matlab can convert audio file to data file. Thank you.

Answers (1)

It depends on what a "data file" is. If you mean e.g. a MAT file, which contains a signal as a vector:
Data = load('File.mat');
FS = 8000; % Frequency
audiowrite('Sound.wav', Data.Y, FS);
Or maybe you mean a text file containing numbers? Then the actual question is how to import a text file.

5 Comments

yes. a text file. I convert signal waveform to text file. it contains number
I tried the program that you give. I load a .mat file. but got an error after run. ''Reference to non-existent field 'Y'.''
You have to use the name as existing in the MAT file. I cannot guess the contents of your file. So either adjust the code to your data, or post the file here.
'1' is txt file. '12' is .mat file that I convert '1' to '12'
Thank you
Than you for your responds, I just upload the files

Sign in to comment.

Asked:

on 3 Aug 2017

Commented:

on 7 Aug 2017

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!