Prevent error when the google_url is incorrect

This commit is contained in:
FusionPBX 2023-12-11 11:43:55 -07:00 committed by GitHub
parent cea06a548e
commit 88a4dbf3e6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 18 additions and 14 deletions

View File

@ -164,27 +164,31 @@ if (!function_exists('transcribe')) {
//ob_end_clean();
//run the command
$http_response = shell_exec($command);
//validate the json
$ob = json_decode($http_response);
if($ob === null) {
echo "invalid json\n";
return false;
if (!empty($command)) {
$http_response = shell_exec($command);
}
$message = '';
$json = json_decode($http_response, true);
//echo "json; ".$json."\n";
foreach($json['results'] as $row) {
$message .= $row['alternatives'][0]['transcript'];
//validate the json
if (!empty($http_response)) {
$ob = json_decode($http_response);
if($ob === null) {
echo "invalid json\n";
return false;
}
$json = json_decode($http_response, true);
//echo "json; ".$json."\n";
$message = '';
foreach($json['results'] as $row) {
$message .= $row['alternatives'][0]['transcript'];
}
}
//build the response
$array['provider'] = $transcribe_provider;
$array['language'] = $transcribe_language;
$array['command'] = $command;
$array['message'] = $message;
$array['command'] = $command ?? '';
$array['message'] = $message ?? '';
//print_r($array);
return $array;