require __DIR__ . '/vendor/autoload.php';
use Google\Cloud\Speech\V1\SpeechClient;
use Google\Cloud\Speech\V1\RecognitionAudio;
use Google\Cloud\Speech\V1\RecognitionConfig;
use Google\Cloud\Speech\V1\RecognitionConfig\AudioEncoding;
$encoding = AudioEncoding::FLAC;
$sampleRateHertz = 44100;
$languageCode = 'es-CL';
$audioFile = __DIR__ . '/radio/test.flac';
$audio = (new RecognitionAudio())
->setUri($audioFile);
$config = (new RecognitionConfig())
->setEncoding($encoding)
->setSampleRateHertz($sampleRateHertz)
->setLanguageCode($languageCode);
putenv('GOOGLE_APPLICATION_CREDENTIALS=/var/www/html/key.json');
$client = new SpeechClient();
$operation = $client->longRunningRecognize($config, $audio);
$operation->pollUntilComplete();
if ($operation->operationSucceeded()) {
$response = $operation->getResult();
foreach ($response->getResults() as $result) {
$alternatives = $result->getAlternatives();
$mostLikely = $alternatives[0];
$transcript = $mostLikely->getTranscript();
$confidence = $mostLikely->getConfidence();
printf('Transcript: %s' . PHP_EOL, $transcript);
printf('Confidence: %s' . PHP_EOL, $confidence);
}
} else {
print_r($operation->getError());
}
$client->close();
?>
Fatal error: Uncaught Google\ApiCore\ApiException: { "message": "Request
contains an invalid argument.", "code": 3, "status": "INVALID_ARGUMENT",
"details": [] } thrown in
/var/www/html/vendor/google/gax/src/ApiException.php on line 139
Эта ошибка неполная, и я не знаю, как ее найти на поддержке облачной платформы Goodle. Пожалуйста, если вы можете мне помочь, я оценил