I'm using Sarvam for STT and TTS and I got an erro...
# ask-ai
b
I'm using Sarvam for STT and TTS and I got an error that says " 204850.606 ERROR… livekit.agents error decoding WAV audio ", seems like Sarvam TTS is giving outputs in mp3. How to fix this
✅ 1
t
Thanks for reaching out, Sai. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Thanks — that error message makes sense: something in your pipeline is trying to decode a WAV stream, but Sarvam’s TTS is returning an encoded MP3 stream (or otherwise not supplying proper WAV bytes). I can help you fix that. Below are the simplest options and next steps; pick the one that fits your use case. What to do (short options) • Use PCM/raw audio from Sarvam TTS instead of MP3. LiveKit’s agents expect audio as audio frames (PCM) for streaming; PCM will avoid the WAV-decode error. • If you need a WAV file, collect the audio frames and convert them to WAV (this adds the proper WAV header). • If you must use MP3 output, decode the MP3 into PCM frames before handing it to the LiveKit pipeline. Recommended steps (detailed) 1. Switch Sarvam TTS to PCM/raw output ◦ Configure the Sarvam TTS plugin to use
audio_format
=
pcm
(or the plugin’s default streaming format). This produces
AudioFrame
objects LiveKit expects and prevents “error decoding WAV audio.” ◦ Verify your TTS call returns audio frames rather than an encoded audio file blob. 1. If you need a WAV file (for storage or external processing) ◦ Collect the
AudioFrame
objects from the TTS stream. ◦ Combine frames and generate valid WAV bytes using the audio-frame helper:
Copy code
from livekit import rtc
     wav_bytes = rtc.combine_audio_frames(frames).to_wav_bytes()
• Pass
wav_bytes
to the component expecting a WAV byte stream. 1. If you must keep Sarvam producing MP3 ◦ Decode the MP3 into PCM (audio frames) before sending into LiveKit. ◦ Use an MP3 decoder library to convert to PCM frames, then feed those frames into the LiveKit audio pipeline or convert them to WAV as needed. Quick checks to confirm the root cause • Is your Sarvam TTS call currently set to
audio_format= "mp3"
? If yes, switch it to
pcm
. • What component emitted the “error decoding WAV audio”? Confirm it expects a full WAV byte stream (with header) and not raw PCM frames. • If you can share a short log snippet of the TTS configuration or the code that receives Sarvam output, I can point to the exact place to change. If you want, paste the TTS call/config or the small code path that receives the TTS output (no secrets). I’ll tell you the exact lines to change and a minimal example to produce PCM frames or a valid WAV output. Sources: Rime TTS | LiveKit Documentation | Sarvam TTS plugin guide | LiveKit Documentation | Capturing the First Few Seconds of a Call for Processing, with interactive elements