Search code examples
phpprotocol-buffersgrpcgoogle-cloud-speech

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


Several months ago, all was working fine. We use the gRPC of the Speech-to-text service. We send off an audio file, close the speechclient, and further continue the operation later on:

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

^ It is this line of code from the docs that produces this error:

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

^ "descriptor pool" tells me this is specific to the gRPC and protocol buffers.

From composer.json:

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

Solution

  • Thanks for the report here. I'd be happy to help get you on the right track.

    I tested this out using the following sample and wasn't able to reproduce the issue you reported here:

    File: composer.json

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

    File: 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;
    
    

    One key difference here could be the versions of the gRPC/protobuf extension which are installed on your target system. I'm using v3.8.0 of protobuf and v1.21.3 of gRPC. Would you be able to share yours? (Please note the protobuf extension is different than the "google/protobuf" package you've got installed through composer).

    If you'd be able to share a more broad code snippet with me, that may help as well.

    Thanks! Dave