I am working with speech recognition library in Python and trying to save an audio file after submiting to the API that recognize it. So, my problem comes when I want to save that audio to a file.
import speech_recognition as sr
r = sr.Recognizer()
mic = sr.Microphone()
print('Recording...')
with mic as source:
audio = r.listen(source)
with open("audio_file.wav", "wb") as file:
file.write(audio.frame_data)
The audio_file.wav have a size approximately of 210kb(about 4 or 5 seconds recording)
when I try to reproduce the audio file.wav, the player throws an error saying that can not play the audio... due to a codec problem.
My question are: am I missing save a headers or something like that? Is there another way to saves audio bytes into a file?
Edit My answer is in this question Wav file from microphone on Python