DEV Community

Saptak Roy
Saptak Roy

Posted on

Building Roshni: A Real-Time, Multi-Agent Financial Voice AI for Bharat ๐Ÿ‡ฎ๐Ÿ‡ณ

Building Roshni: An Ultra-Low Latency, Multi-Agent Financial Voice Assistant for Bharat ๐Ÿ‡ฎ๐Ÿ‡ณ

How I built an end-to-end, multilingual financial voice AI using Murf Falcon, LiveKit Agents, Deepgram Nova-3, Google Gemini, and Next.js during the 10 Days of AI Voice Agents Challenge.


๐ŸŒŸ 1. The Problem & Why Voice Matters for Bharat

In India, financial inclusion has accelerated rapidly with UPI, digital banking, and government-backed credit initiatives. However, navigating complex interest rates, eligibility criteria for government schemes (like PM Mudra or Sukanya Samriddhi Yojana), and understanding formal banking terms remains intimidating for millions of citizensโ€”especially in regional and tier-2/3 heartlands where digital interfaces can be overwhelming.

Text-first interfaces fail where voice thrives.
When rural entrepreneurs or first-time bank customers have questions, they don't want to navigate complex web forms or read dense PDFs. They want to ask a direct question in their language and get an immediate, clear, spoken answer.

To solve this, I built Roshni AI (and her specialist counterpart, Vikram) โ€” an ultra-low latency, conversational financial assistant engineered for natural voice interactions in English, Hindi (Devanagari script), and Hinglish.


๐Ÿ—๏ธ 2. High-Level Architecture & Tech Stack

Building a real-time conversational agent requires synchronizing four core pipelines with sub-second latency:


Enter fullscreen mode Exit fullscreen mode
          [ ๐Ÿ‘ค User Microphone ]
                    โ”‚ (WebRTC Audio Stream)
                    โ–ผ
      โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
      โ”‚     LiveKit Agents Worker    โ”‚
      โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                     โ”‚
Enter fullscreen mode Exit fullscreen mode

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ–ผ โ–ผ โ–ผ


โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”       โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”       โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  Deepgram   โ”‚ โ”€โ”€โ”€โ”€โ–บ โ”‚Google Geminiโ”‚ โ”€โ”€โ”€โ”€โ–บ โ”‚   Murf Falcon   โ”‚
โ”‚   Nova-3    โ”‚       โ”‚    (LLM)    โ”‚       โ”‚     Fast TTS    โ”‚
โ”‚  (Fast STT) โ”‚       โ”‚             โ”‚       โ”‚ (Anisha / Samar)โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜       โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”˜       โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
โ”‚ (Tool / Handoff)      โ”‚
โ–ผ                       โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”       [ ๐Ÿ”Š Audio Output ]
โ”‚ SQLite Memory โ”‚
โ”‚  & Analytics  โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Enter fullscreen mode Exit fullscreen mode

The Stack:

  • TTS (Text-to-Speech): Murf Falcon โ€” Delivering conversational Indian voices (Anisha for general banking and Samar for specialist schemes) with lightning-fast Time-To-First-Byte (TTFB ~95ms).
  • STT (Speech-to-Text): Deepgram Nova-3 (language="multi") for instantaneous multi-language speech recognition.
  • LLM Engine: Google Gemini (gemini-3.5-flash-lite) with strict prompt guardrails.
  • Real-time Transport & Orchestration: LiveKit Agents Framework + Silero VAD for natural turn-taking and interruption handling.
  • Frontend Portal & Dashboard: Next.js 15, Tailwind CSS, and LiveKit Components React.
  • Persistence & Call Analytics: SQLite with instant synchronous write pipelines.

๐Ÿš€ 3. Key Capabilities Built

๐ŸŽ™๏ธ 1. Ultra-Realistic Indian Voices via Murf Falcon

Using Murf Falconโ€™s conversational voices transformed the agent from a robotic IVR into a warm, approachable advisor. By pacing sentences naturally and configuring TTFB optimization, conversational latency stayed under 1 second.

๐Ÿ”ค 2. Native Devanagari Script Enforcement

A common flaw in bilingual voice bots is sending romanized Hindi (e.g., "namaste, aapka swagat hai") to TTS engines, causing English phonetic engines to mispronounce Indian syllables. I enforced strict system prompt constraints:

Always write Hindi in Devanagari script (e.g., "เคจเคฎเคธเฅเคคเฅ‡, เค†เคชเค•เคพ เคธเฅเคตเคพเค—เคค เคนเฅˆ"). Never write romanized Hindi.

This simple prompt architecture ensured flawless Indian accent pronunciation every single turn.

๐Ÿง  3. Persistent Memory & User Recognition

Using SQLite (agent_memory.db), Roshni stores caller identity, preferred languages, and previous queries. Returning users are greeted by name with tailored suggestions based on their recorded financial profile.

๐Ÿ› ๏ธ 4. Tool Execution & Dynamic Rate Lookups

Roshni accesses custom tools like check_scheme_rates to provide live, structured interest rate calculations for Fixed Deposits, Senior Citizen schemes, and Savings accounts without LLM hallucinations.

๐Ÿค 5. Multi-Agent Specialist Handoff (Day 9 Milestone)

