Skip to content

AbdulrahmanMasoud/voice-cli

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🎤 VoiceCLI

VoiceCLI is a command-line tool that listens to your voice, transcribes it, uses a local Ollama LLM to convert the transcription into a safe shell command, and then executes it after confirmation.


🧠 How It Works

  1. Records 5 seconds of audio.
  2. Transcribes it using whisper.cpp.
  3. Sends the transcription to a local Ollama model (like llama3).
  4. Returns a shell command (or # unknown).
  5. Asks for your confirmation.
  6. Executes the command.

🛠️ Requirements

  • Go 1.20+
  • sox (macOS) or arecord (Linux)
  • whisper.cpp built as main
  • Whisper model (e.g. ggml-base.en.bin) in models/
  • Ollama running locally with a pulled model:
    ollama pull llama3

🚀 Run It

go run ./cmd/voicecli

📁 Project Structure

voicecli/
├── cmd/voicecli.go         # CLI entry point
├── internal/
│   ├── audio/              # Records audio from mic
│   │   └── recorder.go
│   ├── whisper/            # Transcribes speech
│   │   └── transcriber.go
│   ├── ollama/             # Sends prompt to local Ollama LLM
│   │   └── client.go
│   └── shell/              # Confirms and executes commands
│       └── executor.go

🛡️ Safety

  • Uses a strict system prompt with Ollama to only return simple bash commands.
  • Asks for user confirmation before running anything.

🧪 Example

🎤 VoiceCLI is listening... (press Ctrl+C to exit)
🗣️  You said: list my files
💻 Generated command: ls -la
⚠️  Do you want to execute this command? [y/N]: y
✅ Done.

📌 TODO

  • Continuous listening mode
  • Better error recovery and retries
  • Add Windows audio support (e.g., WASAPI)
  • Customizable system prompt

💡 Author

Abdulrahman Masoud, [@AbdulrahmanMasoud](

Made with ❤️ using Go, Whisper, and Ollama.

About

VoiceCLI is a command-line tool that listens to your voice, transcribes it, uses a local Ollama LLM to convert the transcription into a safe shell command, and then executes it after confirmation.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors