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