Skip to content

A simple voice command configuration for 'hands-free' coding (Optimized for Mac & Cursor IDE)

Notifications You must be signed in to change notification settings

willbarksdale/voice-mode-coding

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Voice Mode

A lightweight voice command service that enables hands-free coding by listening for voice commands and simulating keyboard shortcuts. Perfect for use with AI coding assistants like Cursor or with dictation services.

Overview

This tool enables you to control your coding environment with your voice, letting you execute common actions like pressing Enter or accepting code changes (Command+Enter) without touching your keyboard.

  • Simple: Easy to set up and use
  • Lightweight: Minimal resource usage
  • Extensible: Easy to add new commands
  • Compatible: Works with macOS and most code editors

Features

  • Voice-activated keyboard shortcuts
  • Simple terminal-based interface
  • Global command for easy activation
  • Audio feedback for command recognition
  • Works alongside dictation services

Commands

Currently supported voice commands:

  • Say "enter" to press the Enter key
  • Say "run it" or "run that" to press Command+Enter
  • Say "exit" or "stop" to quit the service

Requirements

  • macOS (for sound effects and terminal integration)
  • Python 3.x
  • Required Python packages:
    • speechrecognition - For voice recognition
    • pyautogui - For keyboard simulation
    • pyaudio - For audio input processing
    • pocketsphinx - As fallback recognizer

Note on Windows Compatibility: This tool was developed and tested on macOS. While the core functionality should work on Windows, some features like sound effects and terminal integration may require modifications. Windows-specific contributions are welcome!

Installation

1. Clone the repository

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

2. Install dependencies

# Install PortAudio (required for PyAudio)
brew install portaudio

# Install required Python packages
pip install speechrecognition pyautogui pyaudio pocketsphinx

3. Set up the command alias

# Run the alias setup script
./voice_mode_config/add_alias.sh

# Reload your shell configuration
source ~/.zshrc

Usage

Starting the service

# Using the alias (from anywhere)
voice

# OR from the project directory
./start_voice_commands.sh

# OR from the voice_mode_config directory
cd voice_mode_config
python voice_commander.py

Using with AI coding assistants

The voice command service works especially well with AI coding assistants like Cursor:

  1. Start the voice service in a terminal: voice
  2. Open your AI coding assistant
  3. When the assistant suggests code changes:
    • Say "run it" to accept the changes (triggers Command+Enter)
  4. When you need a new line:
    • Say "enter" to press Enter
  5. Continue coding with voice commands as needed

Using with dictation

When using with dictation services:

  1. Use dictation for writing code
  2. Pause dictation temporarily when you need to use voice commands
  3. Say your command ("enter" or "run it")
  4. Resume dictation

Setting up macOS Dictation

To use this tool effectively with macOS built-in dictation:

  1. Enable dictation:

    • Go to System Preferences > Keyboard > Dictation
    • Turn dictation ON
    • Choose a keyboard shortcut to toggle dictation (default is press Fn key twice)
  2. Configure dictation settings:

    • Go to System Preferences > Accessibility > Voice Control
    • Check "Enable Voice Control"
    • Adjust microphone and language settings as needed
  3. Using together with Voice Mode:

    • Start Voice Mode in a terminal window
    • In your code editor, toggle dictation ON using your keyboard shortcut
    • Dictate your code normally
    • When you need to execute a command, toggle dictation OFF momentarily
    • Say your voice command ("enter" or "run it")
    • Toggle dictation back ON to continue coding

This workflow allows seamless switching between dictating code and executing commands.

Files

  • voice_commander.py - Main Python script that listens for voice commands
  • start_voice_commands.sh - Shell script to start the service
  • test_mic.py - Utility script to test microphone detection
  • add_alias.sh - Script to add the 'voice' command alias

Troubleshooting

If the service doesn't detect your voice:

  1. Run python test_mic.py to test your microphone
  2. Check if your microphone is selected and working in System Preferences
  3. Try adjusting the energy_threshold value in voice_commander.py (lower value = more sensitive)
  4. Make sure you're speaking clearly and at a normal volume

Customization

You can add new commands or modify existing ones by editing the voice_commander.py file:

  1. Add a new function to simulate the desired keyboard shortcut
  2. Add the command to the recognition logic in the listen_for_commands function
  3. Restart the voice service

License

MIT License

Contributing

Contributions are welcome! All pull requests will be reviewed by the repository owner before merging.

  1. Fork the repository
  2. Create your feature branch: git checkout -b feature/amazing-feature
  3. Commit your changes: git commit -m 'Add some amazing feature'
  4. Push to the branch: git push origin feature/amazing-feature
  5. Open a Pull Request

The repository owner will review your changes and provide feedback before merging.


Built by Will Barksdale V ~ Last Updated: June 13, 2025

About

A simple voice command configuration for 'hands-free' coding (Optimized for Mac & Cursor IDE)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published