Fixes a problem when text-to-speech provider uses mp3

- Get the greeting format to support mp3
- Fixes a problem when using elevenlabs
- Code assumed wav format 
- Check class existence before instantiating objects
This commit is contained in:
FusionPBX
2025-12-18 15:57:10 -07:00
committed by GitHub
parent fd36312abd
commit 2cf0bdc2ce

View File

@@ -57,9 +57,10 @@
$language_enabled = false; $language_enabled = false;
//add the speech object and get the voices and languages arrays //add the speech object and get the voices and languages arrays
if ($speech_enabled && !empty($speech_engine)) { if (class_exists('speech') && $speech_enabled && !empty($speech_engine)) {
$speech = new speech($settings); $speech = new speech($settings);
$voices = $speech->get_voices(); $voices = $speech->get_voices();
$greeting_format = $speech->get_format();
//$speech_models = $speech->get_models(); //$speech_models = $speech->get_models();
//$translate_enabled = $speech->get_translate_enabled(); //$translate_enabled = $speech->get_translate_enabled();
//$language_enabled = $speech->get_language_enabled(); //$language_enabled = $speech->get_language_enabled();
@@ -67,7 +68,7 @@
} }
//add the transcribe object and get the languages arrays //add the transcribe object and get the languages arrays
if ($transcribe_enabled && !empty($transcribe_engine)) { if (class_exists('transcribe') && $transcribe_enabled && !empty($transcribe_engine)) {
$transcribe = new transcribe($settings); $transcribe = new transcribe($settings);
//$transcribe_models = $transcribe->get_models(); //$transcribe_models = $transcribe->get_models();
//$translate_enabled = $transcribe->get_translate_enabled(); //$translate_enabled = $transcribe->get_translate_enabled();
@@ -109,15 +110,17 @@ if (!empty($_POST) && empty($_POST["persistformvar"])) {
if (permission_exists('voicemail_greeting_delete')) { if (permission_exists('voicemail_greeting_delete')) {
if (!empty($_POST['action']) && $_POST['action'] == 'delete' && is_uuid($voicemail_greeting_uuid)) { if (!empty($_POST['action']) && $_POST['action'] == 'delete' && is_uuid($voicemail_greeting_uuid)) {
//prepare //prepare
$array[0]['checked'] = 'true'; $array[0]['checked'] = 'true';
$array[0]['uuid'] = $voicemail_greeting_uuid; $array[0]['uuid'] = $voicemail_greeting_uuid;
//delete //delete
$obj = new voicemail_greetings; $obj = new voicemail_greetings;
$obj->voicemail_id = $voicemail_id; $obj->voicemail_id = $voicemail_id;
$obj->delete($array); $obj->delete($array);
//redirect //redirect
header("Location: voicemail_greetings.php?id=".$voicemail_id); header("Location: voicemail_greetings.php?id=".$voicemail_id);
exit; exit;
} }
} }
@@ -237,12 +240,11 @@ if (!empty($_POST) && empty($_POST["persistformvar"])) {
//set message //set message
message::add($text['message-'.($action == 'add' ? 'greeting_created' : 'update')]); message::add($text['message-'.($action == 'add' ? 'greeting_created' : 'update')]);
} }
//redirect //redirect
header("Location: voicemail_greetings.php?id=".$voicemail_id); header("Location: voicemail_greetings.php?id=".$voicemail_id);
exit; exit;
} }
} }
@@ -405,14 +407,13 @@ if (!empty($_POST) && empty($_POST["persistformvar"])) {
echo " ".$text['label-message']."\n"; echo " ".$text['label-message']."\n";
echo "</td>\n"; echo "</td>\n";
echo "<td class='vtable' align='left'>\n"; echo "<td class='vtable' align='left'>\n";
echo " <textarea class='formfld' name='greeting_message' style='width: 300px; height: 150px;'>".escape($greeting_message ?? '')."</textarea>\n"; echo " <textarea class='formfld' name='greeting_message' style='width: 300px; height: 150px;'>".escape_textarea($greeting_message ?? '')."</textarea>\n";
echo "<br />\n"; echo "<br />\n";
echo $text['description-message']."\n"; echo $text['description-message']."\n";
echo "</td>\n"; echo "</td>\n";
echo "</tr>\n"; echo "</tr>\n";
} }
echo "<tr>\n"; echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap>\n"; echo "<td class='vncell' valign='top' align='left' nowrap>\n";
echo " ".$text['label-description']."\n"; echo " ".$text['label-description']."\n";