Skip to main content

English | 简体中文

agent-voice-input

PyPI version Python 3.10+ CI License

Context-aware voice input built specifically for CLI coding agents (Codex, Claude Code, and Antigravity CLI / agy).

Generic OS dictation has no idea what files, symbols, or CLI flags exist in your repository. agent-voice-input automatically locates the active coding agent session in your focused terminal window or pane, pairs fast speech recognition with lightweight refinement grounded in your live dialogue + git status filenames, and fixes homophone identifiers, mixed-language technical terms, and mid-sentence self-corrections before pasting safely into your terminal:

🎙️ What you say casually to your terminal:
   "Check the default max duration seconds in platform w s l dot py, change it from
    three minutes to five minutes—actually wait, make it ten minutes—and run unit tests
    without piping to head"

❌ Generic OS dictation:
   Check the default max duration seconds in platform WSL dot pie, change it from 3 minutes to 5 minutes actually wait make it 10 minutes and run unit tests without piping to head

✅ agent-voice-input (refined against your active Agent session & repo context, pasted without pressing Enter):
   Check the default of max_duration_sec in platform_wsl.py, change it to 10 minutes, and run the unit tests without piping to head.

Verified on Windows Terminal + WSL2 (including Remote Desktop and tmux) and macOS (Ghostty, built-in Terminal.app, and tmux); common third-party macOS terminals (iTerm2, WezTerm, Alacritty, Kitty, Warp, etc.) share baseline window-scoping, child-PTY session discovery, and Cmd+V / tmux paste support (community verification PRs welcome).


Why It Works Better for Coding Agents

  • Grounded in Your Active Agent Session: Automatically resolves the foreground agent session inside your active terminal window, Ghostty split, or tmux pane (zero ~/.tmux.conf changes needed), incrementally extracting recent dialogue and git status paths as context while strictly ignoring background subagents and sibling splits.
  • Provider-Driven Speech + Context Pipeline: Pairs fast dedicated speech-to-text with a resident tool-free codex refiner by default, switches cleanly to any built-in cloud/local API provider, or runs single-hop multimodal audio + context refinement (Gemini / OpenRouter)—just pick a provider and its built-in default model applies automatically.
  • Built for Long & Back-to-Back Dictation: Start a new recording immediately while earlier utterances are still transcribing or refining—utterances queue and paste in FIFO order (joining consecutive focus-drifted clipboard fallbacks with a blank line instead of overwriting); local silence gating and loudness normalization block empty triggers; supports up to 10-minute recordings by default (with a 15s HUD countdown), splits recordings over 3 minutes (180s) at natural pauses for concurrent transcription, alerts immediately if a mic is missing or unplugged, and stashes failed audio for agent-voice-input retry so long thoughts are never lost.
  • Native HiDPI Waveform HUD & Focus-Safe Paste: Non-activating floating capsule on both Windows (Per-Monitor V2 HiDPI) and macOS (Retina AppKit) displays live timer, waveform bars, and stage progress in English or Chinese matching your desktop locale. Locks onto the origin terminal window/split on record start, never auto-presses Enter, and falls back to clipboard if focus moved elsewhere.
  • Zero Extra Python Dependencies: Pure Python >= 3.10 standard library plus host ffmpeg (uses built-in powershell.exe on WSL2; compiles and caches a native mac_shim helper via /usr/bin/swiftc on macOS).

Quick Start

Copy and paste this prompt directly into Codex, Claude Code, or AGY:

