mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-02-01 20:06:59 +01:00
Talking Animation
This commit is contained in:
parent
9f92b19004
commit
0c919bf32d
@ -14,7 +14,7 @@ const UPDATE_INTERVAL = 1000
|
|||||||
|
|
||||||
let voiceMap = {} // {charName:voiceid, charName2:voiceid2}
|
let voiceMap = {} // {charName:voiceid, charName2:voiceid2}
|
||||||
let audioControl
|
let audioControl
|
||||||
|
let storedvalue = false;
|
||||||
let lastCharacterId = null
|
let lastCharacterId = null
|
||||||
let lastGroupId = null
|
let lastGroupId = null
|
||||||
let lastChatId = null
|
let lastChatId = null
|
||||||
@ -164,6 +164,20 @@ async function moduleWorker() {
|
|||||||
ttsJobQueue.push(message)
|
ttsJobQueue.push(message)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function talkingAnimation(switchValue) {
|
||||||
|
const apiKeyValue = document.getElementById("extensions_url").value;
|
||||||
|
const animationType = switchValue ? "start" : "stop";
|
||||||
|
|
||||||
|
if (switchValue !== storedvalue) {
|
||||||
|
try {
|
||||||
|
console.log(animationType + " Talking Animation");
|
||||||
|
fetch(`${apiKeyValue}/api/live2d/${animationType}_talking`);
|
||||||
|
storedvalue = switchValue; // Update the storedvalue to the current switchValue
|
||||||
|
} catch (error) {
|
||||||
|
// Handle the error here or simply ignore it to prevent logging
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function resetTtsPlayback() {
|
function resetTtsPlayback() {
|
||||||
// Stop system TTS utterance
|
// Stop system TTS utterance
|
||||||
@ -291,8 +305,10 @@ function updateUiAudioPlayState() {
|
|||||||
// Give user feedback that TTS is active by setting the stop icon if processing or playing
|
// Give user feedback that TTS is active by setting the stop icon if processing or playing
|
||||||
if (!audioElement.paused || isTtsProcessing()) {
|
if (!audioElement.paused || isTtsProcessing()) {
|
||||||
img = 'fa-solid fa-stop-circle extensionsMenuExtensionButton'
|
img = 'fa-solid fa-stop-circle extensionsMenuExtensionButton'
|
||||||
|
talkingAnimation(true)
|
||||||
} else {
|
} else {
|
||||||
img = 'fa-solid fa-circle-play extensionsMenuExtensionButton'
|
img = 'fa-solid fa-circle-play extensionsMenuExtensionButton'
|
||||||
|
talkingAnimation(false)
|
||||||
}
|
}
|
||||||
$('#tts_media_control').attr('class', img);
|
$('#tts_media_control').attr('class', img);
|
||||||
} else {
|
} else {
|
||||||
@ -354,6 +370,7 @@ async function processAudioJobQueue() {
|
|||||||
audioQueueProcessorReady = false
|
audioQueueProcessorReady = false
|
||||||
currentAudioJob = audioJobQueue.pop()
|
currentAudioJob = audioJobQueue.pop()
|
||||||
playAudioData(currentAudioJob)
|
playAudioData(currentAudioJob)
|
||||||
|
talkingAnimation(true)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error)
|
console.error(error)
|
||||||
audioQueueProcessorReady = true
|
audioQueueProcessorReady = true
|
||||||
|
Loading…
x
Reference in New Issue
Block a user