fix(tts): apply rate changes whether utterance is speaking or paused

This commit is contained in:
Gigi
2025-10-20 22:10:18 +02:00
parent e2de6f2d91
commit 463ac8f44c

View File

@@ -116,11 +116,12 @@ export function useTextToSpeech(options: UseTTSOptions = {}): UseTTS {
}
}, [supported, synth])
// Update rate in real-time if utterance is playing
// Update rate in real-time if utterance is playing or paused
useEffect(() => {
if (!supported || !utteranceRef.current || !synth!.speaking) return
if (!supported || !utteranceRef.current) return
// Update rate whether speaking or paused
utteranceRef.current.rate = rate
}, [rate, supported, synth])
}, [rate, supported])
// stop TTS when unmounting
useEffect(() => stop, [stop])