重现问题的步骤(似乎仅限于PC):
离开并重新进入解决了问题,在第2步音频切断后更改扬声器输出也解决了问题
下面是一些基本代码。请注意,在某个时候,我确实发现这种方法在不和谐通话中没有切断音频,所以我猜在他们这一端有一些间歇性的东西——我只是想弄清楚如何在我这一端很好地处理它
import speech_recognition as sr
r = sr.Recognizer()
m = sr.Microphone()
with m as source:
r.adjust_for_ambient_noise(source)
while(True):
print("Please say something...")
audio = r.listen(source)
command = ""
try:
# All the getting command stuff. 0 is a dummy number
command = r.recognize_google(audio)
print("You said : \n " + command)
if command.lower() == "quit": break
except:
print("Error getting command from microphone")
目前没有回答
相关问题 更多 >
编程相关推荐