Please install and configure agent-voice-input (https://github.com/xiaohuaxi/agent-voice-input) for me:
1. Check python3 (>=3.10) and ffmpeg (plus Xcode Command Line Tools `/usr/bin/swiftc` on macOS), then install via `uv tool install agent-voice-input` (or `pipx` if `uv` is unavailable).
2. Check if an API key is already set in my environment (e.g. DASHSCOPE_API_KEY, OPENROUTER_API_KEY, GEMINI_API_KEY, OPENAI_API_KEY, GROQ_API_KEY); if not, ask which provider I want to use and write it to `~/.config/agent-voice-input/agent-voice-input.env` with chmod 600.
3. If the `codex` CLI is not installed or logged in on this machine, set `[refiner] provider` in `~/.config/agent-voice-input/config.toml` to match my configured API provider (leave `model` unset so built-in defaults apply).
4. Run `agent-voice-input doctor` to verify all checks pass, then start the background daemon with `agent-voice-input start`.

Option 2: Manual Setup in 3 Steps

1. Prerequisites

  • Python >= 3.10
  • ffmpeg: sudo apt install ffmpeg (Ubuntu / WSL2) or brew install ffmpeg (macOS)
  • Xcode Command Line Tools (recommended on macOS): xcode-select --install for /usr/bin/swiftc to compile and cache the native hotkey & HUD helper on first start (falls back to CLI toggle / once if absent).

2. Install

uv tool install agent-voice-input
# Or with pipx: pipx install agent-voice-input

3. Configure One Credential & Start

Add at least one provider key to ~/.config/agent-voice-input/agent-voice-input.env (for example OPENROUTER_API_KEY, GEMINI_API_KEY, OPENAI_API_KEY, or DASHSCOPE_API_KEY):

mkdir -p ~/.config/agent-voice-input && chmod 700 ~/.config/agent-voice-input
cat > ~/.config/agent-voice-input/agent-voice-input.env <<'EOF'
OPENROUTER_API_KEY="<your-openrouter-api-key>"
EOF
chmod 600 ~/.config/agent-voice-input/agent-voice-input.env

# Verify audio bridge, native shim, resolved providers/models, and session binding, then start daemon
agent-voice-input doctor
agent-voice-input start

Tap Right Ctrl (RControl) inside your terminal to start and finish recording. To customize hotkeys (trigger_mode = "ptt"), HUD position (bottom / top), duration limits, or providers, copy config.example.toml to ~/.config/agent-voice-input/config.toml (see config.example.env for all credential variables).


Platform Experience

Windows Terminal + WSL2 (Including Remote Desktop & tmux)

  • Terminal-Scoped Hotkey & HiDPI Capsule: Isolated Right Ctrl tap toggles recording (chords like RControl+C pass through untouched; starts only when a terminal is focused, while stopping/canceling works from any app) with an anti-aliased Per-Monitor V2 HiDPI capsule above the taskbar.
  • Native WASAPI Capture (Zero WSLg / RDP Glitches): Captures 16 kHz audio directly via Windows WASAPI in a resident win_shim, bypassing WSLg RDPSource zero-packet deadlocks; start/stop audio cues default to off to avoid 1–2s Remote Desktop audio wake-up lag.
  • Zero-Config tmux Pane Resolution: Automatically tracks the active pane of the attached tmux client without modifying ~/.tmux.conf.

macOS (Ghostty, Built-in Terminal.app & tmux)

  • Native Retina HUD & Terminal-Aware Delivery: Uses a cached native mac_shim for Right Ctrl tap/PTT and Retina capsule rendering. In Ghostty, locks onto the exact focused split surface and injects bracketed-paste text directly; in built-in Terminal.app (and other macOS terminals), locks onto the window ID / active tab tty and delivers via tmux buffer paste (when attached to tmux) or Cmd+V (falling back to clipboard if focus or tab moved).
  • Zero-Hook Tab/Split & tmux Session Binding: Reads Ghostty's split tty/cwd, Terminal.app's selected tab tty, or the terminal window's child PTY tree (plus active pane inside tmux) to bind directly to the codex, claude, or agy session running in that tab while isolating sibling terminals; audio input defaults to system mic ([audio] macos_device = "default").
  • Minimal macOS Permissions (TCC): Requires Microphone (for ffmpeg) plus Automation → Ghostty (for Ghostty) or Automation → Terminal (for multi-tab Terminal.app active-tab lookup). Input Monitoring is not required for default modifier hotkeys (RControl), and Accessibility is only needed for Cmd+V paste into non-Ghostty terminals when not running inside tmux.

Configuration & Providers Reference

Configuration uses two clean files (CLI flags > config.toml > built-in defaults):

  • ~/.config/agent-voice-input/config.toml: Structured [hotkey], [ui], [audio], [asr], and [refiner] settings.
  • ~/.config/agent-voice-input/agent-voice-input.env: API credentials (prefix-style aliases also supported; see config.example.env).

How provider, model, and asr.api Work

  • Provider-first defaults (model is optional): Leave model = "" (or omit it) in [asr] and [refiner] to automatically use the selected provider's built-in default model. Overriding provider via CLI without specifying model cleanly resets any config-file model to the new provider's default. When explicitly set, model passes the upstream model ID verbatim.
  • Two-stage STT vs. single-hop multimodal (asr.api):
    • asr.api = "auto" (default) routes dashscope, doubao, and dedicated STT models (qwen/qwen3-asr-1.7b, whisper-*, *-transcribe, SenseVoiceSmall, etc.) through Stage 1 transcription + Stage 2 context refinement;
    • Native gemini and multimodal chat-audio models on OpenRouter / OpenAI-compatible channels (gemini-2.5-flash, google/gemini-2.5-flash, gpt-audio*, etc.) perform transcription + context refinement in a single hop and skip Stage 2 automatically (unless refiner.force_on_single_hop = true). For newly released uncataloged models on openrouter, set asr.api = "audio-transcriptions" or "chat-completions" explicitly.
  • Reasoning budget (effort): Accepts "auto" | "default" | "none" | "minimal" | "low" | "medium" | "high" | "xhigh" | "max". asr.effort defaults to "auto" (suppressing thinking latency on supported multimodal models); refiner.effort defaults to "low".
  • Stage 2 prompt & context caching (refiner.prompt, include_git_status, context_max_chars): Leave prompt = "" (default) to use the built-in English voice-dictation editor prompt (repairs ASR typos/identifiers from read-only <session_reference_log> blocks and <workspace_git_status>, smooths spoken disfluencies while preserving original sentence structure and language, and strictly forbids answering dictated questions), or customize it with TOML multiline strings prompt = '''...'''. Recent dialogue (up to context_max_chars = 200000, evicted in ~1/4-window 50K blocks) is placed at the start of a single user message ahead of the current draft and trailing git status paths (include_git_status = true by default) for automatic prefix caching (codex reuses a reverted per-session shell thread to preserve prompt_cache_key without retaining prior drafts).
  • Same-provider retries & handshake timeout (max_retries): [asr] max_retries and [refiner] max_retries default to 2 (0..10, extra retries beyond the initial request; 0 disables retries), separating rate-limit throttling (HTTP 429, Retry-After, vendor QPS codes) from transient network/5xx errors under the stage timeout_sec budget with a 9s connect/TLS handshake cap.

Built-in Providers

provider Stages Built-in Default asr.model Built-in Default refiner.model Credential Source / Env
codex refiner — gpt-6-luna Local codex CLI login (resident read-only tool-free session; never enables Fast mode)
dashscope asr, refiner qwen3-asr-flash qwen-turbo-latest DASHSCOPE_API_KEY (compat: ALI_API_KEY)
doubao asr bigmodel — DOUBAO_ASR_APP_ID + DOUBAO_ASR_API_KEY (auto-probes granted slot)
volcengine refiner — doubao-seed-1-6-flash ARK_API_KEY (compat: VOLCENGINE_API_KEY, HUOSHAN_API_KEY)
openrouter asr, refiner qwen/qwen3-asr-1.7b google/gemini-2.5-flash-lite OPENROUTER_API_KEY
gemini asr, refiner gemini-2.5-flash (single-hop) gemini-2.5-flash-lite GEMINI_API_KEY
openai asr, refiner gpt-4o-mini-transcribe gpt-4o-mini OPENAI_API_KEY
groq asr, refiner whisper-large-v3-turbo llama-3.3-70b-versatile GROQ_API_KEY
siliconflow asr, refiner FunAudioLLM/SenseVoiceSmall Qwen/Qwen2.5-7B-Instruct SILICONFLOW_API_KEY
openai-compatible asr, refiner gpt-4o-mini-transcribe (needs base_url) (needs explicit base_url + model) api_key_env or OPENAI_API_KEY (loopback URLs need no key)
  • asr.provider = "auto" (default): selects the first configured credential in order dashscope -> doubao -> openrouter -> gemini -> openai -> groq -> siliconflow.
  • refiner.provider = "off": disables Stage 2 refinement.

Common config.toml Recipes

# Recipe 1: OpenRouter single key — two-stage dedicated STT + fast refiner (uses built-in defaults)
[asr]
provider = "openrouter"

[refiner]
provider = "openrouter"
# Recipe 2: Single-hop multimodal audio + context refinement (OpenRouter or native Gemini; skips Stage 2)
[asr]
provider = "openrouter"          # Or set provider = "gemini" (with GEMINI_API_KEY, no model needed)
model = "google/gemini-2.5-flash"
effort = "auto"
# Recipe 3: Low-latency Mainland China setup (DashScope STT + resident local Codex or API refiner)
[asr]
provider = "dashscope"

[refiner]
provider = "codex"               # Or "dashscope" / "volcengine" if Codex CLI is not installed

CLI Commands & Overrides

Common Subcommands

agent-voice-input start                  # Start background daemon
agent-voice-input restart                # Restart daemon after config changes
agent-voice-input status                 # Inspect daemon state, last latency, and redacted errors
agent-voice-input doctor                 # Check audio bridge, native shim, credentials, and session binding
agent-voice-input retry --list           # List stashed failed recordings (`agent-voice-input retry` re-runs latest)
agent-voice-input once --duration 4 --dry-run  # Record once and print result without pasting
agent-voice-input toggle                 # Toggle recording start/stop from CLI
agent-voice-input stop                   # Stop background daemon
agent-voice-input key-test               # Inspect raw key scancodes / modifier events

Runtime CLI Flags

CLI Flag Description
--config PATH Path to config.toml or config.json (also supports AGENT_VOICE_INPUT_CONFIG)
--asr, --asr-provider Stage 1 provider (auto, dashscope, doubao, openrouter, gemini, openai, groq, siliconflow, openai-compatible)
--asr-model Stage 1 upstream model ID
--asr-api Stage 1 protocol (auto, audio-transcriptions, chat-completions)
--asr-effort Stage 1 thinking budget
--refiner, --refiner-provider Stage 2 provider (codex, dashscope, volcengine, openrouter, gemini, openai, groq, siliconflow, openai-compatible, off)
--refiner-model Stage 2 upstream model ID
--refiner-effort, --effort Stage 2 thinking budget

(Environment variables are reserved for API credentials, bootstrap paths AGENT_VOICE_INPUT_CONFIG / AGENT_VOICE_INPUT_RUNTIME_DIR, and low-level runtime/diagnostic hooks; ordinary options live in config.toml.)

Optional: Multi-Window Session Title Hooks

Single-window setups, macOS + Ghostty splits, and tmux panes work out of the box with zero hooks. If you run multiple standalone terminal windows side by side in the same project directory on WSL2 or in terminals without per-split tty/cwd introspection, see integrations/ for optional lightweight session title hooks (agent-voice-input session-hook) for Codex, Claude Code, and Antigravity CLI.


Development

git clone https://github.com/xiaohuaxi/agent-voice-input.git ~/repos/agent-voice-input
ln -sf ~/repos/agent-voice-input/bin/agent-voice-input ~/.local/bin/agent-voice-input
PYTHONPATH=src python3 -m unittest discover -s tests -v

Acknowledgments

Early exploration for this project was inspired by Einstellung/voice-asr, particularly around pairing Qwen3-ASR with technical terminology context for mixed Chinese–English speech, as well as pre-transcription silence gating and loudness normalization.

License

Apache-2.0 License

Metadata

Release files for agent-voice-input 0.6.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for agent-voice-input 0.6.0
File Size Uploaded Provenance Actions
agent_voice_input-0.6.0.tar.gz 425.8 kB With provenance Details for agent_voice_input-0.6.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for agent-voice-input 0.6.0
File Interpreter ABI Platform Actions
agent_voice_input-0.6.0-py3-none-any.whl Python 3 none any Details for agent_voice_input-0.6.0-py3-none-any.whl

Total release size: 654.7 kB

Release files / agent_voice_input-0.6.0.tar.gz

Download URL agent_voice_input-0.6.0.tar.gz
Size 425.8 kB
Tags Source
SHA-256 checksum
How to use checksums
76a9ebd3e1052b8d76521e673b61dc1dbfd791cea2208334b4d6a6d0cb8cdc1c
BLAKE2b-256 checksum
How to use checksums
550bce2b440e2daa1c223a1ff7f11ae1e30f9b680fa18d09029cef3410c1ac5a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 16, 2026.

Transparency log

Release files / agent_voice_input-0.6.0-py3-none-any.whl

Download URL agent_voice_input-0.6.0-py3-none-any.whl
Size 229.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
897c6f50b0812335bfc89baa81e8e39c983fdb5201ab18c29ba2385f3f3618e1
BLAKE2b-256 checksum
How to use checksums
10a414ba899e35a65d49b528d76eb1fbee6fed0466ec09b38702128c034a5a6a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 16, 2026.

Transparency log

Security for agent-voice-input 0.6.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for agent_voice_input-0.6.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 16, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page