如何检索 google 语音 api 异步请求响应?

How to retrieve google speech api asynchronous request response ?

我正在尝试使异步 google-speech-api 请求工作。 根据建议,我使用 play 命令:

play audio2min.flac

使用此处的代码:https://github.com/GoogleCloudPlatform/python-docs-samples/tree/master/speech/api-client。然后我用相应的编码调整请求。

然后我得到错误:

"Audio 'content' cannot be longer than 1 min.
For long audio, use the 'uri' parameter to specify a file."

然后我将我的文件放在 google 存储中并用 "uri": "gs://path/to/my/audio2min.flac"

调整我的请求

但是我得到了错误:

For audio inputs longer than 1 min, please use LINEAR16 encoding.

问题是:当我更改 LINEAR16 而不是 FLAC 的编码时,我得到一个无效的答案。

为确保编码确实是问题所在,我尝试使用同步请求文件中的 30 秒样本。它适用于编码 FLAC 但不适用于编码 LINEAR16。

任何人都可以向我解释我应该怎么做吗?

我终于设法通过更改文件的编码使其工作。

  1. 下载大胆:http://www.audacityteam.org/

  2. 打开文件

  3. 在文件 -> 导出音频 -> 选择:

other uncompressed files

Header : RAW

编码:16-bit PCM

现在应该可以了