From ce124047b044c1aae39363fe8aabe93f97f5d87c Mon Sep 17 00:00:00 2001 From: Bhup-GitHUB Date: Sat, 21 Feb 2026 16:11:34 +0530 Subject: [PATCH] fix:Wire resample 16khz into AudioRecorder stop recording --- .../third_party/mofa-input/src/asr/audio.rs | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/mofa-macos-ime/third_party/mofa-input/src/asr/audio.rs b/mofa-macos-ime/third_party/mofa-input/src/asr/audio.rs index a85749b..6445b30 100644 --- a/mofa-macos-ime/third_party/mofa-input/src/asr/audio.rs +++ b/mofa-macos-ime/third_party/mofa-input/src/asr/audio.rs @@ -7,6 +7,7 @@ pub struct AudioRecorder { samples: Arc>>, stream: Option>, is_recording: Arc>, + sample_rate: u32, } impl AudioRecorder { @@ -15,6 +16,7 @@ impl AudioRecorder { samples: Arc::new(Mutex::new(Vec::new())), stream: None, is_recording: Arc::new(Mutex::new(false)), + sample_rate: 16000, } } @@ -63,12 +65,7 @@ impl AudioRecorder { stream.play()?; self.stream = Some(Box::new(stream)); - - // Resample to 16kHz if needed - if sample_rate != 16000 { - // Store original sample rate for later resampling - // For now, we'll resample after stopping - } + self.sample_rate = sample_rate; Ok(()) } @@ -79,7 +76,7 @@ impl AudioRecorder { self.stream = None; let samples = self.samples.lock().unwrap().clone(); - // TODO: Resample to 16kHz if needed + let samples = resample_to_16khz(&samples, self.sample_rate); Ok(samples) }