Php 类google.cloud.speech.v1.LongRunningRecognitizeMetadata尚未添加到描述符池

Php 类google.cloud.speech.v1.LongRunningRecognitizeMetadata尚未添加到描述符池,php,grpc,google-speech-api,google-cloud-speech,Php,Grpc,Google Speech Api,Google Cloud Speech,我在尝试恢复语音到文本操作时遇到此错误 Google\Protobuf\Internal\GPBDecodeException:解析过程中出错:类Google.cloud.speech.v1.LongRunningRecognitizeMetadata尚未添加到Google\Protobuf\Internal\Message->parseFromJsonStream中的描述符池中 我正在做的是启动长运行操作并存储名称。稍后,我将创建一个单独的页面,其中包含基于先前存储的名称的操作状态 这是我用来

我在尝试恢复语音到文本操作时遇到此错误

Google\Protobuf\Internal\GPBDecodeException:解析过程中出错:类Google.cloud.speech.v1.LongRunningRecognitizeMetadata尚未添加到Google\Protobuf\Internal\Message->parseFromJsonStream中的描述符池中

我正在做的是启动长运行操作并存储名称。稍后,我将创建一个单独的页面,其中包含基于先前存储的名称的操作状态

这是我用来获取操作状态的工具

$speechClient = new SpeechClient();
$operationResponse = $speechClient->resumeOperation($record->operation_name, 'longRunningRecognize');

有可能这样做吗?

我花了很长时间才想出这样一个简单的解决方案,但现在开始

在调用resumeOperation之前放置此行:

\GPBMetadata\Google\Cloud\Speech\V1\CloudSpeech::initOnce

我认为这是SDK中的一个bug,但是考虑到他们的文档说客户端库是Alpha的,这是有道理的

一个更长的解释,因为它花了我这么长时间,我知道如果我再次遇到这个问题,我会在未来找到我的答案:

SpeechGapicClient::longRunningRecognize方法上方的DocBlocks显示了使用$operation->pollUntilComplete阻止轮询的替代方法

//启动操作,保留操作名称,稍后继续 $operationResponse=$speechClient->LongRunningRecognite$config,$audio; $operationName=$operationResponse->getName; // ... 做其他工作 $newOperationResponse=$speechClient->resumeOperation$operationName,‘LongRunningRecognite’; 一会儿$新建操作响应->isDone{ //…做其他工作 $newOperationResponse->重新加载; } 如果$newOperationResponse->OperationSucceed{ $result=$newOperationResponse->getResult; //doSomethingWith$result }否则{ $error=$newOperationResponse->getError; //handleError$错误 } 如果对LongRunningRecognite方法返回的同一个操作调用resumeOperation,一切都会很好。如果你试图在一个单独的请求中恢复,就像你和我一样,我们会得到上面提到的错误

区别在于,LongRunningRecognite方法创建了一个请求LongRunningRecognitizerRequest,该请求将被执行,而resumeOperation非常简单,不需要组合请求参数就可以发送到Google

这里的区别是,LongRunningRecognitizeRequest的构造函数调用\GPBMetadata\Google\Cloud\Speech\V1\CloudSpeech::initOnce;设置所需的语音描述符


我希望这有帮助

我花了很长时间才想出这么简单的解决办法,但现在就来吧

在调用resumeOperation之前放置此行:

\GPBMetadata\Google\Cloud\Speech\V1\CloudSpeech::initOnce

我认为这是SDK中的一个bug,但是考虑到他们的文档说客户端库是Alpha的,这是有道理的

一个更长的解释,因为它花了我这么长时间,我知道如果我再次遇到这个问题,我会在未来找到我的答案:

SpeechGapicClient::longRunningRecognize方法上方的DocBlocks显示了使用$operation->pollUntilComplete阻止轮询的替代方法

//启动操作,保留操作名称,稍后继续 $operationResponse=$speechClient->LongRunningRecognite$config,$audio; $operationName=$operationResponse->getName; // ... 做其他工作 $newOperationResponse=$speechClient->resumeOperation$operationName,‘LongRunningRecognite’; 一会儿$新建操作响应->isDone{ //…做其他工作 $newOperationResponse->重新加载; } 如果$newOperationResponse->OperationSucceed{ $result=$newOperationResponse->getResult; //doSomethingWith$result }否则{ $error=$newOperationResponse->getError; //handleError$错误 } 如果对LongRunningRecognite方法返回的同一个操作调用resumeOperation,一切都会很好。如果你试图在一个单独的请求中恢复,就像你和我一样,我们会得到上面提到的错误

区别在于,LongRunningRecognite方法创建了一个请求LongRunningRecognitizerRequest,该请求将被执行,而resumeOperation非常简单,不需要组合请求参数就可以发送到Google

这里的区别是,LongRunningRecognitizeRequest的构造函数调用\GPBMetadata\Google\Cloud\Speech\V1\CloudSpeech::initOnce;设置所需的语音描述符


我希望这有帮助

我遇到了一个非常类似的问题,试图获取有关操作getOperation的信息:

Google\Protobuf\Internal\GPBDecodeException 分析过程中出错:类google.cloud.speech.v1p1beta1.LongRunningRecognitizeMetadata尚未添加到描述符池

由于@stevenwadejr已经正确应答,因此可以在调用之前调用initOnce来解决此问题

<?php
use Google\Cloud\Speech\V1p1beta1\SpeechClient;
use GPBMetadata\Google\Cloud\Speech\V1P1Beta1\CloudSpeech;

$client = new SpeechClient();

// This line is required. It adds LongRunningRecognizeMetadata and others to the pool of recognized classes
CloudSpeech::initOnce();

// Now, I can get the operation without raising an exception
$operation = $client->getOperationsClient()->getOperation('1234567890123456789');
您可以检查file\vendor\google\protobuf\src\google\
Protobuf\Internal\AnyBase.php函数解包。如果没有initOnce命令,pool变量在$proto->proto_to_类数组中没有完全限定的名称google.cloud.speech.v1p1beta1.LongRunningRecognizeMetadata。

我遇到了一个非常类似的问题,试图获取有关操作getOperation的信息:

Google\Protobuf\Internal\GPBDecodeException 分析过程中出错:类google.cloud.speech.v1p1beta1.LongRunningRecognitizeMetadata尚未添加到描述符池

由于@stevenwadejr已经正确应答,因此可以在调用之前调用initOnce来解决此问题

<?php
use Google\Cloud\Speech\V1p1beta1\SpeechClient;
use GPBMetadata\Google\Cloud\Speech\V1P1Beta1\CloudSpeech;

$client = new SpeechClient();

// This line is required. It adds LongRunningRecognizeMetadata and others to the pool of recognized classes
CloudSpeech::initOnce();

// Now, I can get the operation without raising an exception
$operation = $client->getOperationsClient()->getOperation('1234567890123456789');

您可以检查file\vendor\google\protobuf\src\google\protobuf\Internal\AnyBase.php函数unpack。如果没有initOnce命令,pool变量在$proto->proto_to_类数组中没有完全限定的名称google.cloud.speech.v1p1beta1.LongRunningRecognizeMetadata。

谢谢,这几乎解决了问题。只需确保使用LongRunningRecognite作为resume操作方法的参数,而不是LongRunningRecognite第一个字母应该是大写的,否则响应是protobuf编码的。谢谢,这几乎解决了问题。只需确保使用LongRunningRecognite作为resume操作方法的参数,而不是LongRunningRecognite第一个字母应该是大写的,否则响应是protobuf编码的。