Python语音识别音频的最小激活能级

时间:2021-06-27 09:07:16

标签: python audio microphone speech

我的用例是智能树莓派婴儿电话。只有当说出超过一定“响度”的某些词时,它才应该被激活并触发警报。就像“帮助帮助!”应该激活它,而不是“我有力量!”。

它适用于识别,我将结果保存在结果变量中。我知道我可以通过以下方式寻求帮助:

if "help" in result:

到目前为止,没问题。我也可以设置麦克风的激活能量。但效果有点差。

    r.energy_threshold = 6000

我该怎么做:

<块引用>

跟踪当前口语的能量?

<块引用>

只发送数据到 谷歌(这是一个隐私问题)当某个“响度”已经 达到了吗?

类似于:

audio = r.listen(source)
if(audio.max_energy > 9000):
        result = r.recognize_google(audio)

这是我目前的代码:

import speech_recognition as sr

if __name__ == "__main__":

    r = sr.Recognizer()
    r.energy_threshold = 6000

    while True:
        with sr.Microphone() as source:
            print("Say something!")
            audio = r.listen(source)

        # recognize speech using Sphinx
        try:
            result = r.recognize_google(audio, language='de-De')
            print("Google thinks you said " + result)
        except sr.UnknownValueError:
            print("Google could not understand audio")
        except sr.RequestError as e:
            print("Google error; {0}".format(e))

0 个答案:

没有答案
相关问题