I would like to make an autoencoder for music generation using PyTorch. In input, I would like to have a Waveform (from a .wav file) and I want the output to be a Waveform. My problem is that I don't know how to get a .wav file from a waveform that is the output... Does anybody have an idea?
2 Answers
$\begingroup$
$\endgroup$
Python has a soundfile package. There's also scipy.io.wavfile
$\begingroup$
$\endgroup$
In MATLAB you can create a .wav file waveFileName.wav
from a waveform y
with sampling frequency Fs
using MATLAB's audiowrite as follows:
filename = 'waveFileName.wav';
audiowrite(filename,y,Fs);
You can also read and output a waveform y
and its sampling frequency Fs
from the .wav file waveFileName.wav
using MATLAB's audioread as follows.
[y,Fs] = audioread('waveFileName.wav');
I am sure there must be corresponding functions in Python.