Add / Update talking lips animations

This commit is contained in:
joe 2023-08-11 14:43:53 +09:00
parent 5feebd4897
commit 9fec82bd31
2 changed files with 6 additions and 2 deletions

View File

@ -9,6 +9,7 @@ import { SystemTtsProvider } from './system.js'
import { NovelTtsProvider } from './novel.js' import { NovelTtsProvider } from './novel.js'
import { power_user } from '../../power-user.js' import { power_user } from '../../power-user.js'
import { rvcVoiceConversion } from "../rvc/index.js" import { rvcVoiceConversion } from "../rvc/index.js"
export { talkingAnimation };
const UPDATE_INTERVAL = 1000 const UPDATE_INTERVAL = 1000
@ -177,6 +178,7 @@ function talkingAnimation(switchValue) {
// Handle the error here or simply ignore it to prevent logging // Handle the error here or simply ignore it to prevent logging
} }
} }
updateUiAudioPlayState()
} }
function resetTtsPlayback() { function resetTtsPlayback() {
@ -305,10 +307,8 @@ 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 {
@ -345,6 +345,7 @@ function completeCurrentAudioJob() {
audioQueueProcessorReady = true audioQueueProcessorReady = true
currentAudioJob = null currentAudioJob = null
lastAudioPosition = 0 lastAudioPosition = 0
talkingAnimation(false) //stop lip animation
// updateUiPlayState(); // updateUiPlayState();
} }

View File

@ -1,5 +1,6 @@
import { isMobile } from "../../RossAscends-mods.js"; import { isMobile } from "../../RossAscends-mods.js";
import { getPreviewString } from "./index.js"; import { getPreviewString } from "./index.js";
import { talkingAnimation } from './index.js';
export { SystemTtsProvider } export { SystemTtsProvider }
@ -69,6 +70,7 @@ var speechUtteranceChunker = function (utt, settings, callback) {
//placing the speak invocation inside a callback fixes ordering and onend issues. //placing the speak invocation inside a callback fixes ordering and onend issues.
setTimeout(function () { setTimeout(function () {
speechSynthesis.speak(newUtt); speechSynthesis.speak(newUtt);
talkingAnimation(true);
}, 0); }, 0);
}; };
@ -221,6 +223,7 @@ class SystemTtsProvider {
//some code to execute when done //some code to execute when done
resolve(silence); resolve(silence);
console.log('System TTS done'); console.log('System TTS done');
talkingAnimation(false);
}); });
}); });
} }