<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
<channel>
<title>Coder Legion - Recent posts tagged voice-assistant</title>
<link>https://coderlegion.com/tag/voice-assistant</link>
<description>Powered by Question2Answer</description>
<item>
<title>Building Dexibi: A Voice-First AI Operator for Windows</title>
<link>https://coderlegion.com/32801/building-dexibi-a-voice-first-ai-operator-for-windows</link>
<description>&lt;p&gt;The Idea Behind Dexibi&lt;/p&gt;
&lt;p&gt;Dexibi started with a frustration. I was watching a show on Amazon Prime. When the episode ended there was no Next Episode button. I thought, what if I had an AI that could just play the episode for me? That small idea grew into something. It became an AI that lets people control their computers using language instead of clicking and typing through every step.&lt;/p&gt;
&lt;p&gt;Beyond Simple Voice Commands&lt;/p&gt;
&lt;p&gt;Dexibi wants to help users do tasks using their voice. Imagine being in the kitchen cooking and asking your computer to read your emails summarize an article or draft a social media post. Developers could also use Dexibi as a desktop operator alongside tools like Claude or Cursor. The idea is to make computers respond to what you want not how you want it done.&lt;/p&gt;
&lt;p&gt;Making this work reliably is hard. Understanding a request is only the first step. The AI must also figure out what you really mean and carry out the actions—safely.&lt;/p&gt;
&lt;p&gt;The Microphone Reliability Challenge&lt;/p&gt;
&lt;p&gt;One big challenge I'm focused on is microphone reliability. It's not about picking up your voice. Distance matters. A microphone might work well when someone is sitting in front of the computer but it can struggle when they move away. Background noise makes things even harder. A kitchen with a humming refrigerator or a living room with music playing can interfere.&lt;/p&gt;
&lt;p&gt;Dexibi offers three listening modes: Relaxed, Balanced and Strict. These are meant to balance how far you can be from the computer and how accurately the AI understands you. Relaxed mode works at a distance. May miss some details. Strict mode is more precise. Needs you to be closer. Balanced offers a ground.&lt;/p&gt;
&lt;p&gt;The next goal is to make the experience work well across places different microphones and different levels of noise. Voice-first apps have to work outside conditions to be useful in real life.&lt;/p&gt;
&lt;p&gt;Safety Matters&lt;/p&gt;
&lt;p&gt;An AI that controls your computer needs safety measures that go beyond those for a text- AI. A wrong command could open the window delete something or start a process you didn’t mean to start. That’s why safety is a part of Dexibi.&lt;/p&gt;
&lt;p&gt;Now Dexibi uses command validation. It checks if a command makes sense before running it. For high-risk actions—like moving files or shutting down the computer—it asks for confirmation. It also limits access to parts of the system using restricted shell access to prevent unintended changes.&lt;/p&gt;
&lt;p&gt;The goal is to make control easier without taking your control. You should feel safe knowing the AI is helping not taking over.&lt;/p&gt;
&lt;p&gt;What's Next?&lt;/p&gt;
&lt;p&gt;Dexibi is built on a belief: people should be able to say what they want their computer to do not have to do every step themselves. That’s the mission.&lt;/p&gt;
&lt;p&gt;There’s still a lot to do. Microphone distance and background noise are issues.. These aren’t just problems to fix—they’re part of building a product that works in real life not just in a quiet room.&lt;/p&gt;
&lt;p&gt;The future is, about making voice-driven computer interaction practical more reliable and safer. So users can focus on what matters to them—doing their work— of clicking and typing every step of the way.&lt;/p&gt;
</description>
<category>Articles</category>
<guid isPermaLink="true">https://coderlegion.com/32801/building-dexibi-a-voice-first-ai-operator-for-windows</guid>
<pubDate>Wed, 28 Oct 2026 18:00:00 +0000</pubDate>
</item>
<item>
<title>After months of building in silence, I cried a little- a stranger made a YouTube video about our pro</title>
<link>https://coderlegion.com/17948/after-months-of-building-in-silence-cried-little-stranger-made-youtube-video-about-our-pro</link>
<description>&lt;p&gt;&lt;img src=&quot;https://coderlegion.com/?qa=blob&amp;amp;qa_blobid=8018882875828444537&quot; alt=&quot;&quot;&gt;&lt;/p&gt;
&lt;p&gt;A few months ago, I told my co-founder I wasn't sure if anyone would ever care about what we were building.&lt;/p&gt;
&lt;p&gt;We started Dograh as an open-source voice AI platform—an alternative to the closed players like Vapi and Retell. We thought developers would want this. But for a long time, GitHub stars trickled in slowly. Discord stayed quiet. Some days I'd refresh the analytics dashboard, hoping to see something move, and nothing would.&lt;/p&gt;
&lt;p&gt;Today, everything changed. &lt;/p&gt;
&lt;p&gt;Our stars started climbing fast, and we couldn't figure out why. Then we looked at our homepage bot, which asks every new user where they heard about us. Almost all of them said YouTube. We searched and found a BetterStack tutorial posted an hour ago. They'd built something with Dograh, liked it enough to record a video, and put it out into the world. We had no idea it was coming. We've never spoken to them.&lt;/p&gt;
&lt;p&gt;We just crossed 500 stars. I keep refreshing the signup graph because part of me still doesn't believe it.&lt;br&gt;
If you're building something open source and the silence is getting to you, I just want to say: someone out there might already be using your project. They might be about to tell the world. Keep shipping.&lt;/p&gt;
</description>
<category>Discussions</category>
<guid isPermaLink="true">https://coderlegion.com/17948/after-months-of-building-in-silence-cried-little-stranger-made-youtube-video-about-our-pro</guid>
<pubDate>Fri, 15 May 2026 11:40:07 +0000</pubDate>
</item>
<item>
<title>We finally broke the 500ms latency barrier for AI phone calls.</title>
<link>https://coderlegion.com/16611/we-finally-broke-the-500ms-latency-barrier-for-ai-phone-calls</link>
<description>&lt;p&gt;Hey CoderLegion! One of the biggest complaints with AI calling is the lag.&lt;br&gt;
We wanted to share a raw snippet of our open-source framework, Siphon, in action.&lt;br&gt;
By using WebRTC under the hood instead of WebSockets, we've gotten the voice-to-voice response time to feel incredibly human.&lt;br&gt;
Would love for you guys to test the repo and let us know how it feels on your local machines!&lt;/p&gt;
&lt;p&gt; &lt;a rel=&quot;nofollow&quot; href=&quot;https://www.youtube.com/watch?v=GkY42naY8lg&amp;amp;t=1s&quot;&gt;Siphon | Step-by-Step YT Tutorial&lt;/a&gt;&lt;br&gt;
&lt;a rel=&quot;nofollow&quot; href=&quot;http://siphon.blackdwarf.in/docs&quot;&gt;Siphon Website&lt;/a&gt;&lt;br&gt;
&lt;a rel=&quot;nofollow&quot; href=&quot;https://github.com/blackdwarftech/siphon&quot;&gt;GitHub code&lt;/a&gt;&lt;/p&gt;
</description>
<category>Articles</category>
<guid isPermaLink="true">https://coderlegion.com/16611/we-finally-broke-the-500ms-latency-barrier-for-ai-phone-calls</guid>
<pubDate>Mon, 04 May 2026 08:35:00 +0000</pubDate>
</item>
<item>
<title>Build for AI cold caller for outbound. Owners cant tell its a bot</title>
<link>https://coderlegion.com/15814/build-for-ai-cold-caller-for-outbound-owners-cant-tell-its-a-bot</link>
<description>&lt;p&gt;I spent 3-4 weeks building an AI voice agent that cold-calls HVAC owners for me. Real outbound. Real objection handling. Real appointments booked. When we listen back through the recordings, the owners never clock it as AI — they just think its a human SDR with a slightly weird cadence.&lt;/p&gt;
&lt;p&gt;This is the build, and the honest reason its sitting on the shelf for high-volume right now.&lt;/p&gt;
&lt;p&gt;The stack&lt;br&gt;
Make.com runs the whole thing — seven scenarios wired around a single Google Sheet called NeverMiss – Outbound Calls that acts as the CRM.&lt;/p&gt;
&lt;p&gt;dialler — every 5 minutes, pulls one row where status=new, enabled=TRUE, attempts&amp;lt;3, and fires a call into Vapi&lt;br&gt;
Logger — webhook from Vapi after every call. Writes transcript, recording, outcome back. Uses an OpenAI module to classify the transcript into structured outcomes&lt;br&gt;
Watch Dog — every 10 minutes, catches rows where the call went out but the Logger webhook never fired (Vapi had a bad minute), flips them to logger-missed for retry&lt;br&gt;
Reconciler — sweeps stuck rows, enforces attempt caps, handles edge cases&lt;br&gt;
recording sync — pulls MP3s out of Vapi before the 30-day retention wipes them, stores in Drive&lt;br&gt;
Booking Handler — when the agent closes a booking mid-call, writes the calendar event and fires a confirmation&lt;br&gt;
CallBack Dialer — separate path for inbound callback requests (form-fill → call within 60 seconds)&lt;br&gt;
One Vapi agent on the voice side. Four Twilio numbers rotating for caller ID reputation. ElevenLabs for the actual voice. The complexity isnt in any one piece — its in how tightly theyre wired so nothing quietly breaks.&lt;/p&gt;
&lt;p&gt;The Sheet is the CRM, with row locks&lt;br&gt;
The Sheet has columns you would expect: business_name, phone_e164, status, call_id, recording_url, email, last_called_at, attempts, notes.&lt;/p&gt;
&lt;p&gt;And some you might not: lead_uid (UUID, stable key), lock_token + lock_expires_at, next_callable_at, logger_ran_at.&lt;/p&gt;
&lt;p&gt;The lock columns are the interesting part. Before the dialler fires a call, it writes a lock token and an expiry (lock_expires_at = now + 10 min). Thats the contract — if any other scenario or retry sees a row with a live lock, it skips it. If the lock is stale (expired), the row is free for reclaim.&lt;/p&gt;
&lt;p&gt;Stops the Watch Dog from re-queueing a row thats actively being called. Stops two dialler runs from racing the same lead. Stops weird double-call bugs.&lt;/p&gt;
&lt;p&gt;This is the kind of thing you dont need until volume hits, and then you really need it.&lt;/p&gt;
&lt;p&gt;How it sounds like a human&lt;br&gt;
Most AI voice builds fail on two things: the voice itself, and the gap between the human finishing their sentence and the agent replying. Both telegraph &quot;robot&quot; immediately.&lt;/p&gt;
&lt;p&gt;For voice, ElevenLabs inside Vapi, cloned from a real sample. Tested OpenAI, Deepgram, PlayHT — ElevenLabs still wins on natural breath patterns and micro-pauses.&lt;/p&gt;
&lt;p&gt;For latency, Vapis tunable VAD and smart endpointing, tuned so the gap between you finishing and the agent replying sits right where a human would land. Too low, it interrupts. Too high, the silence tells on it.&lt;/p&gt;
&lt;p&gt;The system prompt is about 1,100 words. The agents named Alex. Rules include:&lt;/p&gt;
&lt;p&gt;Never read the prospect back to themselves&lt;br&gt;
Use natural fillers&lt;br&gt;
If asked &quot;is this a robot&quot; — be honest&lt;br&gt;
If asked for pricing — give a range and offer to send email details&lt;br&gt;
If told to stop calling — confirm and end gracefully&lt;br&gt;
Specific objections each get short inline responses that flip to a question. Nothing read aloud — everything handled as conversation.&lt;/p&gt;
&lt;p&gt;The agent can also call two tools mid-call:&lt;/p&gt;
&lt;p&gt;book_appointment — triggers the Booking Handler scenario which writes to Calendar and emails the confirm&lt;br&gt;
capture_email — writes to the Sheet, kicks off a follow-up sequence&lt;br&gt;
When those tools fire, the agent pauses briefly, gets the response, reads the confirmation back. No human in the loop on a successful call.&lt;/p&gt;
&lt;p&gt;The glue — Logger, Watch Dog, recording sync&lt;br&gt;
This is the boring but critical part.&lt;/p&gt;
&lt;p&gt;Logger&lt;br&gt;
Every Vapi call ends with a webhook hitting a Make scenario. The payload has the call ID, transcript, recording URL, end reason, and a Vapi-generated summary. The Logger finds the matching Sheet row by lead_uid, then runs the transcript through OpenAI to classify outcome into my taxonomy:&lt;/p&gt;
&lt;p&gt;booked&lt;br&gt;
email_captured&lt;br&gt;
voicemail&lt;br&gt;
no_answer&lt;br&gt;
do_not_call&lt;br&gt;
no_interest&lt;br&gt;
callback_requested&lt;br&gt;
Writes everything back, fires downstream actions — calendar events, DNC flags, re-queue for voicemails.&lt;/p&gt;
&lt;p&gt;Watch Dog&lt;br&gt;
Vapi sometimes fails to fire the post-call webhook. Without a watchdog, those rows sit silently in dialing status forever while you think everything is fine.&lt;/p&gt;
&lt;p&gt;Mine runs every 10 minutes, finds rows with a last_called_at older than 5 minutes but logger_ran_at still empty, and flips status to logger-missed so the dialler picks them up again. Also clears stale lock tokens.&lt;/p&gt;
&lt;p&gt;Recording sync&lt;br&gt;
Vapi deletes recordings after 30 days. I want them forever — to retrain the prompt, spot objection patterns, audit outcomes. So a Make scenario runs every 4 hours, pulls the MP3, uploads to a Drive folder named &lt;em&gt;&lt;/em&gt;.mp3, writes the Drive URL back, flips a synced flag.&lt;/p&gt;
&lt;p&gt;Owners cant tell its AI — actual numbers&lt;br&gt;
The recording sync is how I proved this instead of just claiming it.&lt;/p&gt;
&lt;p&gt;After 200+ connected calls, I tagged every recording: did the prospect ever ask &quot;is this a bot?&quot;, and did they ever seem confused?&lt;/p&gt;
&lt;p&gt;11 out of 200 asked if it was AI. Thats 5.5%.&lt;/p&gt;
&lt;p&gt;And most of the 11 asked after Alex had already booked a callback or captured their email — curiosity, not suspicion.&lt;/p&gt;
&lt;p&gt;The other 94.5% just had a normal conversation. Successful bookings averaged 3 min 40 sec — identical to a human SDR doing the same call, meaning prospects werent shortcutting it because they smelled a robot.&lt;/p&gt;
&lt;p&gt;Id share clips but theyre real owners voices without opt-in. Trust the data.&lt;/p&gt;
&lt;p&gt;Why Ive parked it for volume&lt;br&gt;
Heres the uncomfortable part.&lt;/p&gt;
&lt;p&gt;Most HVAC numbers on public directories arent direct owner lines. Theyre main business lines routing through:&lt;/p&gt;
&lt;p&gt;An IVR (&quot;press 1 for service, 2 for billing&quot;)&lt;br&gt;
A call center&lt;br&gt;
A front-desk receptionist whose actual job is keeping people like me away from the owner&lt;br&gt;
Current voice AI is still bad at IVRs. Vapi, Retell, Bland — all of them. The agent hears &quot;press 1 for service&quot; and either sits silent until the menu times out, or tries to talk to a recording.&lt;/p&gt;
&lt;p&gt;Human gatekeepers are a coin flip — warm ones might put you through, suspicious ones kill the call with one question the agent cant answer.&lt;/p&gt;
&lt;p&gt;Until voice AI gets genuinely good at navigating phone trees — pressing digits intelligently, detecting robot-vs-human, adjusting mid-call — high-volume outbound to public numbers burns money for 10-15% owner connection rates.&lt;/p&gt;
&lt;p&gt;So Ive paused it. Not dead. Paused. When the models catch up, its right back on.&lt;/p&gt;
&lt;p&gt;Why it still works&lt;br&gt;
If youve got direct owner mobile numbers, this system is a weapon.&lt;/p&gt;
&lt;p&gt;MetricNumber&lt;br&gt;
Connection rate (direct mobiles)40-55%&lt;br&gt;
Book rate (on connected calls)8-14%&lt;br&gt;
All-in cost per connected minute~$0.18&lt;br&gt;
Thats cold-outbound economics that actually pencil.&lt;/p&gt;
&lt;p&gt;Where direct mobiles come from ethically:&lt;/p&gt;
&lt;p&gt;LinkedIn scraping through Apollo / Clay / Wiza&lt;br&gt;
Network-sourced lists&lt;br&gt;
Trade show attendees&lt;br&gt;
Re-engagement on your own past leads&lt;br&gt;
Also works brilliantly for inbound callback — form-fill, Alex calls within 60 seconds, qualifies, books. Running that in production right now. Book rates are silly.&lt;/p&gt;
&lt;p&gt;What Im building instead&lt;/p&gt;
&lt;p&gt;Inbound. AI receptionists catching the calls HVAC owners are already missing nights, weekends, summer peak.&lt;/p&gt;
&lt;p&gt;Same agent pattern, flipped direction, better unit economics, 100% connection rate (theyre the ones calling you).&lt;/p&gt;
&lt;p&gt;Thats what NeverMiss is now. If you run HVAC, plumbing, or roofing and want to hear what a modern AI receptionist sounds like when the call lands at 9:47pm on a Saturday — nevermisshq.com has the live demo.&lt;/p&gt;
&lt;p&gt;And when voice AI finally cracks IVR? The dialler comes right off the shelf.&lt;/p&gt;
&lt;p&gt;Happy to answer build questions in the comments.&lt;/p&gt;
&lt;p&gt;Rayhan Mahmood runs NeverMiss AI automation for US home service businesses.&lt;/p&gt;
</description>
<category>Articles</category>
<guid isPermaLink="true">https://coderlegion.com/15814/build-for-ai-cold-caller-for-outbound-owners-cant-tell-its-a-bot</guid>
<pubDate>Sat, 25 Apr 2026 17:43:23 +0000</pubDate>
</item>
<item>
<title>Build a 24/7 AI Receptionist in 15 Mins (Python + Google Calendar)</title>
<link>https://coderlegion.com/10873/build-a-24-7-ai-receptionist-in-15-mins-python-google-calendar</link>
<description>&lt;p&gt;Voice AI demos are cool — but most fail at one critical thing: &lt;strong&gt;doing real work&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;Today, I’m sharing how to build a &lt;strong&gt;production-ready AI Dental Clinic Receptionist&lt;/strong&gt; that can &lt;strong&gt;check a real Google Calendar and book appointments over the phone&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;We’ll use &lt;strong&gt;SIPHON&lt;/strong&gt;, an open-source Python framework, to build this with just a few lines of logic.&lt;/p&gt;
&lt;hr&gt;
&lt;h3 id=&quot;what-this-agent-can-do&quot;&gt;What This Agent Can Do&lt;/h3&gt;
&lt;p&gt;This tutorial walks you through building a voice agent that:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Books new appointments&lt;/strong&gt; using Google Calendar&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Modifies existing appointments&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Cancels appointments&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Verifies caller identity&lt;/strong&gt; for privacy&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Runs 24/7&lt;/strong&gt; with no human intervention&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;⏱ Time to build:&lt;/strong&gt; ~15 minutes&lt;/p&gt;
&lt;hr&gt;
&lt;h3 id=&quot;architecture-flow&quot;&gt;Architecture Flow&lt;/h3&gt;
&lt;p&gt;&lt;img src=&quot;https://coderlegion.com/?qa=blob&amp;amp;qa_blobid=867787316558118998&quot; alt=&quot;Siphon google calendar flow&quot;&gt;&lt;/p&gt;
&lt;hr&gt;
&lt;h3 id=&quot;prerequisites&quot;&gt;Prerequisites&lt;/h3&gt;
&lt;p&gt;Before you start, make sure you have:&lt;/p&gt;
&lt;h4 id=&quot;system-requirements&quot;&gt;System Requirements&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Python 3.8+&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h4 id=&quot;install-siphon&quot;&gt;Install SIPHON&lt;/h4&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;pip install siphon-ai
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt; &lt;a rel=&quot;nofollow&quot; href=&quot;https://siphon.blackdwarf.in/docs/overview/getting-started&quot;&gt;Getting Started Guide&lt;/a&gt;&lt;/p&gt;
&lt;h4 id=&quot;api-keys&quot;&gt;API Keys&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;OpenRouter API Key&lt;/strong&gt; (LLM)&lt;br&gt;
 &lt;a rel=&quot;nofollow&quot; href=&quot;https://openrouter.ai/&quot;&gt;https://openrouter.ai/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Sarvam or Cartesia API Key&lt;/strong&gt; (STT / TTS)&lt;br&gt;
 &lt;a rel=&quot;nofollow&quot; href=&quot;https://siphon.blackdwarf.in/docs/plugins/tts/overview&quot;&gt;https://siphon.blackdwarf.in/docs/plugins/tts/overview&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h4 id=&quot;services&quot;&gt;Services&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;LiveKit credentials&lt;/strong&gt; (Cloud or self-hosted)&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Google Calendar&lt;/strong&gt; with Service Account&lt;br&gt;
 &lt;a rel=&quot;nofollow&quot; href=&quot;https://github.com/blackdwarftech/siphon/blob/main/examples/Dental_Clinic_Receptionist/CALENDAR_SETUP.md&quot;&gt;Calendar Setup Guide&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;hr&gt;
