> For clean Markdown of any page, append `.md` to the page URL. > For a complete documentation index, see https://docs.sarvam.ai/llms.txt. > For full documentation content in one file, see https://docs.sarvam.ai/llms-full.txt. > For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.sarvam.ai/_mcp/server. # Government Scheme Awareness Agent using LiveKit > Build a voice-based agent that helps citizens understand and apply for government schemes using LiveKit and Sarvam AI. Support for 11 languages (10 Indian + English). ## Overview This guide demonstrates how to build a **government scheme awareness agent** that helps citizens discover, understand, and learn how to apply for various government welfare schemes using **LiveKit** for real-time communication and **Sarvam AI** for speech processing. Ideal for government digital initiatives, NGOs, and citizen service centers. > **Tip** > > For the broader architecture pattern this agent fits into, accessibility, grounding scheme facts, latency targets, see the [Government Services](/api/api-guides-tutorials/speech-to-text/use-cases/government-services) use-case guide. For a closely related rural/farmer audience, see [Agri & Rural](/api/api-guides-tutorials/speech-to-text/use-cases/agri-rural). ## What You'll Build A voice agent that can: * Explain various government schemes in simple language * Help citizens understand eligibility criteria * Guide users through application processes * Answer questions about benefits, documents required, and deadlines * Communicate in multiple Indian languages for maximum accessibility ## Quick Overview 1. Get API keys (LiveKit, Sarvam) 2. Install packages 3. Create `.env` file with your API keys 4. Write the agent code 5. Run: `python agent.py dev` 6. Test: `python agent.py console` --- ## Quick Start ### 1. Prerequisites * Python 3.9 or higher * API keys from: * [LiveKit Cloud](https://cloud.livekit.io) (free account) * [Sarvam AI](https://dashboard.sarvam.ai) (get API key from dashboard) ### 2. Install Dependencies #### macOS/Linux ```bash pip install "livekit-agents[sarvam,silero]" python-dotenv ``` #### Windows ```bash pip install livekit-agents[sarvam,silero] python-dotenv ``` ### 3. Create Environment File Create a file named `.env` in your project folder and add your API keys: ```env LIVEKIT_URL=wss://your-project-xxxxx.livekit.cloud LIVEKIT_API_KEY=APIxxxxxxxxxxxxx LIVEKIT_API_SECRET=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx SARVAM_API_KEY=sk_xxxxxxxxxxxxxxxxxxxxxxxx ``` Replace the values with your actual API keys. ### 4. Write Your Agent Create `scheme_awareness_agent.py`: ```python import logging from dotenv import load_dotenv from livekit.agents import JobContext, WorkerOptions, cli from livekit.agents.voice import Agent, AgentSession from livekit.plugins import sarvam # Load environment variables load_dotenv() # Set up logging logger = logging.getLogger("scheme-awareness-agent") logger.setLevel(logging.INFO) class GovernmentSchemeAgent(Agent): def __init__(self) -> None: super().__init__( # Government scheme awareness agent personality and instructions instructions=""" You are a helpful government scheme awareness assistant designed to help Indian citizens understand and access various government welfare schemes and programs. Your responsibilities: - Explain government schemes in simple, easy-to-understand language - Help citizens determine their eligibility for various schemes - Provide information about required documents for applications - Guide users through the application process step by step - Answer questions about scheme benefits, deadlines, and procedures - Suggest relevant schemes based on user's situation (farmer, student, senior citizen, etc.) Key government schemes you should know about: - PM Kisan Samman Nidhi (farmer income support) - Ayushman Bharat (health insurance) - PM Awas Yojana (housing for all) - Sukanya Samriddhi Yojana (girl child savings) - PM Ujjwala Yojana (LPG connections) - MGNREGA (rural employment guarantee) - PM Jan Dhan Yojana (financial inclusion) - Atal Pension Yojana (pension scheme) - PM Mudra Yojana (small business loans) - Skill India Mission (skill development) Communication guidelines: - Use simple language avoiding complex jargon - Be patient and willing to repeat or explain again - Speak slowly and clearly - Be encouraging and supportive - If you don't know something, honestly say so and suggest where they can get accurate information - Always mention official government portals for verification - Be sensitive to the fact that many users may have limited formal education Start by greeting the user warmly and asking how you can help them today with government schemes. """, # Saaras v4 STT - Converts speech to text stt=sarvam.STT( language="unknown", # Auto-detect language for accessibility model="saaras:v4", mode="transcribe" ), # Sarvam LLM - The "brain" that processes and generates responses llm=sarvam.LLM(model="sarvam-105b"), # Bulbul TTS - Converts text to speech tts=sarvam.TTS( language_code="hi-IN", # Hindi as default for wider reach model="bulbul:v3", speaker="simran" # Warm and friendly female voice ), ) async def on_enter(self): """Called when user joins - agent starts the conversation""" self.session.generate_reply() async def entrypoint(ctx: JobContext): """Main entry point - LiveKit calls this when a user connects""" logger.info(f"User connected to room: {ctx.room.name}") # Create and start the agent session session = AgentSession() await session.start( agent=GovernmentSchemeAgent(), room=ctx.room ) if __name__ == "__main__": # Run the agent cli.run_app(WorkerOptions(entrypoint_fnc=entrypoint)) ``` ### 5. Run Your Agent ```bash python scheme_awareness_agent.py dev ``` ### 6. Test Your Agent In a new terminal, run: ```bash python scheme_awareness_agent.py console ``` --- ## Customization Examples ### Example 1: Hindi-focused Agent For Hindi-speaking citizens: ```python stt=sarvam.STT( language="hi-IN", # Hindi model="saaras:v4", mode="transcribe" ), tts=sarvam.TTS( language_code="hi-IN", model="bulbul:v3", speaker="simran" # Warm and friendly voice ) ``` ### Example 2: Tamil Agent for Rural Tamil Nadu ```python stt=sarvam.STT(language="ta-IN", model="saaras:v4", mode="transcribe"), tts=sarvam.TTS( language_code="ta-IN", model="bulbul:v3", speaker="priya" ) ``` ### Example 3: Bengali Agent for West Bengal ```python stt=sarvam.STT(language="bn-IN", model="saaras:v4", mode="transcribe"), tts=sarvam.TTS( language_code="bn-IN", model="bulbul:v3", speaker="ishita" ) ``` ### Example 4: Multilingual Agent (Auto-detect) For citizen service centers serving diverse populations: ```python stt=sarvam.STT(language="unknown", model="saaras:v4", mode="transcribe"), # Auto-detects language tts=sarvam.TTS(language_code="hi-IN", model="bulbul:v3", speaker="simran") ``` ### Example 5: Speech-to-English Agent (Saaras) When you need to process regional language input but generate English reports. Saaras v4 handles both transcription (same-language output) and translation (English output) via the `mode` parameter: use `mode="translate"` for speech-to-English. ```python # User speaks in any Indian language → Saaras converts to English → LLM processes stt=sarvam.STT(model="saaras:v4", mode="translate"), # Speech-to-English translation llm=sarvam.LLM(model="sarvam-105b"), tts=sarvam.TTS(language_code="en-IN", model="bulbul:v3", speaker="priya") ``` --- ## Available Options ### Language Codes | Language | Code | | --------------- | --------- | | English (India) | `en-IN` | | Hindi | `hi-IN` | | Bengali | `bn-IN` | | Tamil | `ta-IN` | | Telugu | `te-IN` | | Gujarati | `gu-IN` | | Kannada | `kn-IN` | | Malayalam | `ml-IN` | | Marathi | `mr-IN` | | Punjabi | `pa-IN` | | Odia | `od-IN` | | Auto-detect | `unknown` | ### Speaker Voices (Bulbul v3) **Male (23):** Shubh (default), Aditya, Rahul, Rohan, Amit, Dev, Ratan, Varun, Manan, Sumit, Kabir, Aayan, Ashutosh, Advait, Anand, Tarun, Sunny, Mani, Gokul, Vijay, Mohit, Rehan, Soham **Female (14):** Ritu, Priya, Neha, Pooja, Simran, Kavya, Ishita, Shreya, Roopa, Tanya, Shruti, Suhani, Kavitha, Rupali --- ## Pro Tips * Use `language="unknown"` to serve citizens who speak different languages * Use warm, friendly voices like `simran` for citizen-facing services * Sarvam's models handle code-mixing naturally - citizens often mix Hindi with English or regional languages * Consider deploying region-specific agents for better language accuracy * Keep responses simple and avoid bureaucratic jargon --- ## Troubleshooting **API key errors**: Check that all keys are in your `.env` file and the file is in the same directory as your script. **Module not found**: Run the installation command again based on your operating system. **Poor transcription**: Try `language="unknown"` for auto-detection, or specify the correct language code. --- ## Additional Resources * [Sarvam AI Documentation](https://docs.sarvam.ai) * [LiveKit Documentation](https://docs.livekit.io) * [LiveKit Sarvam LLM Plugin](https://docs.livekit.io/agents/models/llm/sarvam/) * [LiveKit Sarvam STT Plugin](https://docs.livekit.io/agents/models/stt/plugins/sarvam/) * [LiveKit Sarvam TTS Plugin](https://docs.livekit.io/agents/models/tts/plugins/sarvam/) --- ## Need Help? * Sarvam Support: [support@sarvam.ai](mailto:support@sarvam.ai) * Community: [Join the Discord Community](https://discord.com/invite/5rAsykttcs) --- **Happy Building!** > Build a voice-based agent that helps citizens understand and apply for government schemes using LiveKit and Sarvam AI. Support for 11 languages (10 Indian + English).