小编man*_*noj的帖子

语音识别 UnknownValueError

我已经在 python shell 3.5.8 上试过了

import speech_recognition as sr
import webbrowser as wb

chrome_path = 'C:/Program Files (x86)/Google/Chrome/Application/chrome.exe 
%s'


# obtain audio from the microphone  
r = sr.Recognizer()  
with sr.Microphone() as source:  
   print("Please wait. Calibrating microphone...")  
   # listen for 5 seconds and create the ambient noise energy level  
   r.adjust_for_ambient_noise(source, duration=5)  
   print("Say something!")  
   audio = r.listen(source)  

# recognize speech 
try:
    text = r.recognize_google(audio)
    print("I thinks you said '" + r.recognize_google(audio) + "'")

    f_text='https://www.google.co.in/search?q=' + text
    wb.get(chrome_path).open(f_text)
#except sr.UnknownValueError:  
#  print("I could …
Run Code Online (Sandbox Code Playgroud)

python

7
推荐指数
1
解决办法
8237
查看次数

标签 统计

python ×1