Search code examples
javascriptnode.jsgoogle-cloud-speech

Using the node.js google cloud speech to text, how can I get the status of a current job?


I managed to trigger a job with:

        const config = {
            languageCode: 'en-US',
            enableSpeakerDiarization: true,
            audioChannelCount: 2,
            enableSeparateRecognitionPerChannel: true,
            useEnhanced: true,
            profanityFilter: false,
            enableAutomaticPunctuation: true,
        };

        const audio = {
            uri: `gs://${filePath}`
        }

        const requestObj = {
            config: config,
            audio: audio
        }
        return speechClient.longRunningRecognize(requestObj)

I get back an object with a name. I want to use that with https://cloud.google.com/speech-to-text/docs/reference/rest/v1/LongRunningRecognizeMetadata (via the node.js package) to get the current status.

How do I do it?

return speechClient.longrunning.Operation()

Seems not to exist


Solution

  • Looks like you can do it with:

                    return speechClient.operationsClient.getOperation({ name: googleName })
    

    This is not super well documented