来自 Google 的 Cloud Speech-to-Text gRPC API 的错误是什么意思?

What does this error from Google's Cloud Speech-to-Text gRPC API mean?

几个月前,一切正常。我们使用 Speech-to-text 服务的 gRPC。我们发出一个音频文件,关闭语音客户端,稍后继续操作:

$speechClient->resumeOperation($this->operation, 'LongRunningRecognize');

^ 正是文档中的这行代码产生了这个错误:

Error occurred during parsing: Class google.cloud.speech.v1p1beta1.LongRunningRecognizeMetadata hasn't been added to descriptor pool

^ "descriptor pool" 告诉我这是 gRPC 和协议缓冲区特有的。

来自composer.json:

"google/apiclient": "2.2.2",
"google/cloud": "0.72.0",
"google/protobuf": "3.6.0.1",

感谢您的报告。我很乐意帮助您走上正轨。

我使用以下示例对此进行了测试,但无法重现您在此处报告的问题:

文件:composer.json

{
    "require": {
        "google/apiclient": "2.2.2",
        "google/cloud": "0.72.0",
        "google/protobuf": "3.6.0.1"
    }
}

文件:test.php

require 'vendor/autoload.php';

use Google\Cloud\Speech\V1p1beta1\RecognitionAudio;
use Google\Cloud\Speech\V1p1beta1\RecognitionConfig_AudioEncoding;
use Google\Cloud\Speech\V1p1beta1\RecognitionConfig;
use Google\Cloud\Speech\V1p1beta1\SpeechClient;

$client = new SpeechClient();
$config = (new RecognitionConfig)
    ->setLanguageCode('en-US')
    ->setSampleRateHertz(44100)
    ->setEncoding(RecognitionConfig_AudioEncoding::FLAC);
$audio = (new RecognitionAudio)
    ->setUri('gs://gapic-toolkit/hello.flac');

$operation = $client->longRunningRecognize($config, $audio);

$metadata = $client->resumeOperation(
    $operation->getName(),
    'LongRunningRecognize'
)->getMetadata();

echo $metadata->getProgressPercent() . PHP_EOL;

这里的一个关键区别可能是目标系统上安装的 gRPC/protobuf 扩展的版本。我正在使用 v3.8.0 的 protobuf 和 v1.21.3 的 gRPC。你能分享你的吗? (请注意 protobuf 扩展与您通过 composer 安装的 "google/protobuf" 包不同)。

如果您能与我分享更广泛的代码片段,那也可能有所帮助。

谢谢! 戴夫