How can I play a recorded audio as a Greeting Mess...
# ask-ai
a
How can I play a recorded audio as a Greeting Message instead of generating it from TTS?? This needs to be done only once when the sesson starts.. suggest me how
t
Thanks for reaching out, Hiren. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
You're asking how to play a pre-recorded audio greeting once at session start instead of using TTS — here’s a concise approach and a minimal example. Plan • Load/decode your recorded file into an AsyncIterable of
rtc.AudioFrame
(48kHz mono recommended). • Call
session.say()
immediately after
session.start()
and pass the audio stream via the
audio
parameter. • Set
allow_interruptions=False
so it plays once uninterrupted. Minimal Python sketch
Copy code
# after session.start(...)
async def audio_frames_from_file(path) -> AsyncIterable[rtc.AudioFrame]:
    # decode file (e.g., with PyAV) and yield rtc.AudioFrame objects
    async for frame in decode_audio_file(path):
        yield frame

await session.say(audio=audio_frames_from_file("/path/greeting.wav"),
                  allow_interruptions=False)
Notes • Do not pass text to
say()
if you don't want it added to transcript/context. • Ensure audio format and frame rate match LiveKit audio requirements (decode to frames before yielding). • Place this call immediately after
session.start()
so it runs once when the session begins. If you want, tell me your runtime (Python/Node) and file format and I’ll give a concrete decoding snippet for that environment. Sources: Agent speech and audio | LiveKit docs