&lt;h3 id=&quot;helpful-documentation&quot;&gt;Helpful Documentation&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a rel=&quot;nofollow&quot; href=&quot;https://siphon.blackdwarf.in/docs/plugins/llm/overview&quot;&gt;LLM Plugins&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a rel=&quot;nofollow&quot; href=&quot;https://siphon.blackdwarf.in/docs/plugins/tts/overview&quot;&gt;TTS Plugins&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a rel=&quot;nofollow&quot; href=&quot;https://siphon.blackdwarf.in/docs/plugins/stt/overview&quot;&gt;STT Plugins&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;⚙️ &lt;a rel=&quot;nofollow&quot; href=&quot;https://siphon.blackdwarf.in/docs/agents/configuration&quot;&gt;Agent Configuration&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a rel=&quot;nofollow&quot; href=&quot;https://siphon.blackdwarf.in/docs/agents/call-data&quot;&gt;Call Data &amp;amp; Observability&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;hr&gt;
&lt;h3 id=&quot;quick-start&quot;&gt;Quick Start&lt;/h3&gt;
&lt;h4 id=&quot;step-1-create-project-structure&quot;&gt;Step 1: Create Project Structure&lt;/h4&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;mkdir dental-clinic-receptionist
cd dental-clinic-receptionist
touch .env prompt.py agent.py inbound.py outbound.py
&lt;/code&gt;&lt;/pre&gt;
&lt;hr&gt;
&lt;h4 id=&quot;step-2-configure-environment-variables&quot;&gt;Step 2: Configure Environment Variables&lt;/h4&gt;
&lt;p&gt;Edit &lt;code&gt;.env&lt;/code&gt;:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-env&quot;&gt;OPENROUTER_API_KEY=your_key   # LLM Provider

