Hacker News new | past | comments | ask | show | jobs | submit login

How do I save the audio array to a file on the file system?



There appear to be several ways to do it, but what worked for me was:

   from scipy.io.wavfile import write as write_wav
   write_wav("c:\\wherever\\whatever.wav", SAMPLE_RATE, audio_array)
If you want to play it right away, you can use:

   from playsound import playsound
   playsound("c:\\wherever\\whatever.wav")
What I wasn't able to do was make torchaudio play it directly, without creating an intermediate .wav file. Apparently there is a live-playback backend on the Mac, but not on on any other OS.




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: