Em đã thu gọn lại phần content (chuyển flac sang base64)
Code đầy đủ: https://pastebin.com/9rzagvUV
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://speech.googleapis.com/v1/speech:recognize?bearer_token=AIzaSyDNr9NKAJ8Tsz6SteemjW2OAj2P3GTHz30&prettyPrint=true&access_token=AIzaSyDNr9NKAJ8Tsz6SteemjW2OAj2P3GTHz30&key=AIzaSyDNr9NKAJ8Tsz6SteemjW2OAj2P3GTHz30 ");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "{\"audio\":{\"content\":\"ZkxhQwA\"},\"config\":{\"encoding\":\"FLAC\",\"sampleRateHertz\":16000,\"languageCode\":\"en-US\"}}");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_ENCODING, 'gzip, deflate');
$headers = array();
$headers[] = "Accept: application/json";
$headers[] = "Content-Type: application/json";
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$result = curl_exec($ch);
if (curl_errno($ch)) {
echo 'Error:' . curl_error($ch);
}
curl_close ($ch);
echo $result;
Sau khi chạy thì báo status 200 nhưng không hiện nội dung?!
Mong anh chị giúp đỡ.