From 81aa414d2e511f8dd2a9765535eeb23b6fca06fa Mon Sep 17 00:00:00 2001 From: Gigi Date: Mon, 20 Oct 2025 22:03:05 +0200 Subject: [PATCH] fix(tts): apply speed changes immediately during playback --- src/hooks/useTextToSpeech.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/hooks/useTextToSpeech.ts b/src/hooks/useTextToSpeech.ts index 02434175..e5a29cf8 100644 --- a/src/hooks/useTextToSpeech.ts +++ b/src/hooks/useTextToSpeech.ts @@ -105,6 +105,12 @@ export function useTextToSpeech(options: UseTTSOptions = {}): UseTTS { } }, [supported, synth]) + // Update rate in real-time if utterance is playing + useEffect(() => { + if (!supported || !utteranceRef.current || !synth!.speaking) return + utteranceRef.current.rate = rate + }, [rate, supported, synth]) + // stop TTS when unmounting useEffect(() => stop, [stop])