python - Python语音识别音频的最小激活能级
问题描述
我的用例是智能树莓派婴儿电话。只有当某些词超过一定的“响度”时,它才应该被激活并触发警报。比如“求助!” 应该激活它,但不是“我有权力!”。
它适用于识别,我将结果保存在结果变量中。我知道我可以通过以下方式寻求帮助:
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))
解决方案
推荐阅读
- java - 在不提供架构的情况下使用 Apache Beam Java SDK 读取 Parquet 文件
- file - Unity:如何在主文件夹中获取文件夹然后检索文件?
- java - 如何在下面的 HTML 代码中找到硬橡胶球的 xpath?
- c# - 在 Unity 中缓慢上下移动对象?
- user-interface - 单击图像中存在的非语言按钮时,我想在代码下方的空间中显示 4 行 4 列的菜单,我该怎么做?
- android - firebase_messaging W/FirebaseMessaging(11255):AndroidManifest 中缺少默认通知通道元数据。将使用默认值
- d3.js - D3 Choropleth - 确定纬度/经度点当前是否在地图视图中
- excel - 在第一行而不是最后一行附加到 VBA 日志文件
- batch-file - PDFTK 右键加密
- java - 如何在 Windows 上禁用 Java 未捕获的 C++ 异常报告?