python语音识别显示错误“模块识别请求失败:内部服务器错误”

wljmcqd8  于 2023-04-22  发布在  Python
关注(0)|答案(1)|浏览(191)

我试图将语音转换为文本,但语音识别模块抛出内部服务器错误。这是我的代码:-

import speech_recognition as s 
sr=s.Recognizer()
print("i am your script and listening you...........................")
with s.Microphone() as m:
 audio=sr.listen(m)
 query=sr.recognize_google(audio,language='eng-in')
 print(query)

我得到错误像:-我是你的脚本和听你...........................................................................................................................................................................................................................................文件“C:\ Users\Believe Itsreal\AppData\Local\Programs\Python\Python310\lib\site-packages\speech_recognition_* init *_. py ",line 894,in recognize_google response = urlopen(request,timeout = self. operation_timeout)File" C:\Users\Believe Itsreal\AppData\Local\Programs\Python\Python310\lib\urllib\request.py ",line 216,in urlopen return www.example.com(url,data,timeout)文件" C:\Users\Believe Itsreal\AppData\Local\Programs\Python\Python310\lib\urllib\request.py ",第525行,在打开response = meth(req,response)文件" C:\Users\Believe Itsreal\AppData\Local\Programs\Python\Python310\lib\urllib\request.py ",line 634,in http_response response = self. parent. error(File" C:\Users\Believe Itsreal\AppData\Local\Programs\Python\Python310\lib\urllib\request.py",line 563,in error return self._call_chain(* args)File" C:\Users\Believe Itsreal\AppData\Local\Programs\Python\Python310\lib\urllib\request.py",line 496,in_call_chain result = func(* args)File" C:\Users\Believe Itsreal\AppData\Local\Programs\Python\Python310\lib\urllib\request.py",line 643,in http_error_default raise HTTPEror(req. full_url,code,msg,hdrs,fp)urllib. error. HTTPError:opener.open内部服务器错误 HTTP Error 500: Internal Server Error 在处理上述异常的过程中,又出现了一个异常: 追溯(最近一次调用):文件"d:\coding\python_in_hole\python code\api.py",line 6,in query = sr. recognize_google(audio,language ='eng-in')文件"C:\Users\Believe Itsreal\AppData\Local\Programs\Python\Python310\lib\site-packages\speech_recognition_* init *_. py",line 896,in recognize_google raise RequestError("recognition request failed:{}". format(e. reason))speech_recognition. RequestError:识别请求失败:内部服务器错误PS D:\coding\python_in_hole〉
我试图更新模块仍然不工作我的代码在同一模块上的一个工作就像一个星期前,但现在代码也不工作在这个模块

ryevplcw

ryevplcw1#

我怀疑这里的问题是传递给sr.recognize_googlelanguage参数不正确,导致了500 http响应。
根据这个PyPI模块的文档,language参数是一个RFC5646语言标记,它采用en-USen-AU
建议:使用字符串en-IN作为language参数。eng-in不是有效的RFC5646语言标记。

相关问题