SARVAM_API_KEY=your_key       # STT Provider
CARTESIA_API_KEY=your_key     # TTS Provider

LIVEKIT_URL=wss://your-livekit-url
LIVEKIT_API_KEY=your_key
LIVEKIT_API_SECRET=your_secret

GOOGLE_CALENDAR_ID=*Emails are not allowed*
GOOGLE_CALENDAR_CREDENTIALS_PATH=/path/to/credentials.json

CALL_RECORDING=false
SAVE_METADATA=true
SAVE_TRANSCRIPTION=true

METADATA_LOCATION=Call_Metadata
TRANSCRIPTION_LOCATION=Transcriptions

AWS_S3_ENDPOINT=http://localhost:9000
AWS_S3_ACCESS_KEY_ID=minioadmin
AWS_S3_SECRET_ACCESS_KEY=minioadmin
AWS_S3_BUCKET=siphon
AWS_S3_REGION=us-east-1
AWS_S3_FORCE_PATH_STYLE=true
&lt;/code&gt;&lt;/pre&gt;
&lt;hr&gt;
&lt;h4 id=&quot;step-3-define-the-system-prompt&quot;&gt;Step 3: Define the System Prompt&lt;/h4&gt;
&lt;p&gt;Create &lt;code&gt;prompt.py&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;The system prompt controls &lt;strong&gt;behavior, privacy, and conversation flow&lt;/strong&gt;.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-python&quot;&gt;system_instructions = &quot;&quot;&quot;
You are a professional dental clinic receptionist.

