因此,我正在为我的智能灯制作python语音控制。但当我说“crimson”时,它会同时触发“on”和“crimson”,因为“crimson”一词的末尾包含“on”。我真的不想把名字改成其他的。
elif (查询中的‘light’) or (查询中的‘light’):# Home automation
if 'on' in query:
control_lights("light on")
speak("okay, turning on light")
我对Python (和一般编程)比较陌生,正在尝试使用语音识别库。然而,当使用Mac OSX在Python 3.3上运行一个非常简单的程序时。
import speech_recognition as sr
r = sr.Recognizer()
sr.adjust_for_ambient_noise(source, duration = 1)
with sr.Microphone() as source: # use the default microphone as the audio source
audio = r.listen(source)
我正在使用Java在Android中构建一个Android应用程序。我想使用语音文本和文本到语音和一些机器学习的蟒蛇程序,我已经写了。有可能这样做吗?我需要什么技术栈来完成这个任务?
我遇到了各种解决方案,比如使用sl4A、Jython、QPython和在服务器上运行python代码。
请举例说明。例如,如果我想使用以下python代码(使用Google语音识别API将语音转换为文本转换)来运行我的android应用程序:
import speech_recognition as sr
r = sr.Recognizer()
with sr.Microphone() as src: