How to inject audio to the agent pipeline
# ask-ai
l
How to inject audio to the agent pipeline
✅ 1
t
Thanks for reaching out, Rajadurai. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Thanks — I’m responding to your question about injecting audio into the agent pipeline. Short answer: you can’t directly "inject" audio into the agent input with a single built-in API call, but you can accomplish the same result with one of these approaches depending on your goal: • Use a custom
stt_node
to replace or modify incoming audio frames before they go to STT. This effectively injects or transforms user input programmatically. • Publish a programmatic audio track from the agent (e.g., with a
LocalAudioTrack
) to broadcast audio into the room — useful when you want the agent to play pre-recorded or programmatic audio as a participant. • For agent output, use
session.say()
with the
audio
parameter to play pre-synthesized audio as agent speech (this is agent output, not user-input injection). • Use
BackgroundAudioPlayer
to play ambient/auxiliary audio during processing (separate track; not part of STT input). Which of these fits your use case? • Are you trying to simulate user speech into STT (testing/automation), replace live user audio before transcription, or have the agent play audio into the room? • Also tell me your environment (server-side agent, client SDK, or custom pipeline) and preferred language/runtime so I can give concrete code snippets. Sources: Agent speech and audio | LiveKit Documentation | Audio customization | LiveKit Documentation | External data and RAG | LiveKit Documentation | Background audio | LiveKit Documentation | Pipeline nodes and hooks | LiveKit Documentation, with interactive elements