CAPABILITIES
- Book new appointments
- Modify existing appointments
- Cancel appointments

PRIVACY RULES
- ALWAYS verify caller identity (name + phone)
- Only show appointments for the verified caller

CONVERSATION STYLE
- Be warm and professional
- Ask one question at a time
- Confirm details by reading them back
&quot;&quot;&quot;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt; &lt;a rel=&quot;nofollow&quot; href=&quot;https://github.com/blackdwarftech/siphon/blob/main/examples/Dental_Clinic_Receptionist/prompt.py&quot;&gt;Full Prompt Example&lt;/a&gt;&lt;/p&gt;
&lt;hr&gt;
&lt;h4 id=&quot;step-4-create-the-agent&quot;&gt;Step 4: Create the Agent&lt;/h4&gt;
&lt;p&gt;Create &lt;code&gt;agent.py&lt;/code&gt;:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-python&quot;&gt;from siphon.agent import Agent
from siphon.plugins import openrouter, sarvam, cartesia
from prompt import system_instructions
from dotenv import load_dotenv

load_dotenv()

llm = openrouter.LLM()
tts = cartesia.TTS()
stt = sarvam.STT()

agent = Agent(
    agent_name=&quot;Dental-Clinic-Receptionist&quot;,
    llm=llm,
    tts=tts,
    stt=stt,
    system_instructions=system_instructions,
    google_calendar=True
)

