【问题标题】:google speech api Empty Results JSON谷歌语音 api 空结果 JSON
【发布时间】:2017-02-10 10:14:04
【问题描述】:

我通常使用格式正确的 JSON 请求和 mp3 文件进行 API 调用,并且我希望结果 JSON 数据包含“结果”对象以及具有“成绩单”和“置信度”值的“替代”对象。

我得到的结果是“{}”(一个空的 JSON 对象)。

使用的操作系统是ubuntu15.04。

创建包含以下文本的 JSON 请求文件,并将其保存为 sync-request.json 纯文本文件:

{
  "config": {
    "encoding": "LINEAR16",
    "sampleRate": 16000,
"languageCode": "en-US"
  },
  "audio": {
    "uri": "gs://audiobucketceino/Learn English - Lesson 41- Hi How are you - Pronunciation-[AudioTrimmer.com].mp3"
  }
}

用于演讲的curl:syncrecognize请求是:

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

测试文件附在:

https://drive.google.com/file/d/0B7cqXnHXm78bLWdyYWhpVEdkT0U/view?usp=sharing

【问题讨论】:

标签: curl google-api speech-to-text google-speech-api


【解决方案1】:

google 语音 API 不直接支持 mp3 文件。它只支持the five listed in the documentation。最简单的方法是使用 sox 或类似工具 (sudo apt-get install sox) 将 mp3 文件转换为 wav 文件:

sox lesson41.mp3 lesson41.wav

wav 文件应该与您提供的LINEAR16 编码兼容。您需要确保采样率为 16k 且样本为 16 位。为了安全起见,试试这个:

sox lesson41.mp3 -r 16000 -c 1 -b 16 lesson41.wav

如果您在获取sox 时遇到任何问题,可以使用lots of other tools that should be able to do the conversion too

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-04-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-12-16
    相关资源
    最近更新 更多