Ai elevenlabs io engine (#6932)
* allow settings to load domain and user settings * ensure the engine is also enabled before attempting to create a new object * add default values to stop undefined variable warnings * enforce all models to set and return voices and languages * enforce all models to set and return languages * ensure speech_enabled is set by the current session * create elevenlabs implementation of ai speech * Update ai_elevenlabs.php
This commit is contained in:
@@ -494,6 +494,58 @@ $text['header']['zh-cn'] = "上传录音";
|
||||
$text['header']['ja-jp'] = "録音をアップロードする";
|
||||
$text['header']['ko-kr'] = "녹음 업로드";
|
||||
|
||||
$text['label-model']['en-us'] = "Model";
|
||||
$text['label-model']['en-gb'] = "Model";
|
||||
$text['label-model']['ar-eg'] = "";
|
||||
$text['label-model']['de-at'] = "";
|
||||
$text['label-model']['de-ch'] = "";
|
||||
$text['label-model']['de-de'] = "";
|
||||
$text['label-model']['el-gr'] = "";
|
||||
$text['label-model']['es-cl'] = "";
|
||||
$text['label-model']['es-mx'] = "";
|
||||
$text['label-model']['fr-ca'] = "";
|
||||
$text['label-model']['fr-fr'] = "";
|
||||
$text['label-model']['he-il'] = "";
|
||||
$text['label-model']['it-it'] = "";
|
||||
$text['label-model']['nl-nl'] = "";
|
||||
$text['label-model']['pl-pl'] = "";
|
||||
$text['label-model']['pt-br'] = "";
|
||||
$text['label-model']['pt-pt'] = "";
|
||||
$text['label-model']['ro-ro'] = "";
|
||||
$text['label-model']['ru-ru'] = "";
|
||||
$text['label-model']['sv-se'] = "";
|
||||
$text['label-model']['uk-ua'] = "";
|
||||
$text['label-model']['tr-tr'] = "";
|
||||
$text['label-model']['zh-cn'] = "";
|
||||
$text['label-model']['ja-jp'] = "";
|
||||
$text['label-model']['ko-kr'] = "";
|
||||
|
||||
$text['description-model']['en-us'] = "Model the engine will use.";
|
||||
$text['description-model']['en-gb'] = "Model the engine will use.";
|
||||
$text['description-model']['ar-eg'] = "";
|
||||
$text['description-model']['de-at'] = "";
|
||||
$text['description-model']['de-ch'] = "";
|
||||
$text['description-model']['de-de'] = "";
|
||||
$text['description-model']['el-gr'] = "";
|
||||
$text['description-model']['es-cl'] = "";
|
||||
$text['description-model']['es-mx'] = "";
|
||||
$text['description-model']['fr-ca'] = "";
|
||||
$text['description-model']['fr-fr'] = "";
|
||||
$text['description-model']['he-il'] = "";
|
||||
$text['description-model']['it-it'] = "";
|
||||
$text['description-model']['nl-nl'] = "";
|
||||
$text['description-model']['pl-pl'] = "";
|
||||
$text['description-model']['pt-br'] = "";
|
||||
$text['description-model']['pt-pt'] = "";
|
||||
$text['description-model']['ro-ro'] = "";
|
||||
$text['description-model']['ru-ru'] = "";
|
||||
$text['description-model']['sv-se'] = "";
|
||||
$text['description-model']['uk-ua'] = "";
|
||||
$text['description-model']['tr-tr'] = "";
|
||||
$text['description-model']['zh-cn'] = "";
|
||||
$text['description-model']['ja-jp'] = "";
|
||||
$text['description-model']['ko-kr'] = "";
|
||||
|
||||
$text['label-voice']['en-us'] = "Voice";
|
||||
$text['label-voice']['en-gb'] = "Voice";
|
||||
$text['label-voice']['ar-eg'] = "";
|
||||
|
||||
@@ -59,6 +59,7 @@
|
||||
if (($speech_enabled == 'true' && !empty($speech_engine)) || ($transcribe_enabled == 'true' && !empty($transcribe_engine))) {
|
||||
$ai = new ai($settings);
|
||||
$voices = $ai->get_voices();
|
||||
$models = $ai->get_models();
|
||||
$translate_enabled = false;
|
||||
$language_enabled = false;
|
||||
//$translate_enabled = $ai->get_translate_enabled();
|
||||
@@ -77,6 +78,7 @@
|
||||
$recording_filename_original = $_POST["recording_filename_original"];
|
||||
$recording_name = $_POST["recording_name"];
|
||||
$recording_voice = $_POST["recording_voice"];
|
||||
$recording_model = $_POST["recording_model"];
|
||||
$recording_language = $_POST["recording_language"];
|
||||
//$translate = $_POST["translate"];
|
||||
$recording_message = $_POST["recording_message"];
|
||||
@@ -152,6 +154,11 @@
|
||||
$recording_voice = 'alloy';
|
||||
}
|
||||
|
||||
//set the default value
|
||||
if (empty($recording_model)) {
|
||||
$recording_model = $settings->get('ai', 'speech_model', '');
|
||||
}
|
||||
|
||||
//set the recording format
|
||||
if (empty($recording_format)) {
|
||||
$recording_format = 'wav';
|
||||
@@ -183,6 +190,7 @@
|
||||
$ai->audio_path = $recording_path;
|
||||
$ai->audio_filename = $recording_filename;
|
||||
$ai->audio_format = $recording_format;
|
||||
$ai->audio_model = $recording_model ?? '';
|
||||
$ai->audio_voice = $recording_voice;
|
||||
//$ai->audio_language = $recording_language;
|
||||
//$ai->audio_translate = $translate;
|
||||
@@ -299,6 +307,28 @@
|
||||
}
|
||||
|
||||
if ($speech_enabled == 'true' || $transcribe_enabled == 'true') {
|
||||
//models
|
||||
if (!empty($models)) {
|
||||
echo "<tr>\n";
|
||||
echo "<td class='vncell' valign='top' align='left' nowrap>\n";
|
||||
echo " ".$text['label-model']."\n";
|
||||
echo "</td>\n";
|
||||
echo "<td class='vtable' align='left'>\n";
|
||||
echo " <select class='formfld' name='recording_model'>\n";
|
||||
echo " <option value=''></option>\n";
|
||||
foreach($models as $model_id => $model_name) {
|
||||
echo " <option value='".escape($model_id)."' ".(($model_id == $recording_model) ? "selected='selected'" : '').">".escape($model_name)."</option>\n";
|
||||
}
|
||||
echo " </select>\n";
|
||||
}
|
||||
else {
|
||||
echo " <input class='formfld' type='hidden' name='recording_model' maxlength='255' value=''>\n";
|
||||
}
|
||||
echo "<br />\n";
|
||||
echo $text['description-model']."\n";
|
||||
echo "</td>\n";
|
||||
echo "</tr>\n";
|
||||
//voices
|
||||
echo "<tr>\n";
|
||||
echo "<td class='vncell' valign='top' align='left' nowrap>\n";
|
||||
echo " ".$text['label-voice']."\n";
|
||||
@@ -316,8 +346,12 @@
|
||||
if (!empty($voices)) {
|
||||
echo " <select class='formfld' name='recording_voice'>\n";
|
||||
echo " <option value=''></option>\n";
|
||||
foreach($voices as $voice) {
|
||||
echo " <option value='".escape($voice)."' ".(($voice == $recording_voice) ? "selected='selected'" : null).">".escape($voice)."</option>\n";
|
||||
foreach($voices as $key => $voice) {
|
||||
if (gettype($key) === "integer") {
|
||||
echo " <option value='".escape($voice)."' ".(($voice == $recording_voice) ? "selected='selected'" : null).">".escape($voice)."</option>\n";
|
||||
} else {
|
||||
echo " <option value='".escape($key)."' ".(($voice == $recording_voice) ? "selected='selected'" : null).">".escape($voice)."</option>\n";
|
||||
}
|
||||
}
|
||||
echo " </select>\n";
|
||||
}
|
||||
|
||||
@@ -384,6 +384,9 @@
|
||||
}
|
||||
}
|
||||
|
||||
//set the default value for speech
|
||||
$speech_enabled = !empty($_SESSION['ai']['speech_enabled']['boolean']) && !empty($_SESSION['ai']['speech_engine']['text']);
|
||||
|
||||
//create token
|
||||
$object = new token;
|
||||
$token = $object->create($_SERVER['PHP_SELF']);
|
||||
@@ -502,7 +505,7 @@
|
||||
foreach ($recordings as $row) {
|
||||
//playback progress bar
|
||||
if (permission_exists('recording_play')) {
|
||||
echo "<tr class='list-row' id='recording_progress_bar_".escape($row['recording_uuid'])."' onclick=\"recording_play('".escape($row['voicemail_greeting_uuid'])."')\" style='display: none;'><td id='playback_progress_bar_background_".escape($row['recording_uuid'])."' class='playback_progress_bar_background' style='padding: 0; border: none;' colspan='".$col_count."'><span class='playback_progress_bar' id='recording_progress_".escape($row['recording_uuid'])."'></span></td><td class='description hide-sm-dn' style='border-bottom: none !important;'></td></tr>\n";
|
||||
echo "<tr class='list-row' id='recording_progress_bar_".escape($row['recording_uuid'])."' onclick=\"recording_play('".escape($row['voicemail_greeting_uuid'] ?? '')."')\" style='display: none;'><td id='playback_progress_bar_background_".escape($row['recording_uuid'])."' class='playback_progress_bar_background' style='padding: 0; border: none;' colspan='".$col_count."'><span class='playback_progress_bar' id='recording_progress_".escape($row['recording_uuid'])."'></span></td><td class='description hide-sm-dn' style='border-bottom: none !important;'></td></tr>\n";
|
||||
echo "<tr class='list-row' style='display: none;'><td></td></tr>\n"; // dummy row to maintain alternating background color
|
||||
}
|
||||
if (permission_exists('recording_edit')) {
|
||||
|
||||
Reference in New Issue
Block a user