导入Google Cloud语音到文本识别时出现问题



我正在尝试

from google.cloud import speech

但有错误

Traceback (most recent call last):
File "test.py", line 4, in <module>
from google.cloud import speech
File "/anaconda3/lib/python3.6/site-packages/google/cloud/speech.py", line 19, in <module>
from google.cloud.speech_v1 import SpeechClient
File "/anaconda3/lib/python3.6/site-packages/google/cloud/speech_v1/__init__.py", line 17, in <module>
from google.cloud.speech_v1.gapic import speech_client
File "/anaconda3/lib/python3.6/site-packages/google/cloud/speech_v1/gapic/speech_client.py", line 26, in <module>
import google.api_core.operation
File "/anaconda3/lib/python3.6/site-packages/google/api_core/operation.py", line 45, in <module>
from google.longrunning import operations_pb2
File "/anaconda3/lib/python3.6/site-packages/google/longrunning/operations_pb2.py", line 23, in <module>
from google.longrunning.operations_grpc_pb2 import *
File "/anaconda3/lib/python3.6/site-packages/google/longrunning/operations_grpc_pb2.py", line 16, in <module>
from google.api import annotations_pb2 as google_dot_api_dot_annotations__pb2
File "/anaconda3/lib/python3.6/site-packages/google/api/annotations_pb2.py", line 15, in <module>
from google.api import http_pb2 as google_dot_api_dot_http__pb2
File "/anaconda3/lib/python3.6/site-packages/google/api/http_pb2.py", line 22, in <module>
serialized_pb=_b('nx15google/api/http.protox12ngoogle.api"Tnx04Httpx12#nx05rulesx18x01 x03(x0bx32x14.google.api.HttpRule
x12'nx1fx66ully_decode_reserved_expansionx18x02 x01(x08"x81x02nx08HttpRulex12x10nx08selectorx18x01
x01(tx12rnx03getx18x02 x01(tHx00x12rnx03putx18x03 x01(tHx00
x12x0enx04postx18x04 x01(tHx00x12x10nx06x64x65letex18x05 x01(tHx00x12x0fnx05patchx18x06 x01(tHx00x12/nx06x63ustomx18x08 x01(x0bx32x1d.google.api.CustomHttpPatternHx00x12x0cnx04x62odyx18x07 x01(tx12x15nrresponse_bodyx18x0c x01(tx12x31nx13x61x64x64itional_bindingsx18x0b x03(x0bx32x14.google.api.HttpRuleBtnx07pattern"/nx11x43ustomHttpPatternx12x0cnx04kindx18x01 x01(tx12x0cnx04pathx18x02 x01(tBjnx0ex63om.google.apiBtHttpProtoPx01ZAgoogle.golang.org/genproto/googleapis/api/annotations;annotationsxf8x01x01xa2x02x04GAPIbx06proto3')
TypeError: __new__() got an unexpected keyword argument 'serialized_options'

Python 3.6.4::Anaconda,Inc,谷歌云SDK 228.0.0,应用程序引擎python 1.9.80,bq 2.0.39,云数据存储模拟器2.0.2,核心2018.12.07,gsutil 4.34,

请运行以下命令

pip安装-U protobuf

这将解决问题。

最新更新