问题
My project is to do speaker recognition using a microphone.
I'm using the speeh_recognition library to extract my microphone audio, but the object's class is 'speech_recognition.AudioData' and i don't know how to convert it into a wav file (in order to use librosa for example to then get audio features and maybe recognize the speaker).
Could someone please help me on that ? I have been learning Python for not so long so there might also be easier ways to do speaker recognition using a mic :) Many thanks !
回答1:
write audio to a WAV file:
with open("microphone-results.wav", "wb") as f:
f.write(audio.get_wav_data())
Quoting the doc:
Returns a byte string representing the contents of a WAV file containing the audio represented by the AudioData instance.
来源:https://stackoverflow.com/questions/46738569/wav-file-from-microphone-on-python