One agent should not try to be an expert in everything. I split responsibilities between two distinct agents:

  1. Roshni (General Banking): Powered by Murf Falcon Anisha. Handles general banking and savings queries.
  2. Vikram (Government Scheme Specialist): Powered by Murf Falcon Samar. Specializes in PM Mudra loans, subsidies, and government welfare programs.

When a caller asks about government schemes, Roshni announces: "I will connect you to Vikram, our Government Scheme Specialist", and hands over the full conversation history to Vikram in real time.

# Multi-Agent Handoff in LiveKit
@function_tool
async def transfer_to_scheme_specialist(self, context: RunContext, query: str) -> str:
    """Handoff caller to Vikram for Government Scheme queries."""
    self.session_state["is_success"] = True
    record_call_outcome(self.call_id, "SUCCESS", "Transferred to Scheme Specialist")
    return "I will connect you to Vikram, our Government Scheme Specialist."

Enter fullscreen mode Exit fullscreen mode

๐Ÿ“ˆ 6. Real-Time Call Analytics Dashboard

A dedicated Next.js dashboard tracks live call outcomes:

  • Total Calls, Successful Inquiries, and Failure rates.
  • Live inspection of active session reference IDs and reasons.
  • Zero-cache dynamic API endpoints polling local SQLite metrics every 2 seconds.

๐Ÿ’ฅ 4. Engineering Challenges & How I Solved Them

No real-world AI project works on the first try. Here were the biggest hurdles and how I conquered them:

โšก Challenge 1: The 429 Quota Trap & Model Selection

  • The Problem: Experimental LLM versions like gemini-3.5-flash have an ultra-restrictive free tier limit of only 20 requests per day. Voice pipelines consume 10โ€“15 calls per conversation due to streaming transcript evaluations, quickly causing 429 Too Many Requests crashes.
  • The Solution: I switched to gemini-3.5-flash-lite, which offers 500 daily requests, instantly resolving quota exhaustion and reducing inference latency.

โฑ๏ธ Challenge 2: Synchronous Network Blocking in Function Tools

  • The Problem: Making synchronous network calls inside tools blocked the Python asyncio event loop, causing LiveKit audio streams to stutter and trigger gateway timeouts.
  • The Solution: Refactored all tool network operations to use asynchronous non-blocking patterns (aiohttp), keeping audio streaming perfectly smooth.

๐Ÿ’พ Challenge 3: SQLite Multi-Process Disconnect Race Conditions

  • The Problem: Logging call outcomes strictly on on_disconnected sometimes missed calls when sessions were terminated abruptly by the browser client.
  • The Solution: Implemented synchronous write-ahead loggingโ€”recording an initial session row immediately on connect and updating it instantly the moment a tool executes.

๐Ÿ› ๏ธ 5. Step-by-Step Guide: Run Your Own Voice Agent

Want to run this agent locally? Here is how to get started in under 5 minutes:

Prerequisites

  • Python 3.10+
  • Node.js 18+
  • Free API Keys: LiveKit Cloud, Murf AI, Deepgram, and Google AI Studio.

Step 1: Clone the Repository

git clone [https://github.com/your-username/murf-livekit-starter-main.git](https://github.com/your-username/murf-livekit-starter-main.git)
cd murf-livekit-starter-main

Enter fullscreen mode Exit fullscreen mode

Step 2: Configure Environment Variables

Create a .env file in backend/:

LIVEKIT_URL=wss://your-project.livekit.cloud
LIVEKIT_API_KEY=your_livekit_api_key
LIVEKIT_API_SECRET=your_livekit_api_secret
DEEPGRAM_API_KEY=your_deepgram_api_key
MURF_API_KEY=your_murf_api_key
GOOGLE_API_KEY=your_gemini_api_key

Enter fullscreen mode Exit fullscreen mode

Step 3: Run Backend Agent

cd backend
python -m venv venv
venv\Scripts\activate
pip install -r requirements.txt
python src/agent.py dev

Enter fullscreen mode Exit fullscreen mode

Step 4: Run Next.js Frontend

cd ../frontend
npm install
npm run dev

Enter fullscreen mode Exit fullscreen mode

Open http://localhost:3000, click Start Session, and start talking!


๐Ÿ”ฎ Whatโ€™s Next?

  • More Regional Dialects: Adding Tamil, Telugu, and Bengali voice models using Murf Falcon.
  • Direct Core Banking API Integration: Secure sandboxed mock transactions via voice biometric confirmation.
  • Low-bandwidth Audio Compression: Optimizing codecs for 2G/3G mobile connectivity in rural areas.

๐Ÿ”— Links & Resources

MY ENTIRE CODE IS IN [ https://github.com/rumparoy3012-ops/DAY-1-AI-VOICE-AGENT-BUILDING ] SO IF VIEW IT FOR BETTER UNDERSTANDING.

Special thanks to the Murf AI team for organizing the #10DaysofAIVoiceAgents โ€” VoiceForBharat Challenge!


Enter fullscreen mode Exit fullscreen mode

Top comments (2)

Collapse
 
saptak_roy_950fd751ad80bc profile image
Saptak Roy

good

Collapse
 
technogamerz profile image
๐“๐ก๐ž ๐‹๐š๐ณ๐ฒ ๐†๐ข๐ซ๐ฅ

Nice ๐Ÿ‘๐Ÿป