skip recordings under 1sec
This commit is contained in:
parent
4a4dbc7b5e
commit
6484b7075d
@ -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")
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user