Prevent error when the google_url is incorrect
This commit is contained in:
parent
cea06a548e
commit
88a4dbf3e6
|
|
@ -164,27 +164,31 @@ if (!function_exists('transcribe')) {
|
||||||
//ob_end_clean();
|
//ob_end_clean();
|
||||||
|
|
||||||
//run the command
|
//run the command
|
||||||
|
if (!empty($command)) {
|
||||||
$http_response = shell_exec($command);
|
$http_response = shell_exec($command);
|
||||||
|
}
|
||||||
|
|
||||||
//validate the json
|
//validate the json
|
||||||
|
if (!empty($http_response)) {
|
||||||
$ob = json_decode($http_response);
|
$ob = json_decode($http_response);
|
||||||
if($ob === null) {
|
if($ob === null) {
|
||||||
echo "invalid json\n";
|
echo "invalid json\n";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$message = '';
|
|
||||||
$json = json_decode($http_response, true);
|
$json = json_decode($http_response, true);
|
||||||
//echo "json; ".$json."\n";
|
//echo "json; ".$json."\n";
|
||||||
|
$message = '';
|
||||||
foreach($json['results'] as $row) {
|
foreach($json['results'] as $row) {
|
||||||
$message .= $row['alternatives'][0]['transcript'];
|
$message .= $row['alternatives'][0]['transcript'];
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//build the response
|
//build the response
|
||||||
$array['provider'] = $transcribe_provider;
|
$array['provider'] = $transcribe_provider;
|
||||||
$array['language'] = $transcribe_language;
|
$array['language'] = $transcribe_language;
|
||||||
$array['command'] = $command;
|
$array['command'] = $command ?? '';
|
||||||
$array['message'] = $message;
|
$array['message'] = $message ?? '';
|
||||||
//print_r($array);
|
//print_r($array);
|
||||||
|
|
||||||
return $array;
|
return $array;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue