【发布时间】:2020-05-31 13:59:03
【问题描述】:
我正在制作一个简单的程序来收听我的麦克风并使用谷歌的 api 将其转换为文本。 一切正常,但我的问题是,当我停止说话时,程序会继续收听,并且在我停止说话几秒钟后它就停止了。
我知道这可能是我的背景噪音有问题,虽然我有 Blue Yeti 麦克风,所以它不应该发生反弹,但我仍然尝试调整噪音,但它显示了相同的结果。
import speech_recognition as sr
# obtain audio from the microphone
r = sr.Recognizer()
with sr.Microphone(device_index = 1) as source:
print("Say something!")
#audio = r.adjust_for_ambient_noise(source) - Tried also that
audio = r.listen(source)
print('Stopped listening!')
try:
print("Google Speech Recognition thinks you said " + r.recognize_google(audio, language="he-HE"))
except sr.UnknownValueError:
print("Google Speech Recognition could not understand audio")
except sr.RequestError as e:
print("Could not request results from Google Speech Recognition service; {0}".format(e))
正如预期的那样,即使我几秒钟没有说话,程序也会继续收听,这使得它真的很慢而且很糟糕.. 感谢您的帮助!
【问题讨论】:
标签: python-3.x speech-recognition