google 演讲 api 空结果 JSON
google speech api Empty Results JSON
我正常地使用格式正确的 JSON 请求和 mp3 文件进行了 API 调用,我期望结果 JSON 数据包含 "results" 对象 "alternatives" 具有 "transcript" 和 "confidence" 值的对象。
相反,我得到的结果是“{}”(一个空的 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"
}
}
用于发出 speech:syncrecognize 请求的 curl 是:
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
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。
我正常地使用格式正确的 JSON 请求和 mp3 文件进行了 API 调用,我期望结果 JSON 数据包含 "results" 对象 "alternatives" 具有 "transcript" 和 "confidence" 值的对象。
相反,我得到的结果是“{}”(一个空的 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"
}
}
用于发出 speech:syncrecognize 请求的 curl 是:
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
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。