is it possible to preprocess audio with something ...
# ask-ai
f
is it possible to preprocess audio with something like RNNoise before using it inside realtime models?
t
Thanks for reaching out, Tusheet. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Could you please share a bit more about what you're hoping to achieve with RNNoise preprocessing? Specifically: • Are you aiming to replace or add to LiveKit's built-in Krisp noise reduction? • Will the preprocessing happen on the client side, in the agent, or through a custom pipeline? • Is low latency or open-source compliance especially important for choosing RNNoise? Understanding this will really help us explore the best possible workaround or alternative solution for you. Sources: examples/avatar_agents/bithuman/README.md | Enhanced noise cancellation | LiveKit docs | Client SDKs | livekit/livekit_composite | DeepWiki | components/room.tsx | Pipeline nodes and hooks | LiveKit docs
f
in the agent, or through a custom pipeline but before we send the audio to a realtime model
t
Custom audio preprocessing, including the use of RNNoise, can be thoughtfully implemented in the agent or a custom pipeline before sending audio to LiveKit's realtime models. You can do this by overriding the
stt_node()
method in a custom
Agent
subclass, which gives you the flexibility to process audio frames before they reach the default transcription or processing pipeline. For instance, applying RNNoise or other filters to the audio stream within this override is definitely possible. Just a heads-up, RNNoise isn’t natively supported, so it would require you to implement it manually using a Python or Node.js binding. On the bright side, LiveKit offers built-in noise cancellation and background voice cancellation (BVC) powered by Krisp, which you can easily enable through
RoomInputOptions
or similar configurations. These options tend to work well for most scenarios. If you’d like, I’d be happy to share a code template or walk you through integrating RNNoise into the
stt_node()
override. Just let me know how you’d like to move forward—I’m here to help! Sources: Enhanced noise cancellation | LiveKit docs | packages/livekit-rtc/src/audio_stream.ts | livekit-plugins/livekit-plugins-gladia/livekit/plugins/gladia/stt.py | Pipeline nodes and hooks | LiveKit docs
f
using realtime models like Gemini live do not have a STT node. Then how do I do this?
t
For Gemini live models, which don’t use an STT node, you have some great options to preprocess audio with custom filters like RNNoise by setting up a custom audio processing pipeline. Let me walk you through the key approaches: 1. Audio Stream Preprocessing: You can preprocess audio streams right in your agent code before sending them to the Gemini model. This means applying RNNoise or other filters to the audio frames in real-time. For instance, using Python bindings for RNNoise to process audio frames and then passing the filtered audio along to the model. 2. Custom Audio Filter Plugin: If you’re looking for a more integrated solution, creating a custom audio filter plugin that wraps RNNoise could be the way to go. This plugin would implement LiveKit’s audio filter interface and handle audio frames before they reach the model. 3. Raw Audio Frame Processing: You can also process audio frames from participants one by one with RNNoise. This approach offers flexibility and lets you manage audio streams dynamically. Keep in mind, each method involves managing audio frame sizes, making sure the sample rate matches (RNNoise usually works at 48kHz), and maintaining low latency for smooth real-time performance. If you’d like, I’d be happy to provide detailed guidance or some code examples for any of these methods. Just let me know how you’d like to move forward! Sources: tools/mtmd/mtmd-audio.cpp | livekit/src/plugin.rs | livekit-rtc/livekit/rtc/_proto/audio_frame_pb2.pyi | packages/livekit-rtc/src/audio_filter.ts | Pipeline nodes and hooks | LiveKit docs
f
yes please
t
I don't have the answer you're looking for. You could also try asking your question: • in one of the other Slack channels or • to https://deepwiki.com/livekit/livekit_composite which is trained on all LiveKit source code If you find the answer, please post it here to help others!