mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Add provider-specific TTS processing: XTTS - replace ellipsis, Novel - remove tildes.
This commit is contained in:
@ -503,6 +503,10 @@ async function processTtsQueue() {
|
||||
text = matches ? matches.join(partJoiner) : text;
|
||||
}
|
||||
|
||||
if (typeof ttsProvider?.processText === 'function') {
|
||||
text = await ttsProvider.processText(text);
|
||||
}
|
||||
|
||||
// Collapse newlines and spaces into single space
|
||||
text = text.replace(/\s+/g, ' ');
|
||||
|
||||
|
@ -19,6 +19,17 @@ class NovelTtsProvider {
|
||||
customVoices: []
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform any text processing before passing to TTS engine.
|
||||
* @param {string} text Input text
|
||||
* @returns {string} Processed text
|
||||
*/
|
||||
processText(text) {
|
||||
// Novel reads tilde as a word. Replace with full stop
|
||||
text = text.replace(/~/g, '.');
|
||||
return text;
|
||||
}
|
||||
|
||||
get settingsHtml() {
|
||||
let html = `
|
||||
<div class="novel_tts_hints">
|
||||
|
@ -15,6 +15,7 @@ Exported for use in extension index.js, and added to providers list in index.js
|
||||
#### Optional
|
||||
1. previewTtsVoice()
|
||||
2. separator field
|
||||
3. processText(text)
|
||||
|
||||
# Requirement Descriptions
|
||||
### generateTts(text, voiceId)
|
||||
@ -69,3 +70,7 @@ Function to handle playing previews of voice samples if no direct preview_url is
|
||||
Optional.
|
||||
Used when narrate quoted text is enabled.
|
||||
Defines the string of characters used to introduce separation between between the groups of extracted quoted text sent to the provider. The provider will use this to introduce pauses by default using `...`
|
||||
|
||||
### processText(text)
|
||||
Optional.
|
||||
A function applied to the input text before passing it to the TTS generator. Can be async.
|
||||
|
@ -13,6 +13,19 @@ class XTTSTtsProvider {
|
||||
voices = []
|
||||
separator = '. '
|
||||
|
||||
/**
|
||||
* Perform any text processing before passing to TTS engine.
|
||||
* @param {string} text Input text
|
||||
* @returns {string} Processed text
|
||||
*/
|
||||
processText(text) {
|
||||
// Replace fancy ellipsis with "..."
|
||||
text = text.replace(/…/g, '...')
|
||||
// Replace multiple "." with single "."
|
||||
text = text.replace(/\.+/g, '.')
|
||||
return text
|
||||
}
|
||||
|
||||
languageLabels = {
|
||||
"Arabic": "ar",
|
||||
"Brazilian Portuguese": "pt",
|
||||
|
Reference in New Issue
Block a user