if __name__ == &quot;__main__&quot;:
    # agent.download_files()  # Run once on fresh machines
    agent.dev()               # Local development
    # agent.start()           # Production
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt; &lt;a rel=&quot;nofollow&quot; href=&quot;https://siphon.blackdwarf.in/docs/agents/overview&quot;&gt;Agent Overview&lt;/a&gt;&lt;/p&gt;
&lt;hr&gt;
&lt;h4 id=&quot;step-5-enable-inbound-calls&quot;&gt;Step 5: Enable Inbound Calls&lt;/h4&gt;
&lt;p&gt;Create &lt;code&gt;inbound.py&lt;/code&gt;:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-python&quot;&gt;from siphon.telephony.inbound import Dispatch
from dotenv import load_dotenv

load_dotenv()

dispatch = Dispatch(
    agent_name=&quot;Dental-Clinic-Receptionist&quot;,
    dispatch_name=&quot;inbound-Dental-Clinic-Receptionist&quot;,
    sip_number=&quot;&quot;  # Provided by your SIP provider
)

result = dispatch.agent()
print(result)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Run:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;python inbound.py
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt; &lt;a rel=&quot;nofollow&quot; href=&quot;https://siphon.blackdwarf.in/docs/calling/inbound/overview&quot;&gt;Inbound Calling Guide&lt;/a&gt;&lt;/p&gt;
&lt;hr&gt;
&lt;h4 id=&quot;step-6-outbound-calls-optional-&quot;&gt;Step 6: Outbound Calls (Optional)&lt;/h4&gt;
&lt;p&gt;Use outbound calls for reminders or follow-ups.&lt;/p&gt;
&lt;p&gt;Create &lt;code&gt;outbound.py&lt;/code&gt;:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-python&quot;&gt;from siphon.telephony import Call
from dotenv import load_dotenv

load_dotenv()

call = Call(
    agent_name=&quot;Dental-Clinic-Receptionist&quot;,
    sip_trunk_setup={
        &quot;name&quot;: &quot;Dental-Clinic-Receptionist&quot;,
        &quot;sip_address&quot;: &quot;&quot;,
        &quot;sip_number&quot;: &quot;&quot;,
        &quot;sip_username&quot;: &quot;&quot;,
        &quot;sip_password&quot;: &quot;&quot;
    },
    number_to_call=&quot;&quot;
)

