Coqui TTS UI, added a button to remove choosen character from the voice map. Fixed the request spam to extras when there is no local coqui model or no rvc model in extras folder.

This commit is contained in:
Tony Ribeiro
2023-08-17 01:16:57 +02:00
parent 6dce566cb9
commit a07637aa43
2 changed files with 35 additions and 12 deletions

View File

@ -14,6 +14,7 @@ const UPDATE_INTERVAL = 1000
let charactersList = [] // Updated with module worker let charactersList = [] // Updated with module worker
let rvcModelsList = [] // Initialized only once let rvcModelsList = [] // Initialized only once
let rvcModelsReceived = false;
function updateVoiceMapText(){ function updateVoiceMapText(){
let voiceMapText = "" let voiceMapText = ""
@ -340,7 +341,7 @@ async function rvcVoiceConversion(response, character) {
async function moduleWorker() { async function moduleWorker() {
updateCharactersList(); updateCharactersList();
if (modules.includes('rvc') && rvcModelsList.length == 0) { if (modules.includes('rvc') && !rvcModelsReceived) {
let result = await get_models_list(); let result = await get_models_list();
result = await result.json(); result = await result.json();
rvcModelsList = result["models_list"] rvcModelsList = result["models_list"]
@ -356,6 +357,7 @@ async function moduleWorker() {
$("#rvc_model_select").append(new Option(modelName,modelName)); $("#rvc_model_select").append(new Option(modelName,modelName));
} }
rvcModelsReceived = true
console.debug(DEBUG_PREFIX,"Updated model list to:", rvcModelsList); console.debug(DEBUG_PREFIX,"Updated model list to:", rvcModelsList);
} }
} }

View File

@ -9,13 +9,14 @@ import { doExtrasFetch, extension_settings, getApiUrl, getContext, modules, Modu
export { CoquiTtsProvider } export { CoquiTtsProvider }
const DEBUG_PREFIX = "<Coqui TTS module> " const DEBUG_PREFIX = "<Coqui TTS module> ";
const UPDATE_INTERVAL = 1000 const UPDATE_INTERVAL = 1000;
let inApiCall = false let inApiCall = false;
let charactersList = [] // Updated with module worker let charactersList = []; // Updated with module worker
let coquiApiModels = {} // Initialized only once let coquiApiModels = {}; // Initialized only once
let coquiLocalModels = [] // Initialized only once let coquiLocalModels = []; // Initialized only once
let coquiLocalModelsReceived = false;
/* /*
coquiApiModels format [language][dataset][name]:coqui-api-model-id, example: coquiApiModels format [language][dataset][name]:coqui-api-model-id, example:
{ {
@ -98,6 +99,9 @@ class CoquiTtsProvider {
<select id="coqui_character_select"> <select id="coqui_character_select">
<!-- Populated by JS --> <!-- Populated by JS -->
</select> </select>
<input id="coqui_remove_char_mapping" class="menu_button" type="button" value="Remove from Voice Map" />
<label for="coqui_model_origin">Models:</label> <label for="coqui_model_origin">Models:</label>
<select id="coqui_model_origin">gpu_mode <select id="coqui_model_origin">gpu_mode
<option value="none">Select Origin</option> <option value="none">Select Origin</option>
@ -163,9 +167,12 @@ class CoquiTtsProvider {
$("#coqui_api_model_install_status").hide(); $("#coqui_api_model_install_status").hide();
$("#coqui_api_model_install_button").hide(); $("#coqui_api_model_install_button").hide();
$("#coqui_model_origin").on("change",this.onModelOriginChange); let that = this
$("#coqui_api_language").on("change",this.onModelLanguageChange); $("#coqui_model_origin").on("change",function(){that.onModelOriginChange()});
$("#coqui_api_model_name").on("change",this.onModelNameChange); $("#coqui_api_language").on("change",function(){that.onModelLanguageChange()});
$("#coqui_api_model_name").on("change",function(){that.onModelNameChange()});
$("#coqui_remove_char_mapping").on("click", function(){that.onRemoveClick()});
// Load characters list // Load characters list
$('#coqui_character_select') $('#coqui_character_select')
@ -321,11 +328,23 @@ class CoquiTtsProvider {
return output; return output;
} }
async onRemoveClick() {
const character = $("#coqui_character_select").val();
if (character === "none") {
toastr.error(`Character not selected, please select one.`, DEBUG_PREFIX+" voice mapping character", { timeOut: 10000, extendedTimeOut: 20000, preventDuplicates: true });
return;
}
// Todo erase from voicemap
delete(this.settings.voiceMapDict[character]);
this.updateVoiceMap(); // TODO
}
async onModelOriginChange() { async onModelOriginChange() {
throwIfModuleMissing() throwIfModuleMissing()
resetModelSettings(); resetModelSettings();
const model_origin = $('#coqui_model_origin').val(); const model_origin = $('#coqui_model_origin').val();
console.debug(model_origin);
if (model_origin == "none") { if (model_origin == "none") {
$("#coqui_local_model_div").hide(); $("#coqui_local_model_div").hide();
@ -662,7 +681,7 @@ async function moduleWorker() {
return return
// Initialized local model once // Initialized local model once
if (coquiLocalModels.length == 0){ if (!coquiLocalModelsReceived){
let result = await CoquiTtsProvider.getLocalModelList(); let result = await CoquiTtsProvider.getLocalModelList();
result = await result.json(); result = await result.json();
@ -678,6 +697,8 @@ async function moduleWorker() {
for(const model_dataset of coquiLocalModels) for(const model_dataset of coquiLocalModels)
$("#coqui_local_model_name").append(new Option(model_dataset,model_dataset)); $("#coqui_local_model_name").append(new Option(model_dataset,model_dataset));
coquiLocalModelsReceived = true;
} }
} }