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.
For more advanced and flexible output options, refer to soundfile.
Parameters:
path : str

path to save the output wav file

y : np.ndarray [shape=(n,) or (2,n)]

audio time series (mono or stereo)

sr : int > 0 [scalar]

sampling rate of y

norm : boolean [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)