Caution

You're reading an old version of this documentation. If you want up-to-date information, please have a look at 0.9.1.

librosa.output.write_wav

librosa.output.write_wav(path, y, sr, norm=False)[source]

Output a time series as a .wav file

Note: only mono or stereo, floating-point data is supported.

Warning

This function is deprecated in librosa 0.7.0. It will be removed in 0.8. Usage of write_wav should be replaced by soundfile.write.

Parameters
pathstr

path to save the output wav file

ynp.ndarray [shape=(n,) or (2,n), dtype=np.float]

audio time series (mono or stereo).

Note that only floating-point values are supported.

srint > 0 [scalar]

sampling rate of y

normboolean [scalar]

enable amplitude normalization. For floating point y, scale the data to the range [-1, +1].

See also

soundfile.write

Examples

Trim a signal to 5 seconds and save it back

>>> y, sr = librosa.load(librosa.util.example_audio_file(),
...                      duration=5.0)
>>> librosa.output.write_wav('file_trim_5s.wav', y, sr)