I am trying to send a Curl request to Wit.ai
speech.
I am recording a .wav
file on the frontend with recorder.js
.
I specified mono channel, since wit.ai
only supports mono.
I know that php7 doesn't support @ for CURLOPT_POSTFIELDS, so I downgraded my php to 5.6 just to keep it simple.
I used Postman to generate the Curl request.
I also saw this Post which his similar to my issue but I am using a file: How to stream speech to wit.ai speech end point
Note: What I think, I am still lacking wav file parameters, but I am not sure how to get them. I tried properties but there wasn't much info.
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.wit.ai/speech?v=20170307",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_SAFE_UPLOAD => false,
CURLOPT_POSTFIELDS =>"@uploads/audio1585176568858.wav",
CURLOPT_HTTPHEADER => array(
"Authorization: Bearer $token",
"Content-Type: audio/wav"
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response
The response I get back is this : { "_text": "", "entities": {} }
.
I also used a python script with https://pypi.org/project/SpeechRecognition/ lib with same audio .wav
file and it worked.