Reputation: 8961
How can I use curl
to invoke HPE Haven's Speech Recognition API? I only get a json response containing something called a jobID
. Where's the speech recognition result?
Upvotes: 0
Views: 126
Reputation: 8961
HPE Haven's Speech Recognition API can be called by using two curl
commands. The first curl
posts the audio/video file and returns a json object containing a jobID
. A second curl
command can retrieve the speech recognition result by referencing the jobID
. Extracting the jobID
and passing it to the second command can be tricky. Below is a Windows batch file that performs the whole process ultimately displaying the recognized text. This procedure uses the jq
program available at https://stedolan.github.io/jq/ to manipulate the json responses.
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.txt
Upvotes: 2