0

I followed https://cloud.google.com/speech/docs/getting-started and successfully ran

curl -s -k -H "Content-Type: application/json" \
-H "Authorization: Bearer access_token" \
https://speech.googleapis.com/v1beta1/speech:syncrecognize \
-d @sync-request.json

to get the expected output. However, now I am trying to do essentially the same thing but for a local flac file so I'm instead running:

curl -s -k -H "Content-Type: audio/x-flac" -H "Authorization: Bearer [my access key]" 
https://speech.googleapis.com/v1beta1/speech:syncrecognize --data-binary @file.flac

and I'm getting a response of

{
  "error": {
    "code": 400,
    "message": "Invalid JSON payload received. Unexpected     token.\nfLaC\u0000\u0000\u0000\"\u0004\n^",
    "status": "INVALID_ARGUMENT"
  }
}

The google api developer console shows the message coming in but give me no further information to help me. I've also tried

wget --post-file file.flac --header="Content-Type: audio/x-flac; rate=16000" -O - "https://speech.googleapis.com/v1beta1/speech:syncrecognize?key=[my api key]"

and am also getting a 400 Bad Request error.

私が目指していることを成功させた人はいますか?私が見つけることができるすべての例は、最小限のcurlまたはwgetリクエストとは対照的に、アップロードされたファイルのAPIを使用するか、いくつかのライブラリを使用するためのものです.

4

1 に答える 1