AllTalk initial commit

AllTalk TTS initial commit from https://github.com/erew123/alltalk_tts
ST index.js is updated to have "Pass Asterisks to TTS Engine" which allows AllTalk to split text as character/narrator voices. This setting has been left disabled as standard, so wont affect other TTS engines. The setting will save along with other settings on the page (if checked).
This commit is contained in:
erew123
2024-01-13 19:43:38 +00:00
committed by GitHub
parent cd88702e33
commit b78350cc8e
2 changed files with 959 additions and 3 deletions

View File

@ -11,6 +11,7 @@ import { power_user } from '../../power-user.js';
import { registerSlashCommand } from '../../slash-commands.js';
import { OpenAITtsProvider } from './openai.js';
import { XTTSTtsProvider } from './xtts.js';
import { AllTalkTtsProvider } from './alltalk.js';
export { talkingAnimation };
const UPDATE_INTERVAL = 1000;
@ -74,6 +75,7 @@ let ttsProviders = {
Edge: EdgeTtsProvider,
Novel: NovelTtsProvider,
OpenAI: OpenAITtsProvider,
AllTalk: AllTalkTtsProvider,
};
let ttsProvider;
let ttsProviderName;
@ -488,9 +490,11 @@ async function processTtsQueue() {
text = text.replace(/```.*?```/gs, '').trim();
}
text = extension_settings.tts.narrate_dialogues_only
? text.replace(/\*[^*]*?(\*|$)/g, '').trim() // remove asterisks content
: text.replaceAll('*', '').trim(); // remove just the asterisks
if (!extension_settings.tts.pass_asterisks) {
text = extension_settings.tts.narrate_dialogues_only
? text.replace(/\*[^*]*?(\*|$)/g, '').trim() // remove asterisks content
: text.replaceAll('*', '').trim(); // remove just the asterisks
}
if (extension_settings.tts.narrate_quoted_only) {
const special_quotes = /[“”]/g; // Extend this regex to include other special quotes
@ -572,6 +576,7 @@ function loadSettings() {
$('#tts_auto_generation').prop('checked', extension_settings.tts.auto_generation);
$('#tts_narrate_translated_only').prop('checked', extension_settings.tts.narrate_translated_only);
$('#tts_narrate_user').prop('checked', extension_settings.tts.narrate_user);
$('#tts_pass_asterisks').prop('checked', extension_settings.tts.pass_asterisks);
$('body').toggleClass('tts', extension_settings.tts.enabled);
}
@ -627,6 +632,7 @@ function onAutoGenerationClick() {
function onNarrateDialoguesClick() {
extension_settings.tts.narrate_dialogues_only = !!$('#tts_narrate_dialogues').prop('checked');
saveSettingsDebounced();
console.log("setting narrate changed", extension_settings.tts.narrate_dialogues_only)
}
function onNarrateUserClick() {
@ -637,6 +643,7 @@ function onNarrateUserClick() {
function onNarrateQuotedClick() {
extension_settings.tts.narrate_quoted_only = !!$('#tts_narrate_quoted').prop('checked');
saveSettingsDebounced();
console.log("setting narrate quoted changed", extension_settings.tts.narrate_quoted_only)
}
@ -650,6 +657,12 @@ function onSkipCodeblocksClick() {
saveSettingsDebounced();
}
function onPassAsterisksClick() {
extension_settings.tts.pass_asterisks = !!$('#tts_pass_asterisks').prop('checked');
saveSettingsDebounced();
console.log("setting pass asterisks", extension_settings.tts.pass_asterisks)
}
//##############//
// TTS Provider //
//##############//
@ -968,6 +981,10 @@ $(document).ready(function () {
<input type="checkbox" id="tts_skip_codeblocks">
<small>Skip codeblocks</small>
</label>
<label class="checkbox_label" for="tts_pass_asterisks">
<input type="checkbox" id="tts_pass_asterisks">
<small>Pass Asterisks to TTS Engine</small>
</label>
</div>
<div id="tts_voicemap_block">
</div>
@ -989,6 +1006,7 @@ $(document).ready(function () {
$('#tts_narrate_quoted').on('click', onNarrateQuotedClick);
$('#tts_narrate_translated_only').on('click', onNarrateTranslatedOnlyClick);
$('#tts_skip_codeblocks').on('click', onSkipCodeblocksClick);
$('#tts_pass_asterisks').on('click', onPassAsterisksClick);
$('#tts_auto_generation').on('click', onAutoGenerationClick);
$('#tts_narrate_user').on('click', onNarrateUserClick);
$('#tts_voices').on('click', onTtsVoicesClick);