Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🎙️ voice2code

Talk to your computer. Watch it code.

An AI-powered coding assistant you control entirely with your voice.
Speak a feature, describe a bug, ask for a refactor — voice2code understands and executes it in real time.

Python LangGraph OpenAI License: MIT Open Source


What is voice2code?

voice2code is an open-source, voice-native coding assistant that lets you build software by simply talking. No keyboard. No typing. Just describe what you want — and the AI agent understands your intent, runs the right commands, and writes the code.

Inspired by tools like Cursor and Claude Code, but designed around a conversational, voice-first workflow.

You:  "Create a Python script that reads a CSV and outputs a summary"
AI:   *creates the file, writes the code, runs it, shows you the output*

Features

  • Voice to Code — Speak naturally; the agent translates intent to action
  • Agentic Loop — Powered by LangGraph, the AI reasons over multi-step tasks autonomously
  • Shell Execution — The agent can run real terminal commands on your machine
  • GPT-4.1 Brain — State-of-the-art reasoning for code generation and debugging
  • Extensible Tools — Add your own LangChain tools to expand agent capabilities
  • Minimal Setup — Two files, one .env, and you're running

How It Works

Microphone → Speech Recognition → LangGraph Agent → Tool Execution → Response
  1. SpeechRecognition captures audio from your mic and transcribes it via Google Speech API
  2. The transcript is sent into a LangGraph StateGraph as a user message
  3. The chatbot node (GPT-4.1) decides whether to call a tool or respond directly
  4. If a tool is needed, the tools node executes shell commands on your machine
  5. The result feeds back into the agent until the task is complete

Getting Started

Prerequisites

  • Python 3.9+
  • A microphone connected to your machine
  • An OpenAI API key

1. Clone the repo

git clone https://github.com/your-username/voice2code.git
cd voice2code

2. Create a virtual environment

python3 -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate

3. Install dependencies

pip install -r requirements.txt

macOS users: PyAudio requires PortAudio. Install it first:

brew install portaudio

Linux users:

sudo apt-get install python3-pyaudio portaudio19-dev

4. Set up environment variables

Create a .env file in the project root:

OPENAI_API_KEY=sk-your-key-here

5. Run

python3 main.py

The agent will start listening. Speak your instruction and watch it go.


Usage Examples

Once running, just speak naturally:

You say What happens
"List the files in the current directory" Runs ls, shows output
"Create a folder called my-project" Runs mkdir my-project
"Write a Python script that prints Hello World" Creates and writes the file
"Read the contents of main.py" Runs cat main.py, reads it back
"Refactor that function to use a list comprehension" Modifies the file in place

All generated files are saved in the chat_gpt/ folder by default.


Project Structure

voice2code/
├── main.py           # Entry point — mic loop + agent streaming
├── graph.py          # LangGraph agent: nodes, tools, edges
├── requirements.txt
├── .env              # Your secrets (not committed)
├── docs/
│   ├── context.md    # Project context for the AI assistant
│   └── logs.md       # Session logs
└── chat_gpt/         # AI-generated output files

Extending voice2code

Adding a new tool is straightforward:

# graph.py
from langchain_core.tools import tool

@tool
def read_file(path: str):
    """Reads and returns the contents of a file at the given path."""
    with open(path, "r") as f:
        return f.read()

available_tools = [run_command, read_file]  # add it here

The agent automatically learns to use it from the docstring.


Roadmap

  • Wake word detection ("Hey voice2code...")
  • Multi-file context awareness
  • Voice feedback / text-to-speech responses
  • Web UI / Electron desktop app
  • Plugin system for custom tool packs
  • Support for more LLM providers (Claude, Gemini, local models)

Contributing

Contributions are welcome! Here's how to get started:

  1. Fork the repo
  2. Create a feature branch: git checkout -b feat/your-feature
  3. Commit your changes: git commit -m "feat: add your feature"
  4. Push and open a Pull Request

Please keep PRs focused and include a clear description of the change.


License

MIT — free to use, modify, and distribute. See LICENSE for details.


Built with curiosity and a microphone.
Star the repo if you think talking to your computer should be the future.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages