Skip to content

Voice-to-text dictation app with local (Nvidia Parakeet/Whisper) and cloud models (BYOK). Privacy-first and available cross-platform.

fix(media): resume playback when recording stops, not after transcription (#1030)

Alcahest Malus Dienheim6632918b1bc1
diff --git a/src/helpers/audioManager.js b/src/helpers/audioManager.js
index 0198e8999..c1038d078 100644
--- a/src/helpers/audioManager.js
+++ b/src/helpers/audioManager.js
@@ -3139,7 +3139,7 @@ registerProcessor("pcm-streaming-processor", PCMStreamingProcessor);
"streaming"
);
} else {
- // Silence: still fire callback so media playback resumes.
+ // Silence: still fire callback to dismiss the preview and show the no-audio toast.
this.onTranscriptionComplete?.({ success: true, text: "" });
}
diff --git a/src/hooks/useAudioRecording.js b/src/hooks/useAudioRecording.js
index bec80f94c..dd0bcae0c 100644
--- a/src/hooks/useAudioRecording.js
+++ b/src/hooks/useAudioRecording.js
@@ -18,6 +18,7 @@ export const useAudioRecording = (toast, options = {}) => {
const audioManagerRef = useRef(null);
const startLockRef = useRef(false);
const stopLockRef = useRef(false);
+ const wasRecordingRef = useRef(false);
const { onToggle } = options;
const performStartRecording = useCallback(async ({ voiceAgentRequested = false } = {}) => {
@@ -90,7 +91,14 @@ export const useAudioRecording = (toast, options = {}) => {
audioManagerRef.current.setCallbacks({
onStateChange: ({ isRecording, isProcessing, isStreaming }) => {
- if (!isRecording) window.electronAPI?.unregisterCancelHotkey?.();
+ if (!isRecording) {
+ window.electronAPI?.unregisterCancelHotkey?.();
+ // Resume media the instant recording ends, not after transcription.
+ if (wasRecordingRef.current && getSettings().pauseMediaOnDictation) {
+ window.electronAPI?.resumeMediaPlayback?.();
+ }
+ }
+ wasRecordingRef.current = isRecording;
setIsRecording(isRecording);
setIsProcessing(isProcessing);
setIsStreaming(isStreaming ?? false);
@@ -118,10 +126,6 @@ export const useAudioRecording = (toast, options = {}) => {
setPartialTranscript(text);
},
onTranscriptionComplete: async (result) => {
- if (getSettings().pauseMediaOnDictation) {
- window.electronAPI?.resumeMediaPlayback?.();
- }
-
if (result.success) {
const transcribedText = result.text?.trim();