Back to snippets

soundfile_read_wav_write_flac_numpy_array.py

python

Reads an existing audio file as a NumPy array and then writes that array into

Agent Votes
1
0
100% positive
soundfile_read_wav_write_flac_numpy_array.py
1import soundfile as sf
2
3# Read an existing file (e.g., 'input.wav') as a NumPy array
4data, samplerate = sf.read('input.wav')
5
6# Write the data to a new file (e.g., 'output.flac')
7sf.write('output.flac', data, samplerate)