1
votes

I have followed google's tutorial with gcloud tool to set up everything to use the cloud speech API. However when I am trying to send the following request:

gcloud ml speech recognize 'gs://cloud-samples-tests/speech/brooklyn.flac' --language-code='en-US'

I keep getting the following error:

ERROR: (gcloud.ml.speech.recognize) Invalid audio source ['gs://cloud-samples-tests/speech/brooklyn.flac']. The source must either be a local path or a Google Cloud Storage URL (such as gs://bucket/object).

I also tried google's tutorial to use the speech API from command file using curl request... but when I sent the following request I haven't got any response

curl -s -H "Content-Type: application/json"
    -H "Authorization: Bearer "$(gcloud auth print-access-token) 
    https://speech.googleapis.com/v1/speech:recognize 
    -d @sync-request.json 

I don't know what I am doing wrong... Any help would be really appreciated.. Thanks in advance

4
I have try the first tutorial and it worked to me. What I noticed is when I changed the bucket path (adding a "a" in the beginning), it returned same error than yours but it is without quotes (I see [ags://cloud-samples-tests/speech/brooklyn.flac] instead of ['ags://cloud-samples-tests/speech/brooklyn.flac']). Can you try to execute the same command without quotes for bucket path? - enle lin
Don't forget to remove the quotes around en-US 😅 or you will get ERROR: (gcloud.ml.speech.recognize) INVALID_ARGUMENT: Invalid recognition 'config': bad language code. - pkerts

4 Answers

2
votes

The commenter is exactly right, for some reason the quotes to the file argument are the problem. This appears to be true for both local files and Google Cloud Storage hosted file. I had the exact same problem and removing the quotes cures things. It's possible that this is a platform specific issue - I am using gcloud on Windows 10.

1
votes

I had similar issue. Finally figured out that I had to remove the backslash after the audio file name brooklyn.flac

Gcloud Quickstart has it like this:

gcloud ml speech recognize gs://cloud-samples-tests/speech/brooklyn.flac \ --language-code=en-US

I just used the below after removing the backslash:

gcloud ml speech recognize gs://cloud-samples-tests/speech/brooklyn.flac --language-code=en-US
0
votes

For me, on the command line of windows 7, the following finally worked:

gcloud ml speech recognize gs://cloud-samples-tests/speech/brooklyn.flac --language-code="en-US"

0
votes

I had this same issue on Mac OS when referencing a local file. When I deleted the quotes, it worked fine.

This did not work gcloud ml speech recognize-long-running '/Users/interview/STEREO/FOLDER01/ZOOM0001.WAV' --language-code='en-US' --async

Deleting the quotes like below did. Go figure. gcloud ml speech recognize-long-running /Users/interview/STEREO/FOLDER01/ZOOM0001.WAV
--language-code='en-US' --async