Hello from January 2026! The example code in section 4 is still awesome after two years, but due to subtle changes in libraries, I had to reformat the audio values before saving the wav file at the end.
From:
sf.write(output_path, audio_values_normalized, sampling_rate)
return {"song": output_path}
To:
final_audio_values = np.ravel(audio_values_normalized)
final_audio_values = final_audio_values.astype(np.float32)
sf.write(output_path, final_audio_values, sampling_rate)
return {"song": output_path}
(Added add 'import numpy as np' near the top)
So if you get an error like this, then that should fix it:
soundfile.LibsndfileError: Error opening 'song_1768411427.wav': Format not recognised.