【发布时间】:2018-01-06 14:12:59
【问题描述】:
说点什么!
Traceback (most recent call last):<br/>
File "speechrecognition.py", line 17, in <module><br/>
print("You said: " + r.recognize_google(audio))<br/>
File "C:\python27\lib\site-packages\speech_recognition\__init__.py", line 828, in recognize_google<br/>
convert_width=2 # audio samples must be 16-bit<br/>
File "C:\python27\lib\site-packages\speech_recognition\__init__.py", line 448, in get_flac_data<br/>
startup_info.dwFlags |= subprocess.STARTF_USESHOWWINDOW # specify that the wShowWindow field of `startup_info` contains a value<br/>
AttributeError: 'module' object has no attribute 'STARTF_USESHOWWINDOW'<br/>
【问题讨论】:
-
你导入
subprocess模块了吗? -
是的,我已经导入了子流程
-
这是我的程序 import speech_recognition as sr r = sr.Recognizer() 以 sr.Microphone() 作为源: print("Say something!") audio = r.listen(source) 尝试: print("你说:" + r.recognize_google(audio)) 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服务;{0}".format(e))
-
很抱歉,您的代码不可读,请相应格式化。但是,据我所见,您没有导入子流程模块,仅导入了 Speech_recognition。
-
我导入了还是有错误
标签: python windows python-2.7 speech-recognition google-speech-api