result = call.start()
print(result)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Run:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;python outbound.py
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt; &lt;a rel=&quot;nofollow&quot; href=&quot;https://siphon.blackdwarf.in/docs/calling/outbound/overview&quot;&gt;Outbound Calling Guide&lt;/a&gt;&lt;/p&gt;
&lt;hr&gt;
&lt;h4 id=&quot;step-7-start-the-agent&quot;&gt;Step 7: Start the Agent&lt;/h4&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;python agent.py
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Your AI receptionist is now live &lt;/p&gt;
&lt;hr&gt;
&lt;h3 id=&quot;production-scaling&quot;&gt;Production Scaling&lt;/h3&gt;
&lt;p&gt;SIPHON supports &lt;strong&gt;horizontal scaling&lt;/strong&gt; out of the box.&lt;/p&gt;
&lt;p&gt;Just run multiple agent instances, and calls are automatically distributed.&lt;/p&gt;
&lt;p&gt; &lt;a rel=&quot;nofollow&quot; href=&quot;https://siphon.blackdwarf.in/docs/concepts/scaling&quot;&gt;Scaling Guide&lt;/a&gt;&lt;/p&gt;
&lt;hr&gt;
&lt;h3 id=&quot;what-this-looks-like-in-practice&quot;&gt;What This Looks Like in Practice&lt;/h3&gt;
&lt;h4 id=&quot;booking-an-appointment&quot;&gt;Booking an Appointment&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;Caller: &lt;em&gt;“I need a cleaning next Tuesday at 2 PM”&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;Agent verifies name + phone&lt;/li&gt;
&lt;li&gt;Checks Google Calendar&lt;/li&gt;
&lt;li&gt;Books and confirms&lt;/li&gt;
&lt;/ul&gt;
&lt;h4 id=&quot;-modifying-an-appointment&quot;&gt;✏️ Modifying an Appointment&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;Caller requests a change&lt;/li&gt;
&lt;li&gt;Agent verifies identity&lt;/li&gt;
&lt;li&gt;Shows &lt;strong&gt;only their appointments&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Reschedules and confirms&lt;/li&gt;
&lt;/ul&gt;
&lt;h4 id=&quot;-cancelling-an-appointment&quot;&gt;❌ Cancelling an Appointment&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;Agent verifies identity&lt;/li&gt;
&lt;li&gt;Confirms appointment&lt;/li&gt;
&lt;li&gt;Cancels and acknowledges&lt;/li&gt;
&lt;/ul&gt;
&lt;h4 id=&quot;privacy-by-design&quot;&gt;Privacy by Design&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;Identity verification required&lt;/li&gt;
&lt;li&gt;No cross-patient data exposure&lt;/li&gt;
&lt;/ul&gt;
&lt;hr&gt;
&lt;h3 id=&quot;resources&quot;&gt;Resources&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a rel=&quot;nofollow&quot; href=&quot;https://github.com/blackdwarftech/siphon/tree/main/examples/Dental_Clinic_Receptionist&quot;&gt;Complete Example Code&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a rel=&quot;nofollow&quot; href=&quot;https://github.com/blackdwarftech/siphon/blob/main/examples/Dental_Clinic_Receptionist/CALENDAR_SETUP.md&quot;&gt;Google Calendar Setup&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a rel=&quot;nofollow&quot; href=&quot;https://siphon.blackdwarf.in/docs/overview/introduction&quot;&gt;SIPHON Documentation&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;hr&gt;
&lt;p&gt;⭐ &lt;strong&gt;Found this useful?&lt;/strong&gt;&lt;br&gt;
Give SIPHON a star on GitHub → &lt;a rel=&quot;nofollow&quot; href=&quot;https://github.com/blackdwarftech/siphon&quot;&gt;https://github.com/blackdwarftech/siphon&lt;/a&gt;&lt;/p&gt;
</description>
<category>Tutorials</category>
<guid isPermaLink="true">https://coderlegion.com/10873/build-a-24-7-ai-receptionist-in-15-mins-python-google-calendar</guid>
<pubDate>Sun, 01 Feb 2026 13:08:38 +0000</pubDate>
</item>
<item>
<title>Build A Real-Time Voice Assistant with Mistral and FastRTC</title>
<link>https://coderlegion.com/4047/build-a-real-time-voice-assistant-with-mistral-and-fastrtc</link>
<description>&lt;p&gt;&lt;img src=&quot;https://coderlegion.com/?qa=blob&amp;amp;qa_blobid=7335495914467226737&quot; alt=&quot;&quot;&gt;&lt;/p&gt;
&lt;p&gt;In this post, I will demonstrate how to build a real-time voice assistant using Mistral AI and FastRTC.&lt;/p&gt;
&lt;p&gt;&lt;a rel=&quot;nofollow&quot; href=&quot;https://mistral.ai/&quot;&gt;Mistral AI&lt;/a&gt; is one of the leading LLM providers, and they have made their LLM API easily accessible to developers.&lt;/p&gt;
&lt;p&gt;&lt;a rel=&quot;nofollow&quot; href=&quot;https://fastrtc.org/&quot;&gt;FastRTC&lt;/a&gt;, on the other hand, is a real-time communication library for Python that enables you to quickly turn any Python function into real-time audio and video stream over WebRTC or WebSockets.&lt;/p&gt;
&lt;h3 id=&quot;building-a-real-time-voice-assistant&quot;&gt;&lt;strong&gt;Building A Real-time Voice Assistant&lt;/strong&gt;&lt;/h3&gt;
&lt;p&gt;First, let's install the required libraries by running the code below in your terminal&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;pip install mistalai fastrtc
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Next, set an environment variable and import the libraries. Create a &lt;code&gt;.env&lt;/code&gt; file in your project and save your Mistral API key there&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;MISTRAL_API_KEY = &quot;&amp;lt;your-api-key&amp;gt;&quot;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Import the libraries&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;from mistralai import Mistral
from fastrtc import (ReplyOnPause, Stream, get_stt_model, get_tts_model)
from dotenv import load_dotenv
import os

load_dotenv()
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;To get your Mistral API key, you will need to create an account on their &lt;a rel=&quot;nofollow&quot; href=&quot;https://admin.mistral.ai/organization/api-keys&quot;&gt;website&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;In the above, we have imported Mistral and the specific methods that we need from FastRTC namely &lt;code&gt;ReplyOnPause()&lt;/code&gt;, &lt;code&gt;Stream()&lt;/code&gt;, &lt;code&gt;get_stt_model()&lt;/code&gt;, and &lt;code&gt;get_tts_model()&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;ReplyOnPause()&lt;/code&gt;: This method takes a Python audio function. It monitors the audio, and when it detects a pause, it takes it as a cue to give a reply.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;Stream()&lt;/code&gt;: This method streams the audio reply.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;get_stt_model()&lt;/code&gt;: This is used to access the speech-to-text model that is used to convert audio to text.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;get_tts_model()&lt;/code&gt;: This is used to access the text-to-speech model that is used to convert text back into audio.&lt;/p&gt;
&lt;p&gt;Now, let's activate the Mistral client with our API key stored in the &lt;code&gt;.env&lt;/code&gt; file&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;api_key = os.environ[&quot;MISTRAL_API_KEY&quot;]
model = &quot;mistral-large-latest&quot;

client = Mistral(api_key=api_key)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Here we are using Mistral large model. However, you can try out other Mistral models too. Additionally, you can actually plug any LLM into FastRTC and receive real-time voice responses.&lt;/p&gt;
&lt;p&gt;We will now build the audio function that will take a prompt and return a response&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;stt_model = get_stt_model()
tts_model = get_tts_model()


