Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 4 additions & 7 deletions mofa-macos-ime/third_party/mofa-input/src/asr/audio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ pub struct AudioRecorder {
samples: Arc<Mutex<Vec<f32>>>,
stream: Option<Box<dyn StreamTrait>>,
is_recording: Arc<Mutex<bool>>,
sample_rate: u32,
}

impl AudioRecorder {
Expand All @@ -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,
}
}

Expand Down Expand Up @@ -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(())
}
Expand All @@ -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)
}

Expand Down