how hard it is to get the raw audio directly from ...
# ask-ai
h
how hard it is to get the raw audio directly from livekit and pass it to our STT custom model ?
t
Thanks for reaching out, Issam. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
I’m glad you’re exploring how to access raw audio from LiveKit to use with your custom Speech-to-Text (STT) model! You can achieve this by using the
rtc.AudioStream
class, which lets you tap into the raw audio stream from a participant’s track. This way, you can process audio frames in real-time or collect them for later use. Here’s a simple overview to guide you: • Access Raw Audio: Listen for the
on_track_subscribed
event to know when an audio track is published. Then, wrap the track with
rtc.AudioStream
to start working with
AudioFrame
objects. • Buffer and Convert: Gather frames over the time you need, and then use
combine_audio_frames
along with
to_wav_bytes
to create a WAV file that your STT model can understand. • Custom STT Integration: You can override the
stt_node
in your agent to send audio directly to your custom STT model. Alternatively, the standalone streaming interface with
push_frame
lets you handle real-time audio processing smoothly. This method should work well with most STT models and gives you great flexibility in handling audio. If you’d like, I’m here to help with more details or provide some example code—just let me know! Sources: Pipeline nodes and hooks | LiveKit Docs | An open source stack for real-time multimodal AI | AI Agents Framework | livekit/livekit_composite | DeepWiki | Capturing the First Few Seconds of a Call for Processing | Speech-to-text (STT) models | LiveKit Docs