def echo(audio):
    prompt = stt_model.stt(audio)
    chat_response = client.chat.complete(
    model = model,
    messages = [
        {
            &quot;role&quot;: &quot;user&quot;,
            &quot;content&quot;: f&quot;{prompt}&quot;
        },
      ]
    )

    for audio_chunk in tts_model.stream_tts_sync(chat_response.choices[0].message.content):
        yield audio_chunk
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Above, we wrote a function called &lt;code&gt;echo&lt;/code&gt;, and the function takes an audio input, then passes that to the speech-to-text method, which is converted to a user prompt and given to the LLM. The response from the LLM is then passed to a text-to-speech method and is streamed synchronously.&lt;/p&gt;
&lt;p&gt;Finally, we will run the application&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;stream = Stream(ReplyOnPause(echo), modality=&quot;audio&quot;, mode=&quot;send-receive&quot;)
stream.ui.launch() 
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This will launch the UI below at the URL: &lt;code&gt;http://127.0.0.1:7860/&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://coderlegion.com/?qa=blob&amp;amp;qa_blobid=3898391398304302750&quot; alt=&quot;&quot;&gt;&lt;/p&gt;
&lt;p&gt;Now, you can activate the microphone and say something to your assistant, who will give you a reply immediately.&lt;/p&gt;
&lt;h3 id=&quot;change-voice&quot;&gt;&lt;strong&gt;Change Voice&lt;/strong&gt;&lt;/h3&gt;
&lt;p&gt;If you do not like the default voice, you can change that by passing an instance of &lt;code&gt;KokoroTTSOptions()&lt;/code&gt; to the text-to-speech method.&lt;/p&gt;
&lt;p&gt;First import &lt;code&gt;KokoroTTSOptions()&lt;/code&gt; from FastRTC by adding it to the import tuple&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;from fastrtc import (ReplyOnPause, Stream, get_stt_model, get_tts_model, KokoroTTSOptions)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Next, define the options&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;tts_model = get_tts_model(model=&quot;kokoro&quot;)

options = KokoroTTSOptions(
    voice=&quot;af_bella&quot;,
    speed=1.0,
    lang=&quot;en-us&quot;
)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Then pass the options to the text-to-speech method in your audio function&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;for audio_chunk in tts_model.stream_tts_sync(chat_response.choices[0].message.content, options = options)
        yield audio_chunk
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;For more voice options, you can check out &lt;a rel=&quot;nofollow&quot; href=&quot;https://huggingface.co/hexgrad/Kokoro-82M/blob/main/VOICES.md&quot;&gt;KokoroTTS documentation&lt;/a&gt;&lt;/p&gt;
&lt;h3 id=&quot;complete-project-code&quot;&gt;&lt;strong&gt;Complete Project Code&lt;/strong&gt;&lt;/h3&gt;
&lt;p&gt;Here is the complete code that we have used to create the real-time voice assistant&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;import os
from fastrtc import (ReplyOnPause, Stream, get_stt_model, get_tts_model, KokoroTTSOptions)
from dotenv import load_dotenv
from mistralai import Mistral

load_dotenv()

api_key = os.environ[&quot;MISTRAL_API_KEY&quot;]
model = &quot;mistral-large-latest&quot;

client = Mistral(api_key=api_key)

options = KokoroTTSOptions(
    voice=&quot;af_bella&quot;,
    speed=1.0,
    lang=&quot;en-us&quot;
)

stt_model = get_stt_model()
tts_model = get_tts_model(model=&quot;kokoro&quot;)

def echo(audio):
    prompt = stt_model.stt(audio)
    chat_response = client.chat.complete(
    model = model,
    messages = [

        {
            &quot;role&quot;: &quot;user&quot;,
            &quot;content&quot;: f&quot;{prompt}&quot;
        },
      ]
    )

    for audio_chunk in tts_model.stream_tts_sync(chat_response.choices[0].message.content, options=options):
        yield audio_chunk

if__name__==&quot;__main__&quot;:
       stream = Stream(ReplyOnPause(echo), modality=&quot;audio&quot;, mode=&quot;send-receive&quot;)
       stream.ui.launch()
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Now, instead of typing a prompt, you can give voice commands to an LLM and have it speak its response, just like a natural human conversation.&lt;/p&gt;
&lt;p&gt;I hope you found this post useful. If you did, please share it with others; it might benefit them, too. Thanks for reading!&lt;/p&gt;
&lt;p&gt;You can follow me on the following platforms:&lt;/p&gt;
&lt;p&gt;GitHub: &lt;a rel=&quot;nofollow&quot; href=&quot;https://github.com/Ifeanyi55&quot;&gt;Ifeanyi55&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;X: &lt;a rel=&quot;nofollow&quot; href=&quot;https://x.com/Ifeanyidiaye&quot;&gt;iCode2&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;LinkedIn: &lt;a rel=&quot;nofollow&quot; href=&quot;https://www.linkedin.com/in/ifeanyi-idiaye-09523abb/&quot;&gt;Ifeanyi Idiaye&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;You can also visit my website: &lt;a rel=&quot;nofollow&quot; href=&quot;https://ifeanyi-idiaye.netlify.app/&quot;&gt;https://ifeanyi-idiaye.netlify.app/&lt;/a&gt;&lt;/p&gt;
</description>
<category>Automation</category>
<guid isPermaLink="true">https://coderlegion.com/4047/build-a-real-time-voice-assistant-with-mistral-and-fastrtc</guid>
<pubDate>Tue, 15 Jul 2025 19:34:36 +0000</pubDate>
</item>
<item>
<title>Build A Real-Time Voice Assistant with Mistral AI and FastRTC</title>
<link>https://coderlegion.com/1548/build-a-real-time-voice-assistant-with-mistral-ai-and-fastrtc</link>
<description>&lt;p&gt;&lt;img src=&quot;https://coderlegion.com/?qa=blob&amp;amp;qa_blobid=4434151775262072449&quot; alt=&quot;A robot assistant sitting at a desk&quot;&gt;&lt;/p&gt;
&lt;p&gt;In this post, I will show you how to build a real-time voice assistant with Mistral AI and FastRTC.&lt;/p&gt;
&lt;p&gt;&lt;a rel=&quot;nofollow&quot; href=&quot;https://mistral.ai/&quot;&gt;Mistral AI&lt;/a&gt; is one of the leading LLM providers out there, and they have made their LLM API easily accessible to developers.&lt;/p&gt;
&lt;p&gt;&lt;a rel=&quot;nofollow&quot; href=&quot;https://fastrtc.org/&quot;&gt;FastRTC&lt;/a&gt;, on the other hand, is a real-time communication library for Python that enables you to quickly turn any Python function into real-time audio and video stream over WebRTC or WebSockets.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Building A Real-time Voice Assistant&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;First, let's install the required libraries by running the code below in your terminal&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;pip install mistalai fastrtc
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Next, set an environment variable and import the libraries. Create a &lt;code&gt;.env&lt;/code&gt; file in your project and save your Mistral API key there&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;MISTRAL_API_KEY = &quot;&amp;lt;your-api-key&amp;gt;&quot;

