Are there official code resources to integrate Sar...
# ask-ai
a
Are there official code resources to integrate Sarvam AI SST and TTS using livekit?
t
Thanks for reaching out, Anushkaa. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
I'm glad you asked! Yes, there are official code resources available to help you integrate Sarvam AI Speech-to-Text (STT) and Text-to-Speech (TTS) with LiveKit, making the process smoother for you. The livekit-plugins-sarvam Python package is designed to support integrating Sarvam.ai’s Indian-language voice AI services into LiveKit Agents. Here’s what it offers: • Speech-to-Text (STT) using Sarvam's "Saarika" models • Text-to-Speech (TTS) using Sarvam's "Bulbul" models To get started, you can install it easily with:
Copy code
pip install livekit-plugins-sarvam
Or, if you’re setting up LiveKit Agents, just include it like this:
Copy code
uv add "livekit-agents[sarvam]~=1.2"
For authentication, you’ll need a Sarvam API key, which you can get from the Sarvam dashboard. Just make sure to store it in your environment variable
SARVAM_API_KEY
. Here’s a simple example to illustrate usage:
Copy code
from livekit.plugins import sarvam

agent = AgentSession(
    stt=sarvam.STT(language="hi-IN", model="saarika:v2.5"),
    tts=sarvam.TTS(target_language_code="hi-IN", speaker="anushka")
)
If you'd like to see a full example, there’s a wonderful one available in the LiveKit Python examples repository that walks you through the entire integration of Sarvam STT and TTS in a voice agent pipeline. Also, here are some additional resources that might be helpful: • Sarvam TTS Plugin Guide • Sarvam STT Plugin Guide • GitHub Repository If you have any more questions or need further assistance, feel free to reach out—I'm here to help! Sources: livekit-plugins/livekit-plugins-sarvam/livekit/plugins/sarvam/stt.py | Sarvam TTS plugin guide | LiveKit Docs | Sarvam STT plugin guide | LiveKit Docs | pipeline-tts/sarvam.py
a
Do you have code resources to integrate it without plugins?
t
I'm happy to help you with integrating Sarvam AI STT and TTS with LiveKit! To make this process smooth, you'll want to use the official
livekit-plugins-sarvam
plugin. This plugin takes care of everything you need—like authentication, API connections, WebSocket streaming, and data formatting—so you don’t have to worry about the technical details. At the moment, there aren't any alternative code resources or methods to integrate Sarvam AI STT and TTS with LiveKit without this plugin. All the examples and documentation we have are designed around using it for the best results. If you have a particular scenario in mind or need a hand with anything specific, please feel free to share! I’m here to guide you through it. Sources: livekit-plugins/livekit-plugins-sarvam/pyproject.toml | Sarvam STT plugin guide | LiveKit Docs | Sarvam TTS plugin guide | LiveKit Docs | pipeline-tts/sarvam.py
a
What is the target_language_code to give in Sarvam TTS to answer back in the same language as the user spoke to the system?
t
I want to help you get the best experience with Sarvam TTS! Just a quick note: the
target_language_code
needs to be explicitly set to a supported BCP-47 language code because Sarvam TTS doesn’t automatically detect and respond in the same language the user spoke. But don’t worry—we can work around this by detecting the user’s spoken language using STT and then updating the TTS settings dynamically. Here’s a friendly guide on how to do this: • Start by using Sarvam STT to process the user’s input in a set language, like
hi-IN
for Hindi. • Then, programmatically update the TTS language with the
update_options
method, such as
tts.update_options(target_language_code="hi-IN")
. • Make sure to keep the STT and TTS language settings synchronized so everything flows smoothly. Just so you know, Sarvam TTS supports these languages:
bn-IN
,
en-IN
,
gu-IN
,
hi-IN
,
kn-IN
,
ml-IN
,
mr-IN
,
od-IN
,
pa-IN
,
ta-IN
, and
te-IN
. If you’d like, I’m here to provide a detailed example or walk you through implementing dynamic language switching—just let me know! Sources: Gladia STT plugin guide | LiveKit Docs | Sarvam TTS plugin guide | LiveKit Docs | pipeline-tts/changing_language/README.md | livekit-plugins/livekit-plugins-sarvam/livekit/plugins/sarvam/__init__.py