I have the following code:
$transcribe1 = exec('"C:\path\to\gcloud\gcloud.cmd" ml speech recognize "audio-file.flac" --language-code="en-GB"', $transcribe2);
echo '<pre>'; print_r($transcribe1); echo '</pre>';
echo '<pre>'; print_r($transcribe2); echo '</pre>';
$transcribeArray = json_decode($transcribe1, true);
echo '<pre>'; print_r($transcribeArray); echo '</pre>';
The result is:
Array
(
[0] => {
[1] => "results": [
[2] => {
[3] => "alternatives": [
[4] => {
[5] => "confidence": 0.880379,
[6] => "transcript": "the text returned from google cloud"
[7] => }
[8] => ]
[9] => }
[10] => ]
[11] => }
)
The first two print_rs return empty.
All I'm trying to do is get the json returned from gCloud into an array so I can reference it properly in the rest of the code. In other words, an array that looks like this:
[results] => Array(
[alternatives] => Array(
[confidence] => "0.880379",
[transcript] => "the text returned from google cloud"
);
);
What am I missing?