我正在发送一个长语音识别文件以进行语音识别。
operation = client.long_running_recognize(config, audio)
operation_name = operation._operation.name
还有另一个文件,我必须使用operation_name
(由Google Speech API返回)再次获取响应。
ref:Python way of polling longrunning operations from operation name in Google Cloud?
我尝试了“长时间运行的操作客户端”的get_operation
方法:
from google.api_core import operations_v1
api = operations_v1.OperationsClient()
name = ...
response = api.get_operation(name)
但该行出现以下错误:
api = Operations_v1.OperationsClient()
TypeError:init()缺少1个必需的位置参数:“ channel”
答案 0 :(得分:0)
获得有关Github问题的答案:
from google.cloud import speech
client = speech.SpeechClient()
from google.api_core import operations_v1
api = operations_v1.OperationsClient(client.transport.channel)
name = ...
response = api.get_operation(name)
引用:Github