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 || ' ... ');
text = matches ? matches.join(partJoiner) : text;
}
// Collapse newlines and spaces into single space
text = text.replace(/\s+/g, ' ');
console.log(`TTS: ${text}`)
const char = currentTtsJob.name

View File

@ -11,25 +11,25 @@ class XTTSTtsProvider {
settings
ready = false
voices = []
separator = ' .. '
separator = '. '
languageLabels = {
"Arabic": "ar",
"Brazilian Portuguese": "pt",
"Chinese": "zh-cn",
"Czech": "cs",
"Dutch": "nl",
"English": "en",
"French": "fr",
"German": "de",
"Italian": "it",
"Polish": "pl",
"Russian": "ru",
"Spanish": "es",
"Turkish": "tr",
"Japanese": "ja",
"Korean": "ko",
"Hungarian": "hu"
"Arabic": "ar",
"Brazilian Portuguese": "pt",
"Chinese": "zh-cn",
"Czech": "cs",
"Dutch": "nl",
"English": "en",
"French": "fr",
"German": "de",
"Italian": "it",
"Polish": "pl",
"Russian": "ru",
"Spanish": "es",
"Turkish": "tr",
"Japanese": "ja",
"Korean": "ko",
"Hungarian": "hu"
}
defaultSettings = {
@ -38,15 +38,15 @@ class XTTSTtsProvider {
voiceMap: {}
}
get settingsHtml() {
get settingsHtml() {
let html = `
<label for="xtts_api_language">Language</label>
<select id="xtts_api_language">`;
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>`;
continue
}
@ -54,20 +54,20 @@ class XTTSTtsProvider {
html += `<option value="${this.languageLabels[language]}">${language}</option>`;
}
html += `
</select>
<label for="xtts_tts_endpoint">Provider Endpoint:</label>
<input id="xtts_tts_endpoint" type="text" class="text_pole" maxlength="250" value="${this.defaultSettings.provider_endpoint}"/>
`;
html += `
<span>
<span>Use <a target="_blank" href="https://github.com/daswer123/xtts-api-server">XTTSv2 TTS Server</a>.</span>
`;
return html;
}
onSettingsChange() {
@ -86,8 +86,8 @@ class XTTSTtsProvider {
// Only accept keys defined in defaultSettings
this.settings = this.defaultSettings
for (const key in settings){
if (key in this.settings){
for (const key in settings) {
if (key in this.settings) {
this.settings[key] = settings[key]
} else {
throw `Invalid setting passed to TTS Provider: ${key}`
@ -106,9 +106,9 @@ class XTTSTtsProvider {
}, 2000);
$('#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').on("change", () => {this.onSettingsChange()})
$('#xtts_api_language').on("change", () => { this.onSettingsChange() })
await this.checkReady()
@ -116,8 +116,8 @@ class XTTSTtsProvider {
}
// Perform a simple readiness check by trying to fetch voiceIds
async checkReady(){
async checkReady() {
const response = await this.fetchTtsVoiceObjects()
}
@ -142,7 +142,7 @@ class XTTSTtsProvider {
return match
}
async generateTts(text, voiceId){
async generateTts(text, voiceId) {
const response = await this.fetchTtsGeneration(text, voiceId)
return response
}
@ -167,7 +167,7 @@ class XTTSTtsProvider {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Cache-Control': 'no-cache' // Added this line to disable caching of file so new files are always played - Rolyat 7/7/23
'Cache-Control': 'no-cache' // Added this line to disable caching of file so new files are always played - Rolyat 7/7/23
},
body: JSON.stringify({
"text": inputText,