Fix experimental audio, add denoise, auto volume.Prep migration (#38874)

Uses the previously merged denoising crate (and fixes a bug in it that
snug in during refactoring) to add denoising to the microphone input. 

Adds automatic volume control for microphone and output.

Prepares for migrating to 16kHz SR mono:
The experimental audio path now picks the samplerate and channel count depending on a setting. It can handle incoming streams with both the current (future legacy) and new samplerate & channel count. These are url-encoded into the livekit track name

Release Notes:

- N/A
This commit is contained in:
David Kleingeld
2025-09-25 15:11:12 +02:00
committed by GitHub
parent 783ba389f7
commit 3c5e683fbe
15 changed files with 498 additions and 161 deletions
+3 -3
View File
@@ -138,13 +138,13 @@ impl Engine {
const SPECTRUM_INPUT: &str = "input_2";
const MEMORY_INPUT: &str = "input_3";
let memory_input =
let spectrum =
Tensor::from_slice::<_, f32>(&self.in_magnitude, (1, 1, FFT_OUT_SIZE), &Device::Cpu)
.expect("the in magnitude has enough elements to fill the Tensor");
let inputs = HashMap::from([
(MEMORY_INPUT.to_string(), memory_input),
(SPECTRUM_INPUT.to_string(), self.spectral_memory.clone()),
(SPECTRUM_INPUT.to_string(), spectrum),
(MEMORY_INPUT.to_string(), self.spectral_memory.clone()),
]);
inputs
}
+1 -1
View File
@@ -84,7 +84,7 @@ impl<S: Source> Denoiser<S> {
.spawn(move || {
run_neural_denoiser(denoised_tx, input_rx);
})
.unwrap();
.expect("Should be ablet to spawn threads");
Ok(Self {
inner: source,