save_waveform_as_mp3#

scikitplot.doremi.save_waveform_as_mp3(waveform, file_path='output.mp3', sample_rate=44100, amplitude_int=32767, bitrate='192k', metadata=None)[source]#

Save waveform as an MP3 file using pydub and ffmpeg, with support for mono or stereo.

Parameters:
waveformnp.ndarray

Waveform as float32 array, range [-1, 1].

file_pathstr, default=”output.mp3”

Output file path, must end with ‘.mp3’.

sample_rateint or None

Sampling rate in Hz, defaults to 44100.

amplitude_intint or None

Integer scale factor for converting float waveform to PCM int16. Defaults to 32767 (16-bit max).

bitratestr or None

Bitrate string for MP3 encoding (e.g., ‘192k’).

metadatadict or None

Metadata tags to embed into the MP3 file.

Returns:
str

The file path of the saved audio.

Parameters:

Examples

>>> save_waveform_as_mp3(
...     tone, "Do4.mp3", metadata={"title": "Do4", "artist": "NoteGen"}
... )