Fix xtts separator

This commit is contained in:
Cohee
2023-11-22 17:47:58 +02:00
parent 56b63c0e02
commit f802fe1797
2 changed files with 37 additions and 33 deletions

View File

@ -502,6 +502,10 @@ async function processTtsQueue() {
const partJoiner = (ttsProvider?.separator || ' ... '); const partJoiner = (ttsProvider?.separator || ' ... ');
text = matches ? matches.join(partJoiner) : text; text = matches ? matches.join(partJoiner) : text;
} }
// Collapse newlines and spaces into single space
text = text.replace(/\s+/g, ' ');
console.log(`TTS: ${text}`) console.log(`TTS: ${text}`)
const char = currentTtsJob.name const char = currentTtsJob.name

View File

@ -11,7 +11,7 @@ class XTTSTtsProvider {
settings settings
ready = false ready = false
voices = [] voices = []
separator = ' .. ' separator = '. '
languageLabels = { languageLabels = {
"Arabic": "ar", "Arabic": "ar",
@ -46,7 +46,7 @@ class XTTSTtsProvider {
for (let language in this.languageLabels) { for (let language in this.languageLabels) {
if(this.languageLabels[language] == this.settings?.language){ if (this.languageLabels[language] == this.settings?.language) {
html += `<option value="${this.languageLabels[language]}" selected="selected">${language}</option>`; html += `<option value="${this.languageLabels[language]}" selected="selected">${language}</option>`;
continue continue
} }
@ -86,8 +86,8 @@ class XTTSTtsProvider {
// Only accept keys defined in defaultSettings // Only accept keys defined in defaultSettings
this.settings = this.defaultSettings this.settings = this.defaultSettings
for (const key in settings){ for (const key in settings) {
if (key in this.settings){ if (key in this.settings) {
this.settings[key] = settings[key] this.settings[key] = settings[key]
} else { } else {
throw `Invalid setting passed to TTS Provider: ${key}` throw `Invalid setting passed to TTS Provider: ${key}`
@ -106,9 +106,9 @@ class XTTSTtsProvider {
}, 2000); }, 2000);
$('#xtts_tts_endpoint').val(this.settings.provider_endpoint) $('#xtts_tts_endpoint').val(this.settings.provider_endpoint)
$('#xtts_tts_endpoint').on("input", () => {this.onSettingsChange()}) $('#xtts_tts_endpoint').on("input", () => { this.onSettingsChange() })
$('#xtts_api_language').val(this.settings.language) $('#xtts_api_language').val(this.settings.language)
$('#xtts_api_language').on("change", () => {this.onSettingsChange()}) $('#xtts_api_language').on("change", () => { this.onSettingsChange() })
await this.checkReady() await this.checkReady()
@ -116,7 +116,7 @@ class XTTSTtsProvider {
} }
// Perform a simple readiness check by trying to fetch voiceIds // Perform a simple readiness check by trying to fetch voiceIds
async checkReady(){ async checkReady() {
const response = await this.fetchTtsVoiceObjects() const response = await this.fetchTtsVoiceObjects()
} }
@ -142,7 +142,7 @@ class XTTSTtsProvider {
return match return match
} }
async generateTts(text, voiceId){ async generateTts(text, voiceId) {
const response = await this.fetchTtsGeneration(text, voiceId) const response = await this.fetchTtsGeneration(text, voiceId)
return response return response
} }