已解决
如何制作一个仅Python依靠Python第三方库的听写程序
来自网友在路上 185885提问 提问时间:2023-10-20 22:44:06阅读次数: 85
最佳答案 问答题库858位专家为你答疑解惑
导入所需的库
import speech_recognition as sr
创建一个Recognizer对象
r = sr.Recognizer()
使用麦克风录音
with sr.Microphone() as source:print("Please speak your sentence:")audio = r.listen(source)
使用Google Speech Recognition进行语音识别
try:sentence = r.recognize_google(audio)print("You said: " + sentence)
except sr.UnknownValueError:print("Sorry, I could not understand what you said.")
except sr.RequestError as e:print("Could not request results from Google Speech Recognition service; {0}".format(e))
完整代码:
import speech_recognition as srr = sr.Recognizer()with sr.Microphone() as source:print("Please speak your sentence:")audio =
查看全文
99%的人还看了
相似问题
猜你感兴趣
版权申明
本文"如何制作一个仅Python依靠Python第三方库的听写程序":http://eshow365.cn/6-20460-0.html 内容来自互联网,请自行判断内容的正确性。如有侵权请联系我们,立即删除!