B
B
bezvozni2019-03-21 09:01:12
Google
bezvozni, 2019-03-21 09:01:12

How to recognize audio to text by google in php?

I try the demo code from the main page https://cloud.google.com/speech-to-text/ like this:

<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://speech.googleapis.com/v1/speech:recognize?key=myKey');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, '{"audio":{"content":"RTovT1NQYW5lbC9kb21haW5zL3Rlc2R0L3ZpZGVvcy9nZGdkcy5mbGFj"},"config":{"enableAutomaticPunctuation":true,"encoding":"FLAC","sampleRateHertz":16000,"languageCode":"ru-RU","model":"default"}}');
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
$out = curl_exec($ch);
curl_close($ch);

echo $out;
?>

In response I get {}
php code for the post request stupidly copied from the Internet
how to get the decryption text?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question