python-3.x - 导入 Google Cloud Speech-to-Text 识别的问题
问题描述
我试着
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('\n\x15google/api/http.proto\x12\ngoogle.api\"T\n\x04Http\x12#\n\x05rules\x18\x01 \x03(\x0b\x32\x14.google.api.HttpRule
\x12\'\n\x1f\x66ully_decode_reserved_expansion\x18\x02 \x01(\x08\"\x81\x02\n\x08HttpRule\x12\x10\n\x08selector\x18\x01
\x01(\t\x12\r\n\x03get\x18\x02 \x01(\tH\x00\x12\r\n\x03put\x18\x03 \x01(\tH\x00
\x12\x0e\n\x04post\x18\x04 \x01(\tH\x00\x12\x10\n\x06\x64\x65lete\x18\x05 \x01(\tH\x00\x12\x0f\n\x05patch\x18\x06 \x01(\tH\x00\x12/\n\x06\x63ustom\x18\x08 \x01(\x0b\x32\x1d.google.api.CustomHttpPatternH\x00\x12\x0c\n\x04\x62ody\x18\x07 \x01(\t\x12\x15\n\rresponse_body\x18\x0c \x01(\t\x12\x31\n\x13\x61\x64\x64itional_bindings\x18\x0b \x03(\x0b\x32\x14.google.api.HttpRuleB\t\n\x07pattern\"/\n\x11\x43ustomHttpPattern\x12\x0c\n\x04kind\x18\x01 \x01(\t\x12\x0c\n\x04path\x18\x02 \x01(\tBj\n\x0e\x63om.google.apiB\tHttpProtoP\x01ZAgoogle.golang.org/genproto/googleapis/api/annotations;annotations\xf8\x01\x01\xa2\x02\x04GAPIb\x06proto3')
TypeError: __new__() got an unexpected keyword argument 'serialized_options'
Python 3.6.4 :: Anaconda, Inc、Google Cloud SDK 228.0.0、app-engine-python 1.9.80、bq 2.0.39、cloud-datastore-emulator 2.0.2、核心 2018.12.07、gsutil 4.34、
解决方案
请运行以下命令
pip install -U protobuf
这将解决问题。
推荐阅读
- c - C 如何在程序终止后处理变量声明?
- node.js - 变量 $file 的值无效 {}; 上传值无效
- gis - geopandas中..cx和sjoin之间通过边界框过滤的区别?
- javascript - 页面加载时使用 JavaScript 更改跨度文本
- python - jupyter_client KernelClient 在启动通道时给出“ChannelABC() 不带参数”
- javascript - Typescript:使用枚举的自定义接口类型
- azure-data-factory - Azure 数据工厂 - 在存储过程活动中使用 SQL 查询内部联接表
- python - protobuf 中的结构与映射
- html - 使 div 填充设置高度没有内容
- ios - 如何检测“长按”