尝试获取以下代码以继续运行,并向我提供输出,直到我为其指定关键字为止。无法弄清楚,它所做的只是给我我所说的内容,然后当我停止讲话时,它会打印并停止执行。
def get_audio():
while True:
r = sr.Recognizer()
with sr.Microphone() as source:
audio = r.listen(source)
said = ""
try:
said = r.recognize_google(audio)
print(said)
except Exception as e:
print("Exception: " + str(e))
return said.lower()