From 6484b7075d6b8b85ba9c6d0c61e85578c6cacfb4 Mon Sep 17 00:00:00 2001 From: Beingpax Date: Sat, 10 May 2025 09:33:34 +0545 Subject: [PATCH] skip recordings under 1sec --- VoiceInk/Whisper/WhisperState.swift | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/VoiceInk/Whisper/WhisperState.swift b/VoiceInk/Whisper/WhisperState.swift index 14bd2d5..169cc2b 100644 --- a/VoiceInk/Whisper/WhisperState.swift +++ b/VoiceInk/Whisper/WhisperState.swift @@ -288,6 +288,15 @@ class WhisperState: NSObject, ObservableObject, AVAudioRecorderDelegate { let actualDuration = CMTimeGetSeconds(audioAsset.duration) logger.notice("📊 Audio file duration: \(actualDuration) seconds") + // Check if audio is too short (less than 1 second) + if actualDuration < 1.0 { + logger.notice("⚠️ Audio recording too short (< 1s), skipping transcription") + try? FileManager.default.removeItem(at: url) + await dismissMiniRecorder() + await cleanupModelResources() + return + } + await whisperContext.setPrompt(whisperPrompt.transcriptionPrompt) if shouldCancelRecording { return } await whisperContext.fullTranscribe(samples: data) @@ -438,4 +447,4 @@ private class TaskDelegate: NSObject, URLSessionTaskDelegate { extension Notification.Name { static let toggleMiniRecorder = Notification.Name("toggleMiniRecorder") -} +} \ No newline at end of file