【发布时间】:2020-02-03 13:41:46
【问题描述】:
我尝试了从 1 到 10 的数字,它运行良好,但我需要它来处理所有数字,并且为每个数字编写代码是不可行的。 我也需要它在我的代码中没有发生的句子中工作。 请各位大侠帮帮我...... 这是我的代码....
import speech_recognition as sr
import time
t = ['one','two','three','four','five','six','seven','eight','nine','ten']
r = sr.Recognizer()
with sr.Microphone() as source:
print('Speak anything: ')
audio = r.listen(source)
try:
text = r.recognize_google(audio)
print('You said : {} '.format(text))
time.sleep(1)
for i in range(0,10):
if (t[i] == text):
print('/n',i)
except:
print('Sorry could not recogonize your voice')
【问题讨论】:
标签: python python-3.x math speech-recognition speech-to-text