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])