语音识别报错
ighack 发布于2018-03 浏览:4577 回复:2
0
收藏
快速回复
最后编辑于2022-04

debugger: process 3256 is connecting

Traceback (most recent call last):
File "D:\Application\python36\lib\site-packages\requests\packages\urllib3\connection.py", line 141, in _new_conn
(self.host, self.port), self.timeout, **extra_kw)
File "D:\Application\python36\lib\site-packages\requests\packages\urllib3\util\connection.py", line 83, in create_connection
raise err
File "D:\Application\python36\lib\site-packages\requests\packages\urllib3\util\connection.py", line 73, in create_connection
sock.connect(sa)
ConnectionRefusedError: [WinError 10061] 由于目标计算机积极拒绝,无法连接。

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "D:\Application\python36\lib\site-packages\requests\packages\urllib3\connectionpool.py", line 594, in urlopen
self._prepare_proxy(conn)
File "D:\Application\python36\lib\site-packages\requests\packages\urllib3\connectionpool.py", line 810, in _prepare_proxy
conn.connect()
File "D:\Application\python36\lib\site-packages\requests\packages\urllib3\connection.py", line 284, in connect
conn = self._new_conn()
File "D:\Application\python36\lib\site-packages\requests\packages\urllib3\connection.py", line 150, in _new_conn
self, "Failed to establish a new connection: %s" % e)
requests.packages.urllib3.exceptions.NewConnectionError: : Failed to establish a new connection: [WinError 10061] 由于目标计算机积极拒绝,无法连接。

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "D:\Application\python36\lib\site-packages\requests\adapters.py", line 423, in send
timeout=timeout
File "D:\Application\python36\lib\site-packages\requests\packages\urllib3\connectionpool.py", line 649, in urlopen
_stacktrace=sys.exc_info()[2])
File "D:\Application\python36\lib\site-packages\requests\packages\urllib3\util\retry.py", line 376, in increment
raise MaxRetryError(_pool, url, error or ResponseError(cause))
requests.packages.urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='aip.baidubce.com', port=443): Max retries exceeded with url: /oauth/2.0/token?grant_type=client_credentials&client_id=********&client_secret=******* (Caused by ProxyError('Cannot connect to proxy.', NewConnectionError(': Failed to establish a new connection: [WinError 10061] 由于目标计算机积极拒绝,无法连接。',)))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "D:\Application\pycharm-professional-2017.1\helpers\pydev\pydevd.py", line 1585, in
globals = debugger.run(setup['file'], None, None, is_module)
File "D:\Application\pycharm-professional-2017.1\helpers\pydev\pydevd.py", line 1015, in run
pydev_imports.execfile(file, globals, locals) # execute the script
File "D:\Application\pycharm-professional-2017.1\helpers\pydev\_pydev_imps\_pydev_execfile.py", line 18, in execfile
exec(compile(contents+"\n", file, 'exec'), glob, loc)
File "G:/code/Python/baiduAudioRecognition/baidu-aipSDK.py", line 11, in
result = client.synthesis('你好凯文','zh',1,{'vol':5})
File "D:\Application\python36\lib\site-packages\baidu_aip-2.0.0.1-py3.6.egg\aip\speech.py", line 92, in synthesis
File "D:\Application\python36\lib\site-packages\baidu_aip-2.0.0.1-py3.6.egg\aip\base.py", line 89, in _request
File "D:\Application\python36\lib\site-packages\baidu_aip-2.0.0.1-py3.6.egg\aip\base.py", line 165, in _auth
File "D:\Application\python36\lib\site-packages\requests\api.py", line 70, in get
return request('get', url, params=params, **kwargs)
File "D:\Application\python36\lib\site-packages\requests\api.py", line 56, in request
return session.request(method=method, url=url, **kwargs)
File "D:\Application\python36\lib\site-packages\requests\sessions.py", line 488, in request
resp = self.send(prep, **send_kwargs)
File "D:\Application\python36\lib\site-packages\requests\sessions.py", line 609, in send
r = adapter.send(request, **kwargs)
File "D:\Application\python36\lib\site-packages\requests\adapters.py", line 485, in send
raise ProxyError(e, request=request)
requests.exceptions.ProxyError: HTTPSConnectionPool(host='aip.baidubce.com', port=443): Max retries exceeded with url: /oauth/2.0/token?grant_type=client_credentials&client_id=*********&client_secret=********** (Caused by ProxyError('Cannot connect to proxy.', NewConnectionError(': Failed to establish a new connection: [WinError 10061] 由于目标计算机积极拒绝,无法连接。',)))

Process finished with exit code 1

 

APP_ID, API_KEY, SECRET_KEY

这三个值我确认是对的

client = AipSpeech(APP_ID, API_KEY, SECRET_KEY)
#client.setConnectionTimeoutInMillis(100000)
#client.setSocketTimeoutInMillis(100000)
result = client.synthesis('你好凯文','zh',1,{'vol':5})
if not isinstance(result,dict):
     with open('auido.mp3','wb') as f:
         f.write(result)

收藏
点赞
0
个赞
共2条回复 最后由用户已被禁言回复于2022-04
#3ighack回复于2018-03

http://aip.baidubce.com/oauth/2.0/token?grant_type=client_credentials&client_id=*********&client_secret=**********

我直接访问这个是可以获得token的

现在不知道是什么原因

而且我发现pip install baidu-aip也装不了

我是下载以后安装的

0
#2用户已被禁言回复于2018-03

你这个是PythonSDK调用。你尝试更换你的网络试试。或者更新最新的SDK再次尝试。

from aip import AipSpeech
APP_ID = 'appid'
API_KEY = 'apikey'
SECRET_KEY = 'sercetkey'
client=AipSpeech(APP_ID,API_KEY,SECRET_KEY)
result  = client.synthesis('你好百度', 'zh', 1, {
    'vol': 5,
})
# 识别正确返回语音二进制 错误则返回dict 参照下面错误码
if not isinstance(result, dict):
    with open('output.mp3', 'wb') as f:
        f.write(result)
2
TOP
切换版块