&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Import the libraries&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;from mistralai import Mistral
from fastrtc import (ReplyOnPause, Stream, get_stt_model, get_tts_model)
from dotenv import load_dotenv
import os

load_dotenv()
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;To get your Mistral API key, you will need to create an account on their &lt;a rel=&quot;nofollow&quot; href=&quot;https://console.mistral.ai/home&quot;&gt;website&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;In the above, we have imported Mistral and the specific methods that we need from FastRTC namely &lt;code&gt;ReplyOnPause()&lt;/code&gt;, &lt;code&gt;Stream()&lt;/code&gt;, &lt;code&gt;get_stt_model()&lt;/code&gt;, and &lt;code&gt;get_tts_model()&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;&lt;code&gt;ReplyOnPause()&lt;/code&gt;: This method takes a Python audio function. It monitors the audio, and when it detects a pause, it takes it as a cue to give a reply.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;Stream()&lt;/code&gt;: This method streams the audio reply.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;get_stt_model()&lt;/code&gt;: This is used to access the speech-to-text model that is used to convert audio to text.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;get_tts_model()&lt;/code&gt;: This is used to access the text-to-speech model that is used to convert text back into audio.&lt;/p&gt;
&lt;p&gt;Now, let's activate the Mistral client with our API key stored in the .env file&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;api_key = os.environ[&quot;MISTRAL_API_KEY&quot;]
model = &quot;mistral-large-latest&quot;

client = Mistral(api_key=api_key)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Here we are using Mistral large model. However, you can try out other Mistral models too.&lt;/p&gt;
&lt;p&gt;Also, in actuality, you can plug any LLM into FastRTC and get real-time voice responses.&lt;/p&gt;
&lt;p&gt;We will now build the audio function that will take a prompt and return a response&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;stt_model = get_stt_model()
tts_model = get_tts_model()


def echo(audio):
    prompt = stt_model.stt(audio)
    chat_response = client.chat.complete(
    model = model,
    messages = [
        {
            &quot;role&quot;: &quot;user&quot;,
            &quot;content&quot;: f&quot;{prompt}&quot;
        },
      ]
    )

    for audio_chunk in tts_model.stream_tts_sync(chat_response.choices[0].message.content):
        yield audio_chunk
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Above, we wrote a function called echo, and the function takes an audio input, then passes that to the speech-to-text method, which is converted to a user prompt and given to the LLM. The response from the LLM is then passed to a text-to-speech method and is streamed synchronously.&lt;/p&gt;
&lt;p&gt;Finally, we will run the application&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;if __name__ == &quot;__main__&quot;:
         stream = Stream(ReplyOnPause(echo), modality=&quot;audio&quot;, mode=&quot;send-receive&quot;)
         stream.ui.launch() 
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This will launch the UI below at the URL:&lt;code&gt; http://127.0.0.1:7860/&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://coderlegion.com/?qa=blob&amp;amp;qa_blobid=957347199380965435&quot; alt=&quot;&quot;&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Change Voice&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;If you do not like the default voice, you can change that by passing an instance of &lt;code&gt;KokoroTTSOptions()&lt;/code&gt; to the text-to-speech method.&lt;/p&gt;
&lt;p&gt;First import &lt;code&gt;KokoroTTSOptions()&lt;/code&gt; from FastRTC by adding it to the import tuple&lt;/p&gt;
&lt;p&gt;&lt;code&gt;from fastrtc import (ReplyOnPause, Stream, get_stt_model, get_tts_model, KokoroTTSOptions)&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;Next, define the options&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;tts_model = get_tts_model(model=&quot;kokoro&quot;)

options = KokoroTTSOptions(
    voice=&quot;af_bella&quot;,
    speed=1.0,
    lang=&quot;en-us&quot;
)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Then pass the options to the text-to-speech method in your audio function&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;for audio_chunk in tts_model.stream_tts_sync(chat_response.choices[0].message.content, options = options)
        yield audio_chunk
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;For more voice options, you can check out &lt;a rel=&quot;nofollow&quot; href=&quot;https://huggingface.co/hexgrad/Kokoro-82M/blob/main/VOICES.md&quot;&gt;KokoroTTS&lt;/a&gt; documentation.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Complete Project Code&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Here is the complete code that we have used to create the real-time voice assistant&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;import os
from fastrtc import (ReplyOnPause, Stream, get_stt_model, get_tts_model, KokoroTTSOptions)
from dotenv import load_dotenv
from mistralai import Mistral

load_dotenv()

api_key = os.environ[&quot;MISTRAL_API_KEY&quot;]
model = &quot;mistral-large-latest&quot;

client = Mistral(api_key=api_key)

options = KokoroTTSOptions(
    voice=&quot;af_bella&quot;,
    speed=1.0,
    lang=&quot;en-us&quot;
)

stt_model = get_stt_model()
tts_model = get_tts_model(model=&quot;kokoro&quot;)

def echo(audio):
    prompt = stt_model.stt(audio)
    chat_response = client.chat.complete(
    model = model,
    messages = [

        {
            &quot;role&quot;: &quot;user&quot;,
            &quot;content&quot;: f&quot;{prompt}&quot;
        },
      ]
    )

    for audio_chunk in tts_model.stream_tts_sync(chat_response.choices[0].message.content, options=options):
        yield audio_chunk


if __name__== &quot;__main__&quot;:
         stream = Stream(ReplyOnPause(echo), modality=&quot;audio&quot;, mode=&quot;send-receive&quot;)
         stream.ui.launch()
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Now, instead of typing a prompt, you can give voice commands to an LLM and have it speak its response, just like a natural human conversation.&lt;/p&gt;
&lt;p&gt;I hope you found this post useful. If you did, please share it with others it might benefit too. Thanks for reading!&lt;/p&gt;
</description>
<category>Automation</category>
<guid isPermaLink="true">https://coderlegion.com/1548/build-a-real-time-voice-assistant-with-mistral-ai-and-fastrtc</guid>
<pubDate>Mon, 17 Mar 2025 12:58:30 +0000</pubDate>
</item>
</channel>
</rss>