add ready flag

This commit is contained in:
ouoertheo
2023-08-22 08:30:33 -05:00
parent 24b6261f46
commit 56fcf1cbb8
5 changed files with 80 additions and 0 deletions

View File

@ -84,6 +84,7 @@ class CoquiTtsProvider {
//#############################//
settings
ready
defaultSettings = {
voiceMap: "",
@ -147,6 +148,7 @@ class CoquiTtsProvider {
loadSettings(settings) {
// Only accept keys defined in defaultSettings
this.settings = this.defaultSettings
this.ready = false
for (const key in settings) {
if (key in this.settings) {
@ -227,6 +229,21 @@ class CoquiTtsProvider {
});
}
// Perform a simple readiness check by trying to fetch voiceIds
async checkReady(){
try {
if (!modules.includes('coqui-tts')){
this.ready = false
return
}
await this.fetchTtsVoiceIds()
this.ready = true
} catch {
this.ready = false
}
}
updateVoiceMap() {
this.settings.voiceMap = "";
for (let i in this.settings.voiceMapDict) {