Wav file from microphone on Python

时间秒杀一切 提交于 2019-12-11 15:26:52

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!