mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Stop TTS playback on swipe
This commit is contained in:
@ -414,6 +414,9 @@ const system_messages = {
|
||||
|
||||
export const event_types = {
|
||||
EXTRAS_CONNECTED: 'extras_connected',
|
||||
MESSAGE_SWIPED: 'message_swiped',
|
||||
MESSAGE_SENT: 'message_sent',
|
||||
MESSAGE_RECEIVED: 'message_received',
|
||||
}
|
||||
|
||||
export const eventSource = new EventEmitter();
|
||||
@ -2391,6 +2394,7 @@ async function Generate(type, { automatic_trigger, force_name2, resolve, reject,
|
||||
|
||||
if (type !== 'quiet') {
|
||||
playMessageSound();
|
||||
eventSource.emit(event_types.MESSAGE_RECEIVED, (chat.length - 1));
|
||||
}
|
||||
|
||||
|
||||
@ -2527,6 +2531,7 @@ function sendMessageAsUser(textareaText, messageBias) {
|
||||
}
|
||||
|
||||
addOneMessage(chat[chat.length - 1]);
|
||||
eventSource.emit(event_types.MESSAGE_SENT, (chat.length - 1));
|
||||
}
|
||||
|
||||
function getMaxContextSize() {
|
||||
@ -4836,6 +4841,7 @@ function swipe_left() { // when we swipe left..but no generation.
|
||||
queue: false,
|
||||
complete: function () {
|
||||
saveChatConditional();
|
||||
eventSource.emit(event_types.MESSAGE_SWIPED, (chat.length - 1));
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -4997,6 +5003,7 @@ const swipe_right = () => {
|
||||
saveChatConditional();
|
||||
}
|
||||
}
|
||||
eventSource.emit(event_types.MESSAGE_SWIPED, (chat.length - 1));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -386,7 +386,7 @@ function processReply(str) {
|
||||
str = str.replaceAll('“', '')
|
||||
str = str.replaceAll('.', ',')
|
||||
str = str.replaceAll('\n', ', ')
|
||||
str = str.replace(/[^a-zA-Z0-9,:]+/g, ' ') // Replace everything except alphanumeric characters and commas with spaces
|
||||
str = str.replace(/[^a-zA-Z0-9,:()]+/g, ' ') // Replace everything except alphanumeric characters and commas with spaces
|
||||
str = str.replace(/\s+/g, ' '); // Collapse multiple whitespaces into one
|
||||
str = str.trim();
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { callPopup, cancelTtsPlay, isMultigenEnabled, is_send_press, saveSettingsDebounced } from '../../../script.js'
|
||||
import { callPopup, cancelTtsPlay, eventSource, event_types, isMultigenEnabled, is_send_press, saveSettingsDebounced } from '../../../script.js'
|
||||
import { extension_settings, getContext } from '../../extensions.js'
|
||||
import { getStringHash } from '../../utils.js'
|
||||
import { ElevenLabsTtsProvider } from './elevenlabs.js'
|
||||
@ -167,7 +167,7 @@ function debugTtsPlayback() {
|
||||
{
|
||||
"ttsProviderName": ttsProviderName,
|
||||
"currentMessageNumber": currentMessageNumber,
|
||||
"isWorkerBusy":isWorkerBusy,
|
||||
"isWorkerBusy": isWorkerBusy,
|
||||
"audioPaused": audioPaused,
|
||||
"audioJobQueue": audioJobQueue,
|
||||
"currentAudioJob": currentAudioJob,
|
||||
@ -644,4 +644,5 @@ $(document).ready(function () {
|
||||
loadTtsProvider(extension_settings.tts.currentProvider) // No dependencies
|
||||
addAudioControl() // Depends on Extension Controls
|
||||
setInterval(moduleWorkerWrapper, UPDATE_INTERVAL) // Init depends on all the things
|
||||
eventSource.on(event_types.MESSAGE_SWIPED, resetTtsPlayback);
|
||||
})
|
||||
|
Reference in New Issue
Block a user