From df577bc08c307bcc25699f13a3f69e1f1141f1db Mon Sep 17 00:00:00 2001 From: Henry Heino <46334387+personalizedrefrigerator@users.noreply.github.com> Date: Mon, 9 Dec 2024 07:56:25 -0800 Subject: [PATCH] Android: Close voice typing session when closing the editor (#11466) --- .../app-mobile/components/voiceTyping/VoiceTypingDialog.tsx | 4 ++++ packages/app-mobile/services/voiceTyping/whisper.ts | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/app-mobile/components/voiceTyping/VoiceTypingDialog.tsx b/packages/app-mobile/components/voiceTyping/VoiceTypingDialog.tsx index e002da97c..06d229405 100644 --- a/packages/app-mobile/components/voiceTyping/VoiceTypingDialog.tsx +++ b/packages/app-mobile/components/voiceTyping/VoiceTypingDialog.tsx @@ -78,6 +78,10 @@ const useWhisper = ({ locale, provider, onSetPreview, onText }: UseVoiceTypingPr setMustDownloadModel(!(await builder.isDownloaded())); }, [builder]); + useEffect(() => () => { + void voiceTypingRef.current?.stop(); + }, []); + return [error, mustDownloadModel, voiceTyping]; }; diff --git a/packages/app-mobile/services/voiceTyping/whisper.ts b/packages/app-mobile/services/voiceTyping/whisper.ts index 0db6ae1e5..df81b6631 100644 --- a/packages/app-mobile/services/voiceTyping/whisper.ts +++ b/packages/app-mobile/services/voiceTyping/whisper.ts @@ -75,7 +75,7 @@ class Whisper implements VoiceTypingSession { public async stop() { if (this.sessionId === null) { - logger.warn('Session already closed.'); + logger.debug('Session already closed.'); return; }