如何使用curl调用HPE Haven的语音识别API?我只得到一个json响应,其中包含一个称为jobID的东西。语音识别结果在哪里?
发布于 2016-09-11 06:10:06
可以使用两个curl命令调用HPE Haven的语音识别API。第一个curl发布音频/视频文件,并返回一个包含jobID的json对象。第二个curl命令可以通过引用jobID来检索语音识别结果。提取jobID并将其传递给第二个命令可能比较棘手。下面是一个Windows批处理文件,它执行整个过程,最终显示识别的文本。此过程使用https://stedolan.github.io/jq/上提供的jq程序来操作json响应。
set ApiKey="<your HPE Haven Speech Recognition key>"
set file="<some audio/video filename>"
curl -sS -X POST --form "file=@%file%" --form "apikey=%ApiKey%" -k https://api.havenondemand.com/1/api/async/recognizespeech/v1 > curljobidout.txt
jq -r ".jobID" curljobidout.txt > JobID.txt
set /p JobID= < JobID.txt
curl -sS https://api.havenondemand.com/1/job/result/%JobID%?apikey=%ApiKey% > curlresultout.txt
jq -r ".actions[0].result.document[0].content" < curlresultout.txthttps://stackoverflow.com/questions/39431039
复制相似问题