我通过跟踪https://cloud.google.com/sdk/docs/quickstart-debian-ubuntu下载了Google。我通过跟踪https://github.com/GoogleCloudPlatform/python-docs-samples/tree/master/speech/cloud-client下载了Google。当我运行python transcribe.py资源/audo.raw时,就会发生错误。我得到了一个错误,TransportError: TransportError port=443):最大重试超过了url: /o/oauth2/token (由SSLError(SSLError(1,u‘’SSL: CERTIFICATE_VERIFY_FAILED证书验证失败(_ssl.c:581)' ) )引起)>)
回溯
E1019 18:46:20.868555489 3813 plugin_credentials.c:74] Getting metadata from plugin failed with error: Traceback (most recent call last):
File "src/python/grpcio/grpc/_cython/_cygrpc/credentials.pyx.pxi", line 154, in grpc._cython.cygrpc.plugin_get_metadata (src/python/grpcio/grpc/_cython/cygrpc.c:7054)
File "/home/pi/py2env/local/lib/python2.7/site-packages/grpc/_plugin_wrapping.py", line 106, in __call__
AuthMetadataPluginCallback(wrapped_cygrpc_callback))
File "/home/pi/py2env/local/lib/python2.7/site-packages/google/auth/transport/grpc.py", line 73, in __call__
callback(self._get_authorization_headers(context), None)
File "/home/pi/py2env/local/lib/python2.7/site-packages/google/auth/transport/grpc.py", line 61, in _get_authorization_headers
headers)
File "/home/pi/py2env/local/lib/python2.7/site-packages/google/auth/credentials.py", line 121, in before_request
self.refresh(request)
File "/home/pi/py2env/local/lib/python2.7/site-packages/google/oauth2/credentials.py", line 117, in refresh
self._client_secret))
File "/home/pi/py2env/local/lib/python2.7/site-packages/google/oauth2/_client.py", line 189, in refresh_grant
response_data = _token_endpoint_request(request, token_uri, body)
File "/home/pi/py2env/local/lib/python2.7/site-packages/google/oauth2/_client.py", line 104, in _token_endpoint_request
method='POST', url=token_uri, headers=headers, body=body)
File "/home/pi/py2env/local/lib/python2.7/site-packages/google/auth/transport/requests.py", line 115, in __call__
raise exceptions.TransportError(exc)
TransportError: HTTPSConnectionPool(host='accounts.google.com', port=443): Max retries exceeded with url: /o/oauth2/token (Caused by SSLError(SSLError(1, u'[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:581)'),))
Traceback (most recent call last):
File "transcribe.py", line 94, in <module>
transcribe_file(args.path)
File "transcribe.py", line 52, in transcribe_file
response = client.recognize(config, audio)
File "/home/pi/py2env/local/lib/python2.7/site-packages/google/cloud/gapic/speech/v1/speech_client.py", line 201, in recognize
return self._recognize(request, options)
File "/home/pi/py2env/local/lib/python2.7/site-packages/google/gax/api_callable.py", line 452, in inner
return api_caller(api_call, this_settings, request)
File "/home/pi/py2env/local/lib/python2.7/site-packages/google/gax/api_callable.py", line 438, in base_caller
return api_call(*args)
File "/home/pi/py2env/local/lib/python2.7/site-packages/google/gax/api_callable.py", line 376, in inner
return a_func(*args, **kwargs)
File "/home/pi/py2env/local/lib/python2.7/site-packages/google/gax/retry.py", line 127, in inner
' classified as transient', exception)
google.gax.errors.RetryError: RetryError(Exception occurred in retry method that was not classified as transient, caused by <_Rendezvous of RPC that terminated with (StatusCode.UNAUTHENTICATED, Traceback (most recent call last):
File "src/python/grpcio/grpc/_cython/_cygrpc/credentials.pyx.pxi", line 154, in grpc._cython.cygrpc.plugin_get_metadata (src/python/grpcio/grpc/_cython/cygrpc.c:7054)
File "/home/pi/py2env/local/lib/python2.7/site-packages/grpc/_plugin_wrapping.py", line 106, in __call__
AuthMetadataPluginCallback(wrapped_cygrpc_callback))
File "/home/pi/py2env/local/lib/python2.7/site-packages/google/auth/transport/grpc.py", line 73, in __call__
callback(self._get_authorization_headers(context), None)
File "/home/pi/py2env/local/lib/python2.7/site-packages/google/auth/transport/grpc.py", line 61, in _get_authorization_headers
headers)
File "/home/pi/py2env/local/lib/python2.7/site-packages/google/auth/credentials.py", line 121, in before_request
self.refresh(request)
File "/home/pi/py2env/local/lib/python2.7/site-packages/google/oauth2/credentials.py", line 117, in refresh
self._client_secret))
File "/home/pi/py2env/local/lib/python2.7/site-packages/google/oauth2/_client.py", line 189, in refresh_grant
response_data = _token_endpoint_request(request, token_uri, body)
File "/home/pi/py2env/local/lib/python2.7/site-packages/google/oauth2/_client.py", line 104, in _token_endpoint_request
method='POST', url=token_uri, headers=headers, body=body)
File "/home/pi/py2env/local/lib/python2.7/site-packages/google/auth/transport/requests.py", line 115, in __call__
raise exceptions.TransportError(exc)
TransportError: HTTPSConnectionPool(host='accounts.google.com', port=443): Max retries exceeded with url: /o/oauth2/token (Caused by SSLError(SSLError(1, u'[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:581)'),))
)>)
我安装的模块可以使用https到ubuntu,所以我真的不明白为什么Google的错误happens.Authentication是可以的,所以我不知道这是为了什么类型的error.How,我应该修复这个吗?
发布于 2022-11-05 23:41:48
它看起来是一个导致错误的grpcio
问题。我建议安装最新版本的Cloud客户端库(它指定了它所需的grpcio
版本),然后再试一次。与其从GH下载它,我建议使用pip install
代替。
"Hello“s2t-demo.py示例 (Py2&3兼容):
from __future__ import print_function
from google.cloud import speech
# Py2 vs. 3 library compatibility
recogcfg = speech.RecognitionConfig if hasattr(
speech, 'RecognitionConfig') else speech.enums.RecognitionConfig
# build request metadata
FILE = 'gs://YOUR_BUCKET/AUDIO_FILE.wav'
body = {
'audio': {'uri': FILE},
'config': {
'language_code': 'en-US',
'encoding': recogcfg.AudioEncoding.LINEAR16,
},
}
# call Speech-to-Text API to transcribe text from specified audio file
S2T = speech.SpeechClient()
rsp = S2T.recognize(**body).results[0].alternatives[0]
print('** %.2f%% confident of this transcript of %r:\n\t%r' % (
rsp.confidence*100., FILE, rsp.transcript))
推荐的步骤(推荐使用虚拟主机):
gcloud auth application-default login
-设置凭据pip install -U pip google-cloud-speech
-更新pip
并安装客户端库pip list
-确认google-cloud-speech
v1.3.4+和grpcio
1.41.1+gsutil cp AUDIO_FILE.wav gs://YOUR_BUCKET
-将音频文件复制到云存储中python s2t-demo.py
-运行应用程序并查看音频文件的转录示例输出:
$ python s2t-demo.py
** 93.05% confident of this transcript of 'gs://bucket/text.wav':
'Google headquarters in Mountain View unveiled the new Android phone at the Consumer Electronics Show Sundar pichai said in his keynote that users love their new Android phones'
代码示例适用于Python 2和3,以防您希望更早地进行升级。
https://stackoverflow.com/questions/46832451
复制相似问题