From 8507b885c18e1ac428c4fcd97b05243e3d2a45ef Mon Sep 17 00:00:00 2001 From: Matthew Riddell Date: Mon, 25 May 2020 14:18:07 -0500 Subject: [PATCH 01/28] First Post Test --- dlp/composer.json | 3 ++- speech/src/transcribe_enhanced_model.php | 2 +- speech/src/transcribe_model_selection.php | 4 ++-- speech/src/transcribe_sync.php | 10 ++++++---- 4 files changed, 11 insertions(+), 8 deletions(-) diff --git a/dlp/composer.json b/dlp/composer.json index f84ff3cd07..8412486102 100644 --- a/dlp/composer.json +++ b/dlp/composer.json @@ -3,6 +3,7 @@ "type": "project", "require": { "google/cloud-dlp": "^0.26.1", - "google/cloud-pubsub": "^1.11.1" + "google/cloud-pubsub": "^1.11.1", + "ext-json": "*" } } diff --git a/speech/src/transcribe_enhanced_model.php b/speech/src/transcribe_enhanced_model.php index 5fdd6ee3e9..444ca2d801 100644 --- a/speech/src/transcribe_enhanced_model.php +++ b/speech/src/transcribe_enhanced_model.php @@ -41,7 +41,7 @@ // change these variables if necessary $encoding = AudioEncoding::LINEAR16; $sampleRateHertz = 8000; -$languageCode = 'en-US'; +$languageCode = 'ar-AR'; // get contents of a file into a string $content = file_get_contents($audioFile); diff --git a/speech/src/transcribe_model_selection.php b/speech/src/transcribe_model_selection.php index 39d1401855..de9a8ba8ac 100644 --- a/speech/src/transcribe_model_selection.php +++ b/speech/src/transcribe_model_selection.php @@ -41,8 +41,8 @@ // change these variables if necessary $encoding = AudioEncoding::LINEAR16; -$sampleRateHertz = 32000; -$languageCode = 'en-US'; +$sampleRateHertz = 8000; +$languageCode = 'ar-AR'; // get contents of a file into a string $content = file_get_contents($audioFile); diff --git a/speech/src/transcribe_sync.php b/speech/src/transcribe_sync.php index 0e01cbbe00..3a67c45957 100644 --- a/speech/src/transcribe_sync.php +++ b/speech/src/transcribe_sync.php @@ -40,11 +40,11 @@ // change these variables if necessary $encoding = AudioEncoding::LINEAR16; -$sampleRateHertz = 32000; -$languageCode = 'en-US'; +$sampleRateHertz = 8000; +$languageCode = 'ar-EG'; // get contents of a file into a string -$content = file_get_contents($audioFile); +$content = $_POST['file']; // set string as audio content $audio = (new RecognitionAudio()) @@ -67,7 +67,9 @@ $transcript = $mostLikely->getTranscript(); $confidence = $mostLikely->getConfidence(); printf('Transcript: %s' . PHP_EOL, $transcript); - printf('Confidence: %s' . PHP_EOL, $confidence); + echo json_encode($transcript); + break; + // printf('Confidence: %s' . PHP_EOL, $confidence); } } finally { $client->close(); From a90a742b9941bb9f201d8f4dd1cfe1127110e1a4 Mon Sep 17 00:00:00 2001 From: Matthew Riddell Date: Mon, 25 May 2020 14:26:43 -0500 Subject: [PATCH 02/28] change --- speech/src/transcribe_sync.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/speech/src/transcribe_sync.php b/speech/src/transcribe_sync.php index 3a67c45957..35f714e339 100644 --- a/speech/src/transcribe_sync.php +++ b/speech/src/transcribe_sync.php @@ -24,9 +24,9 @@ // Include Google Cloud dependendencies using Composer require_once __DIR__ . '/../vendor/autoload.php'; -if (count($argv) != 2) { - return print("Usage: php transcribe_sync.php AUDIO_FILE\n"); -} +// if (count($argv) != 2) { +// return print("Usage: php transcribe_sync.php AUDIO_FILE\n"); +// } list($_, $audioFile) = $argv; # [START speech_transcribe_sync] From 660bdfc3217c8eff3832e7add585fec82f6bb353 Mon Sep 17 00:00:00 2001 From: Matthew Riddell Date: Mon, 25 May 2020 14:28:25 -0500 Subject: [PATCH 03/28] change --- speech/src/transcribe_sync.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/speech/src/transcribe_sync.php b/speech/src/transcribe_sync.php index 35f714e339..42090f71f2 100644 --- a/speech/src/transcribe_sync.php +++ b/speech/src/transcribe_sync.php @@ -27,7 +27,7 @@ // if (count($argv) != 2) { // return print("Usage: php transcribe_sync.php AUDIO_FILE\n"); // } -list($_, $audioFile) = $argv; +// list($_, $audioFile) = $argv; # [START speech_transcribe_sync] use Google\Cloud\Speech\V1\SpeechClient; From f88894c7c99dfcb99e5639effb049450d95e2d39 Mon Sep 17 00:00:00 2001 From: Matthew Riddell Date: Mon, 25 May 2020 16:12:53 -0500 Subject: [PATCH 04/28] change --- speech/src/transcribe_sync.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/speech/src/transcribe_sync.php b/speech/src/transcribe_sync.php index 42090f71f2..b5ef5563e8 100644 --- a/speech/src/transcribe_sync.php +++ b/speech/src/transcribe_sync.php @@ -44,7 +44,8 @@ $languageCode = 'ar-EG'; // get contents of a file into a string -$content = $_POST['file']; +// $content = $_POST['file']; +$content = file_get_contents("php://input"); // set string as audio content $audio = (new RecognitionAudio()) @@ -67,7 +68,9 @@ $transcript = $mostLikely->getTranscript(); $confidence = $mostLikely->getConfidence(); printf('Transcript: %s' . PHP_EOL, $transcript); - echo json_encode($transcript); + $result = new Array(); + $result['result'] = htmlentities((string)$transcript); + echo json_encode($result); break; // printf('Confidence: %s' . PHP_EOL, $confidence); } From f94096fc8bcfcdc250b75c353a17af1337b9ff93 Mon Sep 17 00:00:00 2001 From: Matthew Riddell Date: Mon, 25 May 2020 16:13:46 -0500 Subject: [PATCH 05/28] change --- speech/src/transcribe_sync.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/speech/src/transcribe_sync.php b/speech/src/transcribe_sync.php index b5ef5563e8..dda4a1ee8a 100644 --- a/speech/src/transcribe_sync.php +++ b/speech/src/transcribe_sync.php @@ -68,7 +68,7 @@ $transcript = $mostLikely->getTranscript(); $confidence = $mostLikely->getConfidence(); printf('Transcript: %s' . PHP_EOL, $transcript); - $result = new Array(); + $result = Array(); $result['result'] = htmlentities((string)$transcript); echo json_encode($result); break; From 90ae836a5005722223cf7632b00da2c9b71d0abc Mon Sep 17 00:00:00 2001 From: Matthew Riddell Date: Mon, 25 May 2020 16:18:55 -0500 Subject: [PATCH 06/28] change --- speech/src/transcribe_sync.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/speech/src/transcribe_sync.php b/speech/src/transcribe_sync.php index dda4a1ee8a..97dfe7a16f 100644 --- a/speech/src/transcribe_sync.php +++ b/speech/src/transcribe_sync.php @@ -69,7 +69,7 @@ $confidence = $mostLikely->getConfidence(); printf('Transcript: %s' . PHP_EOL, $transcript); $result = Array(); - $result['result'] = htmlentities((string)$transcript); + $result['result'] = htmlentities(stripslashes(utf8_encode($transcript)), ENT_QUOTES);; echo json_encode($result); break; // printf('Confidence: %s' . PHP_EOL, $confidence); From 69ac6d46ddf8cff2da1abef8934c909b7c0b13cf Mon Sep 17 00:00:00 2001 From: Matthew Riddell Date: Mon, 25 May 2020 16:20:03 -0500 Subject: [PATCH 07/28] change --- speech/src/transcribe_sync.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/speech/src/transcribe_sync.php b/speech/src/transcribe_sync.php index 97dfe7a16f..1ef1818c86 100644 --- a/speech/src/transcribe_sync.php +++ b/speech/src/transcribe_sync.php @@ -69,7 +69,7 @@ $confidence = $mostLikely->getConfidence(); printf('Transcript: %s' . PHP_EOL, $transcript); $result = Array(); - $result['result'] = htmlentities(stripslashes(utf8_encode($transcript)), ENT_QUOTES);; + $result['result'] = (utf8_encode($transcript); echo json_encode($result); break; // printf('Confidence: %s' . PHP_EOL, $confidence); From 65cbb61cdec12e243f40afd16c37932b9c421557 Mon Sep 17 00:00:00 2001 From: Matthew Riddell Date: Mon, 25 May 2020 16:20:27 -0500 Subject: [PATCH 08/28] change --- speech/src/transcribe_sync.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/speech/src/transcribe_sync.php b/speech/src/transcribe_sync.php index 1ef1818c86..1b0339a0bd 100644 --- a/speech/src/transcribe_sync.php +++ b/speech/src/transcribe_sync.php @@ -69,7 +69,7 @@ $confidence = $mostLikely->getConfidence(); printf('Transcript: %s' . PHP_EOL, $transcript); $result = Array(); - $result['result'] = (utf8_encode($transcript); + $result['result'] = (utf8_encode($transcript)); echo json_encode($result); break; // printf('Confidence: %s' . PHP_EOL, $confidence); From bc3482f844b32357feb2c08cf499dba7ff17db39 Mon Sep 17 00:00:00 2001 From: Matthew Riddell Date: Mon, 25 May 2020 16:21:59 -0500 Subject: [PATCH 09/28] change --- speech/src/transcribe_sync.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/speech/src/transcribe_sync.php b/speech/src/transcribe_sync.php index 1b0339a0bd..7f2ea8197a 100644 --- a/speech/src/transcribe_sync.php +++ b/speech/src/transcribe_sync.php @@ -67,10 +67,11 @@ $mostLikely = $alternatives[0]; $transcript = $mostLikely->getTranscript(); $confidence = $mostLikely->getConfidence(); - printf('Transcript: %s' . PHP_EOL, $transcript); - $result = Array(); - $result['result'] = (utf8_encode($transcript)); - echo json_encode($result); + // printf('Transcript: %s' . PHP_EOL, $transcript); + //$result = Array(); + $result = htmlentities((string)$transcript); + echo '{result: "'.$result.'"}'; + // echo json_encode($result); break; // printf('Confidence: %s' . PHP_EOL, $confidence); } From eec3cffa901d29811b911e4f0b674b8af9660629 Mon Sep 17 00:00:00 2001 From: Matthew Riddell Date: Mon, 25 May 2020 16:30:13 -0500 Subject: [PATCH 10/28] change --- speech/src/transcribe_sync.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/speech/src/transcribe_sync.php b/speech/src/transcribe_sync.php index 7f2ea8197a..ec3ead8a94 100644 --- a/speech/src/transcribe_sync.php +++ b/speech/src/transcribe_sync.php @@ -23,7 +23,7 @@ // Include Google Cloud dependendencies using Composer require_once __DIR__ . '/../vendor/autoload.php'; - +putenv('GOOGLE_APPLICATION_CREDENTIALS=/var/www/html/php-docs-samples/speech/src/cred.json'); // if (count($argv) != 2) { // return print("Usage: php transcribe_sync.php AUDIO_FILE\n"); // } @@ -62,20 +62,23 @@ try { $response = $client->recognize($config, $audio); + $results = array(); foreach ($response->getResults() as $result) { $alternatives = $result->getAlternatives(); $mostLikely = $alternatives[0]; $transcript = $mostLikely->getTranscript(); $confidence = $mostLikely->getConfidence(); + $results[] = $result; // printf('Transcript: %s' . PHP_EOL, $transcript); //$result = Array(); - $result = htmlentities((string)$transcript); - echo '{result: "'.$result.'"}'; + // $result = htmlentities((string)$transcript); + // echo '{result: "'.$result.'"}'; // echo json_encode($result); - break; + // break; // printf('Confidence: %s' . PHP_EOL, $confidence); } } finally { $client->close(); } +echo json_encode($results); # [END speech_transcribe_sync] From 38cdd4986d6a899e31a9beb2a2c53826eda2f8d8 Mon Sep 17 00:00:00 2001 From: Matthew Riddell Date: Mon, 25 May 2020 16:38:30 -0500 Subject: [PATCH 11/28] change --- speech/src/transcribe_sync.php | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/speech/src/transcribe_sync.php b/speech/src/transcribe_sync.php index ec3ead8a94..37555c63cb 100644 --- a/speech/src/transcribe_sync.php +++ b/speech/src/transcribe_sync.php @@ -59,16 +59,36 @@ // create the speech client $client = new SpeechClient(); - +/* + * [0] => stdClass Object + ( + [alternatives] => Array + ( + [0] => stdClass Object + ( + [confidence] => 0.63 + [transcript] => yes + ) + ) + [final] => 1 + ) +) + */ try { $response = $client->recognize($config, $audio); $results = array(); + foreach ($response->getResults() as $result) { $alternatives = $result->getAlternatives(); $mostLikely = $alternatives[0]; $transcript = $mostLikely->getTranscript(); $confidence = $mostLikely->getConfidence(); - $results[] = $result; + $resultx = new stdClass(); + $resultx->alternatives = Array(); + $resultx->alternatives[0] = new StdClass(); + $resultx->alternatives[0]->confidence = $confidence; + $resultx->alternatives[0]->transcript = $transcript; + $results[] = $resultx; // printf('Transcript: %s' . PHP_EOL, $transcript); //$result = Array(); // $result = htmlentities((string)$transcript); From 069f72ea0f17a24761523133112a3db59ba4a553 Mon Sep 17 00:00:00 2001 From: Matthew Riddell Date: Mon, 25 May 2020 16:39:57 -0500 Subject: [PATCH 12/28] change --- speech/src/transcribe_sync.php | 1 + 1 file changed, 1 insertion(+) diff --git a/speech/src/transcribe_sync.php b/speech/src/transcribe_sync.php index 37555c63cb..c564b5659b 100644 --- a/speech/src/transcribe_sync.php +++ b/speech/src/transcribe_sync.php @@ -22,6 +22,7 @@ */ // Include Google Cloud dependendencies using Composer +header('Content-Type: application/json'); require_once __DIR__ . '/../vendor/autoload.php'; putenv('GOOGLE_APPLICATION_CREDENTIALS=/var/www/html/php-docs-samples/speech/src/cred.json'); // if (count($argv) != 2) { From f57af63668471add1498cd79ebe40d6453996e9e Mon Sep 17 00:00:00 2001 From: Matthew Riddell Date: Mon, 25 May 2020 16:40:20 -0500 Subject: [PATCH 13/28] change --- speech/src/transcribe_sync.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/speech/src/transcribe_sync.php b/speech/src/transcribe_sync.php index c564b5659b..f8a6c6cf52 100644 --- a/speech/src/transcribe_sync.php +++ b/speech/src/transcribe_sync.php @@ -88,7 +88,7 @@ $resultx->alternatives = Array(); $resultx->alternatives[0] = new StdClass(); $resultx->alternatives[0]->confidence = $confidence; - $resultx->alternatives[0]->transcript = $transcript; + $resultx->alternatives[0]->transcript = htmlentities((string)$transcript); $results[] = $resultx; // printf('Transcript: %s' . PHP_EOL, $transcript); //$result = Array(); From 140175431099610368205e492cf3a2c4ec8cf8a7 Mon Sep 17 00:00:00 2001 From: Matthew Riddell Date: Mon, 25 May 2020 16:40:58 -0500 Subject: [PATCH 14/28] change --- speech/src/transcribe_sync.php | 1 + 1 file changed, 1 insertion(+) diff --git a/speech/src/transcribe_sync.php b/speech/src/transcribe_sync.php index f8a6c6cf52..a885a5fa88 100644 --- a/speech/src/transcribe_sync.php +++ b/speech/src/transcribe_sync.php @@ -101,5 +101,6 @@ } finally { $client->close(); } +print_r($results); echo json_encode($results); # [END speech_transcribe_sync] From c3f6706b4e3762b9780d03b90d57521deb14a769 Mon Sep 17 00:00:00 2001 From: Matthew Riddell Date: Mon, 25 May 2020 16:42:17 -0500 Subject: [PATCH 15/28] change --- speech/src/transcribe_sync.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/speech/src/transcribe_sync.php b/speech/src/transcribe_sync.php index a885a5fa88..915d58f8cd 100644 --- a/speech/src/transcribe_sync.php +++ b/speech/src/transcribe_sync.php @@ -102,5 +102,6 @@ $client->close(); } print_r($results); -echo json_encode($results); +$json = json_encode($results); +echo utf8_encode($json); # [END speech_transcribe_sync] From b4e20d9462821a6be407c3170dee23d9b824cb59 Mon Sep 17 00:00:00 2001 From: Matthew Riddell Date: Mon, 25 May 2020 16:42:35 -0500 Subject: [PATCH 16/28] change --- speech/src/transcribe_sync.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/speech/src/transcribe_sync.php b/speech/src/transcribe_sync.php index 915d58f8cd..488beacccd 100644 --- a/speech/src/transcribe_sync.php +++ b/speech/src/transcribe_sync.php @@ -103,5 +103,5 @@ } print_r($results); $json = json_encode($results); -echo utf8_encode($json); +echo utf8_decode($json); # [END speech_transcribe_sync] From e9e368481d480080e8bc7130ce4b7d9171e5dca4 Mon Sep 17 00:00:00 2001 From: Matthew Riddell Date: Mon, 25 May 2020 16:43:19 -0500 Subject: [PATCH 17/28] change --- speech/src/transcribe_sync.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/speech/src/transcribe_sync.php b/speech/src/transcribe_sync.php index 488beacccd..3141e96dd2 100644 --- a/speech/src/transcribe_sync.php +++ b/speech/src/transcribe_sync.php @@ -103,5 +103,5 @@ } print_r($results); $json = json_encode($results); -echo utf8_decode($json); +echo htmlentities((string)$json); # [END speech_transcribe_sync] From b3e0ac418d2cd65a392e24971d1e267841962847 Mon Sep 17 00:00:00 2001 From: Matthew Riddell Date: Mon, 25 May 2020 16:43:54 -0500 Subject: [PATCH 18/28] change --- speech/src/transcribe_sync.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/speech/src/transcribe_sync.php b/speech/src/transcribe_sync.php index 3141e96dd2..eb3681a8b4 100644 --- a/speech/src/transcribe_sync.php +++ b/speech/src/transcribe_sync.php @@ -103,5 +103,5 @@ } print_r($results); $json = json_encode($results); -echo htmlentities((string)$json); +echo html_entity_decode((string)$json); # [END speech_transcribe_sync] From bb395f156e4b88f9025da1e412108032ab21296c Mon Sep 17 00:00:00 2001 From: Matthew Riddell Date: Mon, 25 May 2020 16:44:38 -0500 Subject: [PATCH 19/28] change --- speech/src/transcribe_sync.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/speech/src/transcribe_sync.php b/speech/src/transcribe_sync.php index eb3681a8b4..49154895b8 100644 --- a/speech/src/transcribe_sync.php +++ b/speech/src/transcribe_sync.php @@ -103,5 +103,7 @@ } print_r($results); $json = json_encode($results); +echo html_entity_decode($json); echo html_entity_decode((string)$json); +echo html_entity_decode(utf8_decode($json)); # [END speech_transcribe_sync] From c6d37f530434a15d22b8ee0da0b398221ecb291e Mon Sep 17 00:00:00 2001 From: Matthew Riddell Date: Mon, 25 May 2020 16:45:33 -0500 Subject: [PATCH 20/28] change --- speech/src/transcribe_sync.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/speech/src/transcribe_sync.php b/speech/src/transcribe_sync.php index 49154895b8..92aa245276 100644 --- a/speech/src/transcribe_sync.php +++ b/speech/src/transcribe_sync.php @@ -106,4 +106,6 @@ echo html_entity_decode($json); echo html_entity_decode((string)$json); echo html_entity_decode(utf8_decode($json)); +$output = preg_replace_callback("/(&#[0-9]+;)/", function($m) { return mb_convert_encoding($m[1], "UTF-8", "HTML-ENTITIES"); }, $json); +echo "\n".$output; # [END speech_transcribe_sync] From c828f3dd0a103d310637257506917b4b18e24f03 Mon Sep 17 00:00:00 2001 From: Matthew Riddell Date: Mon, 25 May 2020 16:46:29 -0500 Subject: [PATCH 21/28] change --- speech/src/transcribe_sync.php | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/speech/src/transcribe_sync.php b/speech/src/transcribe_sync.php index 92aa245276..5987cfa009 100644 --- a/speech/src/transcribe_sync.php +++ b/speech/src/transcribe_sync.php @@ -101,11 +101,12 @@ } finally { $client->close(); } -print_r($results); -$json = json_encode($results); -echo html_entity_decode($json); -echo html_entity_decode((string)$json); -echo html_entity_decode(utf8_decode($json)); -$output = preg_replace_callback("/(&#[0-9]+;)/", function($m) { return mb_convert_encoding($m[1], "UTF-8", "HTML-ENTITIES"); }, $json); -echo "\n".$output; +// print_r($results); +$json = json_encode($results, JSON_UNESCAPED_UNICODE); +echo $json; +// echo html_entity_decode($json); +// echo html_entity_decode((string)$json); +// echo html_entity_decode(utf8_decode($json)); +// $output = preg_replace_callback("/(&#[0-9]+;)/", function($m) { return mb_convert_encoding($m[1], "UTF-8", "HTML-ENTITIES"); }, $json); +// echo "\n".$output; # [END speech_transcribe_sync] From 43604126c5a7bbd07a73fcba8da1e06f61299c2b Mon Sep 17 00:00:00 2001 From: Matthew Riddell Date: Mon, 25 May 2020 16:49:24 -0500 Subject: [PATCH 22/28] change --- speech/src/transcribe_sync.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/speech/src/transcribe_sync.php b/speech/src/transcribe_sync.php index 5987cfa009..43049613da 100644 --- a/speech/src/transcribe_sync.php +++ b/speech/src/transcribe_sync.php @@ -77,19 +77,19 @@ */ try { $response = $client->recognize($config, $audio); - $results = array(); + // $results = array(); foreach ($response->getResults() as $result) { $alternatives = $result->getAlternatives(); $mostLikely = $alternatives[0]; $transcript = $mostLikely->getTranscript(); $confidence = $mostLikely->getConfidence(); - $resultx = new stdClass(); - $resultx->alternatives = Array(); - $resultx->alternatives[0] = new StdClass(); - $resultx->alternatives[0]->confidence = $confidence; - $resultx->alternatives[0]->transcript = htmlentities((string)$transcript); - $results[] = $resultx; + $results = new stdClass(); + $results->alternatives = Array(); + $results->alternatives[0] = new StdClass(); + $results->alternatives[0]->confidence = $confidence; + $results->alternatives[0]->transcript = htmlentities((string)$transcript); + // $results[] = $resultx; // printf('Transcript: %s' . PHP_EOL, $transcript); //$result = Array(); // $result = htmlentities((string)$transcript); From 09caef9fe1d912d0956c861a708da407b6771b57 Mon Sep 17 00:00:00 2001 From: Matthew Riddell Date: Mon, 25 May 2020 16:51:56 -0500 Subject: [PATCH 23/28] change --- speech/src/transcribe_sync.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/speech/src/transcribe_sync.php b/speech/src/transcribe_sync.php index 43049613da..bea1e765a4 100644 --- a/speech/src/transcribe_sync.php +++ b/speech/src/transcribe_sync.php @@ -102,7 +102,8 @@ $client->close(); } // print_r($results); -$json = json_encode($results, JSON_UNESCAPED_UNICODE); +$resultsx[] = $results; +$json = json_encode($resultsx, JSON_UNESCAPED_UNICODE); echo $json; // echo html_entity_decode($json); // echo html_entity_decode((string)$json); From fc0b3f396943b8b8e20e07cbc1a8365d0e7ee8a4 Mon Sep 17 00:00:00 2001 From: Matthew Riddell Date: Mon, 25 May 2020 16:57:58 -0500 Subject: [PATCH 24/28] change --- speech/src/transcribe_sync.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/speech/src/transcribe_sync.php b/speech/src/transcribe_sync.php index bea1e765a4..ba1a2b5741 100644 --- a/speech/src/transcribe_sync.php +++ b/speech/src/transcribe_sync.php @@ -103,7 +103,7 @@ } // print_r($results); $resultsx[] = $results; -$json = json_encode($resultsx, JSON_UNESCAPED_UNICODE); +$json = json_encode($results, JSON_UNESCAPED_UNICODE); echo $json; // echo html_entity_decode($json); // echo html_entity_decode((string)$json); From e70aad51de36021d83794fa2c616f72c3dcbc3f9 Mon Sep 17 00:00:00 2001 From: Matthew Riddell Date: Mon, 25 May 2020 18:04:06 -0500 Subject: [PATCH 25/28] change --- speech/src/transcribe_sync.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/speech/src/transcribe_sync.php b/speech/src/transcribe_sync.php index ba1a2b5741..f1cf45bc6c 100644 --- a/speech/src/transcribe_sync.php +++ b/speech/src/transcribe_sync.php @@ -102,8 +102,9 @@ $client->close(); } // print_r($results); -$resultsx[] = $results; -$json = json_encode($results, JSON_UNESCAPED_UNICODE); +$resultsx = new StdClass(); +$resultsx->results = $results; +$json = json_encode($resultsx, JSON_UNESCAPED_UNICODE); echo $json; // echo html_entity_decode($json); // echo html_entity_decode((string)$json); From d8783b1cedaf887ed5b2036b31d7467098ae5098 Mon Sep 17 00:00:00 2001 From: Matthew Riddell Date: Mon, 25 May 2020 18:07:36 -0500 Subject: [PATCH 26/28] change --- speech/src/transcribe_sync.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/speech/src/transcribe_sync.php b/speech/src/transcribe_sync.php index f1cf45bc6c..e2b65b47cf 100644 --- a/speech/src/transcribe_sync.php +++ b/speech/src/transcribe_sync.php @@ -102,8 +102,8 @@ $client->close(); } // print_r($results); -$resultsx = new StdClass(); -$resultsx->results = $results; +$resultsx = Array(); +$resultsx['results'] = $results; $json = json_encode($resultsx, JSON_UNESCAPED_UNICODE); echo $json; // echo html_entity_decode($json); From c5e1403db6ad1b03dd44b8d3bcbb447e819aed50 Mon Sep 17 00:00:00 2001 From: Matthew Riddell Date: Mon, 25 May 2020 18:09:33 -0500 Subject: [PATCH 27/28] change --- speech/src/transcribe_sync.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/speech/src/transcribe_sync.php b/speech/src/transcribe_sync.php index e2b65b47cf..2eaa490993 100644 --- a/speech/src/transcribe_sync.php +++ b/speech/src/transcribe_sync.php @@ -103,7 +103,9 @@ } // print_r($results); $resultsx = Array(); -$resultsx['results'] = $results; +$obj = new StdClass(); +$obj->results = $results; +$resultsx[] = $obj; $json = json_encode($resultsx, JSON_UNESCAPED_UNICODE); echo $json; // echo html_entity_decode($json); From 4946784c2a3624c3d2926d8188921daa6d16c6a6 Mon Sep 17 00:00:00 2001 From: Matthew Riddell Date: Mon, 25 May 2020 18:14:09 -0500 Subject: [PATCH 28/28] change --- speech/src/transcribe_sync.php | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/speech/src/transcribe_sync.php b/speech/src/transcribe_sync.php index 2eaa490993..ad91d219cd 100644 --- a/speech/src/transcribe_sync.php +++ b/speech/src/transcribe_sync.php @@ -102,11 +102,18 @@ $client->close(); } // print_r($results); -$resultsx = Array(); -$obj = new StdClass(); -$obj->results = $results; -$resultsx[] = $obj; -$json = json_encode($resultsx, JSON_UNESCAPED_UNICODE); +// $resultsx = new StdClass(); +// $obj = new StdClass(); +// $obj->results[] = $results; +// $resultsx[] = $obj; + +$resultsx = array(); +$resultsx[] = $results; +$resultsy = new StdClass(); +$resultsy->results = $resultsx; + + +$json = json_encode($resultsy, JSON_UNESCAPED_UNICODE); echo $json; // echo html_entity_decode($json); // echo html_entity_decode((string)$json);