From bb0473a56fc3f9919b028174cc31a8856e4bc76d Mon Sep 17 00:00:00 2001 From: yangqian <973860441@qq.com> Date: Sat, 23 Nov 2024 01:53:58 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix:=20the=20isLoading=20propert?= =?UTF-8?q?y=20of=20the=20useSpeechSynthes=20hook=20(#40)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: yang.qian7 --- src/react/useSpeechSynthes/index.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/react/useSpeechSynthes/index.ts b/src/react/useSpeechSynthes/index.ts index b5d2982..5e3630f 100644 --- a/src/react/useSpeechSynthes/index.ts +++ b/src/react/useSpeechSynthes/index.ts @@ -19,6 +19,8 @@ export const useSpeechSynthes = ( if (!SpeechSynthesisUtterance) return; const utterance = new SpeechSynthesisUtterance(text); utterance.voice = voiceList.find((item: any) => item.name === voice) as any; + utterance.onstart = () => setIsLoading(true); + utterance.onend = () => setIsLoading(false); if (pitch) utterance.pitch = pitch * 10; if (rate) utterance.rate = rate * 10; return utterance;