Skip to content

armgit / Handy

Public Imported from GitHub
0

A free, open source, and extensible speech-to-text application that works completely offline.

drain audio (#838)

CJ Pais3c0fb951852f
diff --git a/src-tauri/src/audio_toolkit/audio/recorder.rs b/src-tauri/src/audio_toolkit/audio/recorder.rs
index c3f23adb..8326e7c1 100644
--- a/src-tauri/src/audio_toolkit/audio/recorder.rs
+++ b/src-tauri/src/audio_toolkit/audio/recorder.rs
@@ -319,8 +319,14 @@ fn run_consumer(
Cmd::Stop(reply_tx) => {
recording = false;
+ // Drain any audio chunks that were captured but not yet consumed
+ while let Ok(remaining) = sample_rx.try_recv() {
+ frame_resampler.push(&remaining, &mut |frame: &[f32]| {
+ handle_frame(frame, true, &vad, &mut processed_samples)
+ });
+ }
+
frame_resampler.finish(&mut |frame: &[f32]| {
- // we still want to process the last few frames
handle_frame(frame, true, &vad, &mut processed_samples)
});