Python上麦克风的WAV文件 [英] Wav file from microphone on Python

查看:189
本文介绍了Python上麦克风的WAV文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的项目是使用麦克风进行说话人识别.

My project is to do speaker recognition using a microphone.

我正在使用speeh_recognition库提取我的麦克风音频,但是该对象的类是"speech_recognition.AudioData",并且我不知道如何将其转换为wav文件(例如,为了使用librosa,然后获得音频功能,甚至可以识别说话者).

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).

有人可以帮我吗?我学习Python已有很短的时间了,因此可能还会有更简单的方法来使用麦克风进行说话人识别:) 非常感谢!

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 !

推荐答案

将音频写入WAV文件:

write audio to a WAV file:

with open("microphone-results.wav", "wb") as f:
    f.write(audio.get_wav_data())

引用 doc :

返回表示WAV文件内容的字节字符串 包含由AudioData实例表示的音频.

Returns a byte string representing the contents of a WAV file containing the audio represented by the AudioData instance.

这篇关于Python上麦克风的WAV文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