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 = {
|
export const event_types = {
|
||||||
EXTRAS_CONNECTED: 'extras_connected',
|
EXTRAS_CONNECTED: 'extras_connected',
|
||||||
|
MESSAGE_SWIPED: 'message_swiped',
|
||||||
|
MESSAGE_SENT: 'message_sent',
|
||||||
|
MESSAGE_RECEIVED: 'message_received',
|
||||||
}
|
}
|
||||||
|
|
||||||
export const eventSource = new EventEmitter();
|
export const eventSource = new EventEmitter();
|
||||||
@ -2391,6 +2394,7 @@ async function Generate(type, { automatic_trigger, force_name2, resolve, reject,
|
|||||||
|
|
||||||
if (type !== 'quiet') {
|
if (type !== 'quiet') {
|
||||||
playMessageSound();
|
playMessageSound();
|
||||||
|
eventSource.emit(event_types.MESSAGE_RECEIVED, (chat.length - 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -2527,6 +2531,7 @@ function sendMessageAsUser(textareaText, messageBias) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
addOneMessage(chat[chat.length - 1]);
|
addOneMessage(chat[chat.length - 1]);
|
||||||
|
eventSource.emit(event_types.MESSAGE_SENT, (chat.length - 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
function getMaxContextSize() {
|
function getMaxContextSize() {
|
||||||
@ -4836,6 +4841,7 @@ function swipe_left() { // when we swipe left..but no generation.
|
|||||||
queue: false,
|
queue: false,
|
||||||
complete: function () {
|
complete: function () {
|
||||||
saveChatConditional();
|
saveChatConditional();
|
||||||
|
eventSource.emit(event_types.MESSAGE_SWIPED, (chat.length - 1));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -4997,6 +5003,7 @@ const swipe_right = () => {
|
|||||||
saveChatConditional();
|
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('.', ',')
|
str = str.replaceAll('.', ',')
|
||||||
str = str.replaceAll('\n', ', ')
|
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.replace(/\s+/g, ' '); // Collapse multiple whitespaces into one
|
||||||
str = str.trim();
|
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 { extension_settings, getContext } from '../../extensions.js'
|
||||||
import { getStringHash } from '../../utils.js'
|
import { getStringHash } from '../../utils.js'
|
||||||
import { ElevenLabsTtsProvider } from './elevenlabs.js'
|
import { ElevenLabsTtsProvider } from './elevenlabs.js'
|
||||||
@ -644,4 +644,5 @@ $(document).ready(function () {
|
|||||||
loadTtsProvider(extension_settings.tts.currentProvider) // No dependencies
|
loadTtsProvider(extension_settings.tts.currentProvider) // No dependencies
|
||||||
addAudioControl() // Depends on Extension Controls
|
addAudioControl() // Depends on Extension Controls
|
||||||
setInterval(moduleWorkerWrapper, UPDATE_INTERVAL) // Init depends on all the things
|
setInterval(moduleWorkerWrapper, UPDATE_INTERVAL) // Init depends on all the things
|
||||||
|
eventSource.on(event_types.MESSAGE_SWIPED, resetTtsPlayback);
|
||||||
})
|
})
|
||||||
|
Reference in New Issue
Block a user