locationgoogle-speech-api

Google speech v2: 'Expected resource location to be global, but found europe-west4 in resource name.',


I created a Google Cloud Speech v2 recognizer via the front end of the web google cloud console. The Recognizer service is located in europe-west4, because I need the chirp model. The problem comes when i try to get the recognizer via the Node.js client library.

client.getRecognizer({ name: `projects/${project}/locations/europe-west4/recognizers/my-first-chirp` }) The error is:

Google speech v2: 'Expected resource location to be global, but found europe-west4 in resource name.',

When i try to create a different recognizer in europe-west4 i get the same error, but when creating in "global" location there is no problem. The issue is that the model and language I need are not supported in "global".

When I tried to find my recognizer in "global" with .getRecognizer I got an error sayign there isn't such recognizer (as expected, because it is not in global).

I there a way to use google's node library with europe-west4?


Solution

  • When creating the client you need to set the region in the URL:

    For Javascript/Typescript:

    this.client = new v2.SpeechClient({
        apiEndpoint: `europe-west4-speech.googleapis.com`,
    });
    

    For Python

    client_options_var = client_options.ClientOptions(
        api_endpoint="europe-west4-speech.googleapis.com"
    )
        client = SpeechClient(client_options=client_options_var)
    

    Beware the "-speech" part region + "-speech.googleapis.com"