<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Nidhesh Gomai</title>
    <description>The latest articles on DEV Community by Nidhesh Gomai (@nidheshgomai).</description>
    <link>https://dev.to/nidheshgomai</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3875542%2F44a60ef2-2a73-4dc1-8200-2a9af3121ba7.png</url>
      <title>DEV Community: Nidhesh Gomai</title>
      <link>https://dev.to/nidheshgomai</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/nidheshgomai"/>
    <language>en</language>
    <item>
      <title>Building a Voice-Controlled Local AI Agent (with Streamlit + Ollama)</title>
      <dc:creator>Nidhesh Gomai</dc:creator>
      <pubDate>Sun, 12 Apr 2026 21:34:01 +0000</pubDate>
      <link>https://dev.to/nidheshgomai/building-a-voice-controlled-local-ai-agent-with-streamlit-ollama-2f09</link>
      <guid>https://dev.to/nidheshgomai/building-a-voice-controlled-local-ai-agent-with-streamlit-ollama-2f09</guid>
      <description>&lt;p&gt;🧠 Introduction&lt;/p&gt;

&lt;p&gt;Voice interfaces are becoming a natural way to interact with software. In this project, I built a Voice-Controlled Local AI Agent that can:&lt;/p&gt;

&lt;p&gt;Take audio or text input&lt;br&gt;
Convert speech to text&lt;br&gt;
Detect user intent using a local LLM&lt;br&gt;
Execute actions like file creation, code generation, summarization, and chat&lt;br&gt;
Display everything in a clean web UI&lt;/p&gt;

&lt;p&gt;The entire system runs locally, optimized for a low-end laptop (8GB RAM, CPU only).&lt;/p&gt;

&lt;p&gt;🎯 What the Agent Can Do&lt;/p&gt;

&lt;p&gt;The agent supports four core intents:&lt;/p&gt;

&lt;p&gt;create_file → Generate a new file&lt;br&gt;
write_code → Write/update code in a file&lt;br&gt;
summarize → Summarize input text&lt;br&gt;
chat → General conversation&lt;/p&gt;

&lt;p&gt;It also includes:&lt;/p&gt;

&lt;p&gt;✅ Session memory (history tracking)&lt;br&gt;
✅ Error handling (graceful degradation)&lt;br&gt;
✅ Human-in-the-loop confirmation for file operations&lt;br&gt;
🏗️ System Architecture&lt;/p&gt;

&lt;p&gt;The system follows a simple but powerful pipeline:&lt;/p&gt;

&lt;p&gt;Audio/Text Input → Speech-to-Text → Intent Detection → Tool Execution → UI Display → Memory&lt;br&gt;
Components:&lt;br&gt;
Frontend: Streamlit&lt;br&gt;
STT: Whisper (CPU-based)&lt;br&gt;
LLM: Ollama (phi3)&lt;br&gt;
Execution Layer: Python functions&lt;br&gt;
Memory: Streamlit session state&lt;br&gt;
🛠️ Tech Stack&lt;br&gt;
Python&lt;br&gt;
Streamlit&lt;br&gt;
Ollama (phi3 model)&lt;br&gt;
Whisper (speech-to-text)&lt;br&gt;
⚙️ How It Works&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Audio Input&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Users can either:&lt;/p&gt;

&lt;p&gt;Upload an audio file&lt;br&gt;
Record from microphone&lt;/p&gt;

&lt;p&gt;The audio is transcribed using Whisper.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Intent Detection&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The transcribed text is passed to the local LLM via Ollama.&lt;/p&gt;

&lt;p&gt;A prompt is used to classify the intent into:&lt;/p&gt;

&lt;p&gt;create_file, write_code, summarize, chat&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Tool Execution&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Based on the detected intent:&lt;/p&gt;

&lt;p&gt;File operations: Generate and save files inside an output/ folder&lt;br&gt;
Summarization: Condense long text&lt;br&gt;
Chat: Generate conversational responses&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;UI Display&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The Streamlit UI shows:&lt;/p&gt;

&lt;p&gt;Transcribed text&lt;br&gt;
Detected intent&lt;br&gt;
Action taken&lt;br&gt;
Output result&lt;br&gt;
Session history&lt;br&gt;
⚠️ Challenges &amp;amp; Solutions&lt;br&gt;
🔴 1. Speech-to-Text Accuracy&lt;/p&gt;

&lt;p&gt;Whisper on CPU produced inconsistent results.&lt;/p&gt;

&lt;p&gt;Solution:&lt;br&gt;
Added a manual text input fallback and allowed users to edit transcription.&lt;/p&gt;

&lt;p&gt;🔴 2. API Rate Limits&lt;/p&gt;

&lt;p&gt;Initial attempts using cloud APIs failed due to rate limits.&lt;/p&gt;

&lt;p&gt;Solution:&lt;br&gt;
Switched to Ollama, enabling fully local inference.&lt;/p&gt;

&lt;p&gt;🔴 3. Hardware Constraints&lt;/p&gt;

&lt;p&gt;Running large models on a low-end laptop was slow.&lt;/p&gt;

&lt;p&gt;Solution:&lt;br&gt;
Used phi3, a lightweight model optimized for performance.&lt;/p&gt;

&lt;p&gt;🔴 4. File Safety&lt;/p&gt;

&lt;p&gt;Risk of writing files anywhere on the system.&lt;/p&gt;

&lt;p&gt;Solution:&lt;br&gt;
Restricted all file operations to a dedicated output/ folder.&lt;/p&gt;

&lt;p&gt;🧠 Why Ollama?&lt;/p&gt;

&lt;p&gt;Ollama made it possible to:&lt;/p&gt;

&lt;p&gt;Run LLMs locally&lt;br&gt;
Avoid API costs and limits&lt;br&gt;
Maintain privacy&lt;br&gt;
Keep the system responsive&lt;br&gt;
🔐 Safety Considerations&lt;/p&gt;

&lt;p&gt;To prevent accidental system changes:&lt;/p&gt;

&lt;p&gt;All files are created only inside the output/ directory&lt;br&gt;
File operations require user confirmation&lt;br&gt;
🔮 Future Improvements&lt;br&gt;
Multi-step commands (e.g., “summarize and save to file”)&lt;br&gt;
Better speech recognition&lt;br&gt;
Persistent memory (database)&lt;br&gt;
Voice feedback (text-to-speech)&lt;br&gt;
🏁 Conclusion&lt;/p&gt;

&lt;p&gt;This project demonstrates how a complete AI agent pipeline can be built using local tools. Despite hardware limitations, it delivers:&lt;/p&gt;

&lt;p&gt;Real-time interaction&lt;br&gt;
Multi-intent execution&lt;br&gt;
Clean UI experience&lt;/p&gt;

&lt;p&gt;It highlights the power of combining:&lt;/p&gt;

&lt;p&gt;Speech processing&lt;br&gt;
Language models&lt;br&gt;
System automation&lt;br&gt;
🔗 Links&lt;br&gt;
💻 GitHub Repository: &lt;a href="https://github.com/NidheshGomai/Voice-Controlled-Local-AI-Agent" rel="noopener noreferrer"&gt;https://github.com/NidheshGomai/Voice-Controlled-Local-AI-Agent&lt;/a&gt;&lt;br&gt;
🎥 Demo Video: &lt;a href="https://youtu.be/CI2mNQl-Bh4" rel="noopener noreferrer"&gt;https://youtu.be/CI2mNQl-Bh4&lt;/a&gt;&lt;/p&gt;

</description>
      <category>ai</category>
      <category>programming</category>
      <category>python</category>
    </item>
  </channel>
</rss>
