cURL PHP + Google Speech

0

I'm trying to work out an algorithm in php to get a certain .flac file, and through google speech it returns the text generated through it.

The following is the code below:

$filename="good-morning-google";
$file_to_upload = array('myfile'=>'@'.$filename.'.flac');
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://www.google.com/speech-api/v2/recognize?output=json&lang=pt-BR&key=MINHAKEY");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: audio/x-flac; rate=44100"));
curl_setopt($ch, CURLOPT_POSTFIELDS, $file_to_upload);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$result=curl_exec ($ch);
var_dump($result);

I do not know what's going on wrong that the return of var $ result is equal to false.

    
asked by anonymous 01.11.2015 / 06:13

0 answers