feat(audio): write_wav_mono_16k helper for persisting the mic voiceprint (FR-SPK)
This commit is contained in:
1 parent
a481f5dcbf
commit
7733e86cfd
1 file changed
+22
@@ -946,6 +946,28 @@ pub fn read_wav_mono_16k(path: &Path) -> Result<Vec<f32>, AudioError> {
|
||||
Ok(resampler.process(&mono))
|
||||
}
|
||||
|
||||
/// Write mono 16kHz `f32` samples as a Float32 WAV — the format
|
||||
/// [`read_wav_mono_16k`] reads back. Used to persist the mic voiceprint sample
|
||||
/// next to a retained recording so it can be re-matched on reprocess (FR-SPK).
|
||||
pub fn write_wav_mono_16k(path: &Path, samples: &[f32]) -> Result<(), AudioError> {
|
||||
let spec = WavSpec {
|
||||
channels: 1,
|
||||
sample_rate: 16_000,
|
||||
bits_per_sample: 32,
|
||||
sample_format: SampleFormat::Float,
|
||||
};
|
||||
let mut writer =
|
||||
WavWriter::create(path, spec).map_err(|e| AudioError::Capture(format!("write wav: {e}")))?;
|
||||
for &s in samples {
|
||||
writer
|
||||
.write_sample(s)
|
||||
.map_err(|e| AudioError::Capture(format!("write wav: {e}")))?;
|
||||
}
|
||||
writer
|
||||
.finalize()
|
||||
.map_err(|e| AudioError::Capture(format!("write wav: {e}")))
|
||||
}
|
||||
|
||||
/// Ceiling on how far the still-flowing stream may run ahead of a stalled
|
||||
/// partner before the mixer forwards it alone — so a muted/dead microphone (or a
|
||||
/// silent system output) can't hold up the live transcript. 0.5s @ 16kHz.
|
||||
|
||||
Reference in new issue
Block a user