Hi. I am facing some issues while developing a com...
# sdk-rust
a
Hi. I am facing some issues while developing a command-line voice-chat app using livekit rust sdk. 1. I am using cpal package to capture and play audio. While playing audio I am using livekit's AudioResampler to resample the received frames like this
Copy code
// Resample the audio frame
                    let data_i16 = resampler.remix_and_resample(
                        &frame.data,
                        frame.samples_per_channel,
                        frame.num_channels,
                        frame.sample_rate,
                        num_channels,
                        sample_rate,
                    );

                    // Convert i16 samples to f32 before sending to cpal as cpal works with float samples
                    let data_f32: Vec<f32> = data_i16
                        .iter()
                        .map(|&sample| sample as f32 / i16::MAX as f32) // Normalize i16 to f32
                        .collect();

                    let _ = sender.send(data_f32).await; // Send the f32 samples to the cpal callback
The main issue is that there is quite a bit of buzz in the sound. Any idea how to fix this? I have a sample app in Flutter, where this low level audio handling is not required and it seems to have perfect audio. 2. The
ActiveSpeakersChanged
event seems to be flaky. It immediately goes from a list of one member (when I start speaking) to empty list in an instant.
d
Hey @abundant-alligator-31938, we've actually deprecated the old resampler, which can produce this type of artifact. we've just released a new soxr based resampler: https://github.com/livekit/rust-sdks/tree/main/soxr-sys this is being used by our Python and Node SDKs via FFI, but we've not yet built the interfaces to it in pure Rust. If you are interested in exposing them in a PR, we'd love to merge that capability in
l
@magnificent-farmer-43889