From 440cf25935fc2f5cc11ce4db8351b51b9a956e35 Mon Sep 17 00:00:00 2001 From: Quan HL Date: Sat, 27 Jan 2024 09:46:43 +0700 Subject: [PATCH] wip --- .../views/applications/speech-selection.tsx | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/containers/internal/views/applications/speech-selection.tsx b/src/containers/internal/views/applications/speech-selection.tsx index c82e806..1349438 100644 --- a/src/containers/internal/views/applications/speech-selection.tsx +++ b/src/containers/internal/views/applications/speech-selection.tsx @@ -102,6 +102,8 @@ export const SpeechProviderSelection = ({ const currentVendor = useRef(synthVendor); const shouldUpdateTtsVoice = useRef(false); const shouldUpdateSttLanguage = useRef(false); + const ttsEffectTimer = useRef(null); + const sttEffectTimer = useRef(null); const currentServiceProvider = useSelectState("currentServiceProvider"); @@ -121,7 +123,14 @@ export const SpeechProviderSelection = ({ setSynthVoice(""); return; } - configSynthesis(); + // just execute last change + if (ttsEffectTimer.current) { + clearTimeout(ttsEffectTimer.current); + } + + ttsEffectTimer.current = setTimeout(() => { + configSynthesis(); + }, 200); }, [synthVendor, synthLabel, currentServiceProvider]); // Get Recognizer languages and voices @@ -139,7 +148,14 @@ export const SpeechProviderSelection = ({ ) { return; } - configRecognizer(); + // just execute last change + if (sttEffectTimer.current) { + clearTimeout(sttEffectTimer.current); + } + + sttEffectTimer.current = setTimeout(() => { + configRecognizer(); + }, 200); }, [recogVendor, recogLabel, currentServiceProvider]); useEffect(() => {