Skip to main content

English | 简体中文

agent-voice-input

PyPI version Python 3.10+ CI License

Context-aware voice input for CLI coding agents—grounded in your live session, repo, and SSH hosts.
Supports macOS and Windows + WSL2. Built for Codex, Claude Code, and Antigravity CLI (agy), while working out of the box across desktop IDEs and everyday apps.

🎙️ What you say casually to your terminal:
   "Uh check the default retry timeout in session router dot py, change it from
    five seconds to ten seconds—actually wait, make it fifteen seconds—and run
    the unit tests without piping to head"

❌ Generic OS dictation:
   Uh check the default retry timeout in session router dot pie change it from 5 seconds to 10 seconds actually wait make it 15 seconds and run the unit tests without piping to head

✅ agent-voice-input (grounded in active Agent session & repo, pasted without Enter):
   Check the default of retry_timeout_sec in session_router.py, change it to 15 seconds, and run the unit tests without piping to head.

Quick Start in 60 Seconds

The CLI is 100% non-interactive (zero y/n prompts) with structured --json diagnostics. Paste this into Codex, Claude Code, or AGY:

Install and configure agent-voice-input following docs/agent-setup.md (https://github.com/xiaohuaxi/agent-voice-input/blob/main/docs/agent-setup.md):
1. Respect my local keyboard layout (auto-use RCommand on MacBook built-in keyboards; keep RControl on desktop Macs such as Mac mini with external keyboards and on Windows/WSL2).
2. Only run `agent-voice-input integrate` if my setup actually needs hooks (e.g., multiple non-tmux WSL2 windows in the same directory).
3. After `doctor --ping --json` and `start`, guide me through a quick live or `--dry-run` connectivity check.

Path B: Manual Setup in 3 Steps

Prerequisites: Python >= 3.10, ffmpeg (macOS: brew install ffmpeg + xcode-select --install; WSL2: sudo apt install ffmpeg).

Step 1: Install (Pick Either Option)

Option 1 — PyPI one-line install (installs into ~/.local/bin; ensure ~/.local/bin is in your PATH):

uv tool install agent-voice-input          # or: pipx install agent-voice-input

Option 2 — Clone repo & run with zero dependencies (pure Python >= 3.10 standard library; no uv or pipx required):

git clone https://github.com/xiaohuaxi/agent-voice-input.git \
  && mkdir -p ~/.local/bin \
  && ln -s "$PWD/agent-voice-input/bin/agent-voice-input" ~/.local/bin/agent-voice-input

Step 2 & 3: Initialize, Add a Key & Start

# 2. Initialize ~/.agent-voice-input/ (0600 config.toml, .env, starter hotwords/personal.txt & default-ignore .gitignore)
agent-voice-input init

# 3. Verify connectivity & start daemon (first run compiles the native shim: ~5-15s on macOS, ~15-60s+ on WSL2 with Defender)
agent-voice-input doctor --ping && agent-voice-input start
  • Keyboard-aware defaults (even without init): Both init and zero-init runtime automatically default to key = "RCommand" on MacBook built-in keyboards, and keep key = "RControl" on desktop Macs (e.g., Mac mini with an external full-size keyboard) and Windows/WSL2; an explicit key in config.toml or CLI --hotkey strictly takes precedence. Pitfalls to avoid on macOS: ROption conflicts with Doubao IME, Fn conflicts with the macOS 🌐 Globe key (to use Fn, set System Settings → Keyboard → "Press 🌐 key to" to Do Nothing), and RShift conflicts with third-party Chinese IME single-tap toggling. Tap hotkey <= 0.5s to start/stop; hold 0.8s to cancel.
  • macOS permissions belong to the starting terminal: Grant Microphone (required), Accessibility (for Cmd+V auto-paste outside Ghostty/tmux and window-title/session routing in third-party terminals/desktop apps), and Automation (for Ghostty / Terminal.app / iTerm2) to the GUI terminal that runs agent-voice-input start; if you restart from a different terminal app, grant permissions to that terminal too.
  • Unified app home (~/.agent-voice-input/): config.toml, .env, hotwords/personal.txt, and opt-in archives (audio/ & transcripts/) all live under ~/.agent-voice-input/ (override root via AGENT_VOICE_INPUT_HOME). init creates a default-ignore .gitignore tracking only hotwords/, and init --force overwrites only config.toml while always preserving existing .env credentials, hotwords/personal.txt, and .gitignore.
  • Simplest 1-key setup (remember to uncomment .env lines!): init auto-detects existing environment keys and local codex CLI logins and tells you immediately if you are ready out of the box. If you need a Stage 1 key, add 1 key to ~/.agent-voice-input/.env—be sure to remove the leading # comment character and replace the placeholder value:
    • Mainland China: DASHSCOPE_API_KEY or DEEPSEEK_API_KEY
    • Global / Overseas: OPENROUTER_API_KEY, OPENAI_API_KEY, or GEMINI_API_KEY
  • Templates & full agent guide: config.example.toml, config.example.env, and docs/agent-setup.md.

Tip: Zero hooks required for ~80% of daily workflows: macOS Ghostty (✅), Terminal.app (🧪), and iTerm2 (🧪, falls back to PTY scan without Automation permission; grant Automation in System Settings for exact tty), local or remote tmux on any platform (no ~/.tmux.conf edits), all desktop apps, and WSL2 single-window or distinct-directory windows route accurately out of the box. Only if you run multiple standalone non-tmux windows in the same directory (e.g., Windows Terminal on WSL2) do you ever need one optional command: agent-voice-input integrate (see integrations/README.md).


Core Technical Highlights

  • Two-Stage & Single-Hop + 50K Block Prefix Caching: Pair fast Stage 1 STT with lightweight Stage 2 refinement, or run single-hop multimodal audio; session history is sealed into immutable 50K prefix blocks for high cache hits while back-to-back utterances refine concurrently and paste in strict FIFO order.
  • Focus-Aware Terminal, IDE & SSH Routing: Automatically binds to the active session and git status filenames in your focused terminal, Ghostty split, or tmux pane; desktop IDEs mount only workspace context without leaking terminal sessions; chat/everyday apps switch to clean general dictation; SSH terminals block local leaks by default and support zero-install remote probing via a 1-line [remote] hosts whitelist.
  • Zero Third-Party Python Dependencies + Acoustic Silence Gating & Trimming: Pure Python >= 3.10 standard library plus host ffmpeg and minimal native shims (no Electron); local silence gating, adaptive long-pause compression ([audio].silence_trim = "balanced" | "conservative" | "off"), and loudness normalization filter empty triggers and shorten long thinking pauses before API calls, recordings support up to 10 minutes (auto-splitting > 3 min clips at pauses), and failed or in-flight-cancelled clips stash (0600) for retry.
  • Zero-Clipboard Injection in macOS Ghostty/tmux + Never Auto-Presses Enter: Locks onto the origin window on record start and falls back to clipboard if focus drifts; injects directly in macOS Ghostty and macOS tmux without touching your clipboard (WSL2—including inside tmux—and other windows snapshot and restore clipboard contents); paste-only by default so misheard commands never auto-execute.
  • 100% Non-Interactive CLI for Human & Agent Workflows: Every command runs without y/n prompts and supports --json output (status --json, doctor --ping --json, diagnose --json, integrate --status --json), so both humans and AI agents can install, verify, and troubleshoot cleanly.

Support & Verification Matrix

Status Legend:

  • ✅ Verified on hardware: Used daily or verified end-to-end by the author on real devices.
  • 🧪 CI & unit-tested (seeking field reports): Dedicated adaptation implemented and covered by offline unit tests or automated CI checks (e.g., real tmux, real sshd, mac_shim/win_shim self-checks), not yet verified on that specific client or account on real hardware—feedback welcome to light up ✅.
  • ⚪ Generic fallback: Works out of the box under default hotkey.scope = "all" with refined paste and window-locked anti-crosstalk, without app-specific context or tone adaptation.

Platforms, Terminals, SSH & Key Desktop Apps

Category Target Status Scope, Delivery & Boundaries
Host OS macOS (Apple Silicon / Intel) ✅ Daily driver; native mac_shim HUD capsule + system microphone
Host OS Windows + WSL2 ✅ Daily driver; win_shim native WASAPI capture + Per-Monitor V2 HiDPI capsule
Host OS SSH Remote Linux Host ✅ Zero-install remote probe (Python >= 3.10 only) + local crosstalk blocking; verified via Ubuntu CI real sshd E2E
Host OS Native Linux Desktop / Standalone Windows (No WSL2) — Daemon, global hotkey & toggle not yet supported natively; native Linux currently supports offline file transcription (once --file <wav> --dry-run) and headless SSH remote targets
Terminal macOS Ghostty ✅ AppleScript zero-clipboard direct injection + same-split tmux pane anti-crosstalk + zero-hook full context (Codex / Claude Code / AGY CLI hardware-verified)
Terminal Windows Terminal (WSL2) ✅ win_shim transient clipboard + shortcut paste (preserves clipboard) + same-window tab anti-crosstalk + hook/tmux precision context (Codex / Claude Code / AGY CLI hardware-verified)
Terminal Local & Remote tmux ✅ macOS: zero-clipboard direct injection / WSL2: win_shim transient clipboard + paste (preserves clipboard); process tree isolated by focused pane; Linux & macOS CI real tmux E2E
Terminal Other Built-in Terminals & Dedicated SSH Clients 🧪 Built-in paste-chord routing, anti-crosstalk & client rules (see full list below); other CLI agents (OpenCode, Aider, etc.) fall back to workspace git/filenames without reading their conversation history yet; seeking real-hardware feedback
Desktop App Antigravity / AGY Desktop ✅ (macOS) / 🧪 (Windows) Hardware-verified on macOS for Antigravity 2.0 standalone desktop (read-only conversation_summaries.db + exact/truncated-prefix title matching, workspace git/filenames + brain/ incremental cache, and thread switching); legacy VS Code Fork also supported (Windows desktop pending field reports; WSL2 scans WSL paths only)
Desktop App ChatGPT / Codex Unified Desktop ✅ (macOS) / 🧪 (Windows) Hardware-verified on macOS: the unified desktop app (com.openai.codex) reads ~/.codex/sqlite/codex.db + ~/.codex/sessions/*.jsonl read-only to auto-promote local repo tasks to agent mode with project hotwords & incremental cache, keeps cloud ChatGPT chats in general mode (personal hotwords only, zero crosstalk), and re-verifies same-window thread switching before paste; Windows (ChatGPT.exe / Codex.exe) currently provides refined paste & window-locked anti-crosstalk (Windows/WSL2 cross-OS context binding is on the roadmap)
Desktop App Claude Desktop ✅ (macOS) / 🧪 (Windows) Hardware-verified on macOS (com.anthropic.claudefordesktop): Code & Cowork local session binding (bounded read-only AXWebArea route/title probe, joint Claude/Claude-3p metadata scan, 50K incremental cache, and pre-paste same-window thread verification) plus refined paste with clipboard restore, while cloud Chat stays in general mode (personal hotwords only, zero crosstalk) (WSL2 does not yet support Windows Claude Desktop context binding; Windows Claude.exe provides refined paste & window-locked anti-crosstalk)
Desktop App Other Desktop IDEs 🧪 IDEs (VS Code, Cursor, Windsurf, JetBrains, Zed, etc.) run as coding_gui with workspace git/filenames; running CLI agents inside an IDE's integrated terminal is also treated as coding_gui (skips CLI sync_session, does not read codex/claude/agy history inside the integrated terminal, and does not distinguish integrated terminal splits)
Desktop App Any Other Desktop App (browsers, IM, chat, notes, email, etc.) ⚪ Works out of the box under default hotkey.scope = "all" in general mode (personal hotwords only, refined paste + window-locked anti-crosstalk; no fragile non-agent app/browser title enumeration)
Full List of Built-in Terminals & Dedicated SSH Clients (🧪)
  • macOS Terminals (🧪): Terminal.app, iTerm2, WezTerm, Kitty, Alacritty, Warp, Hyper, Rio, Tabby
  • Windows Terminals (🧪): WezTerm, Alacritty, Ghostty, Tabby, Hyper, Rio, Warp, Mintty, PuTTY, KiTTY
  • Dedicated SSH Clients (🧪): MobaXterm, Xshell, WindTerm, SecureCRT, Termius, Electerm, FinalShell, RoyalTS

Using a 🧪 or ⚪ environment? If it works smoothly—or if you run into an edge case—please open an Issue with your OS + terminal/app + provider to help us light up more ✅.


Mainstream Stage 1 (ASR) Providers

Provider Model Hotwords / Context Highlights & Best Fit
Alibaba Bailian (dashscope) ✅ qwen3-asr-flash 250 terms / 2,800 chars + recent dialogue Top choice for Chinese & mixed CN/EN dictation; wide hotword capacity and low latency
OpenRouter (openrouter) ✅ microsoft/mai-transcribe-2 Native keyterms (50 terms) ~$0.10/hr base rate; rock-solid transcription + native keyterms; great global/aggregator default
Doubao (doubao) ✅ bigmodel 50 terms / 1,000 chars + dialogue Fast Mainland China alternative; single-header DOUBAO_SPEECH_API_KEY (no APP_ID required)
OpenAI (openai) ✅ gpt-transcribe (default; also gpt-4o-transcribe) Native keywords[] (50 terms on gpt-transcribe) Strong English & multilingual STT; pairs natively with gpt-6-luna refinement
DeepSeek (deepseek) ✅ deepseek-asr None (rely on Stage 2 refiner) Official /v1/tools/asr with 21-language auto-detect; ultra-low cost single-key two-stage
Google Gemini (gemini) ✅ gemini-3.7-flash Stage 2-grade 200 items / 3,000 chars + 50K context Native single-hop multimodal audio + context refinement (skips Stage 2)

Stage 2 (Refiner) Quality Tiers — Prefer Quality First

  • Tier 1 — Recommended (Best Refinement Quality): codex (gpt-6-luna, reuses local Codex CLI login, never enables Fast mode), agy (gemini-3.8-flash, explicit opt-in via local AGY CLI), openrouter (google/gemini-3.8-flash, default effort = "low"), openai (gpt-6-luna), and gemini (gemini-3.7-flash). These models handle mid-sentence self-corrections, mixed CN/EN technical terminology, and long-session grounding noticeably better than lightweight domestic models—prefer them whenever refinement quality matters most.
  • Tier 2 — Budget / Single-Key Convenience: deepseek (deepseek-flash), dashscope (qwen3.8-flash), and volcengine (doubao-seed-2-0-mini-260428). Fast and inexpensive for 1-key Mainland China setups, with slightly weaker complex edit accuracy than Tier 1.
Scenario Recommended Stage 1 (ASR) Recommended Stage 2 (Refiner) Keys / Setup Needed
Best Quality with Existing Codex / AGY Login dashscope ✅, openrouter ✅, doubao ✅, openai ✅, or deepseek ✅ codex ✅ (auto-detected by auto; never enables Fast mode) or agy ✅ (explicit opt-in) 1 Stage 1 speech key + local codex or agy CLI login
Mainland China Daily Driver (CN / Mixed CN–EN) dashscope (qwen3-asr-flash ✅, 250-term hotwords) or doubao (bigmodel ✅, 50/1,000) Tier 1: codex ✅ / agy ✅ / openrouter ✅ (or Tier 2 budget: deepseek ✅ / dashscope ✅) DASHSCOPE_API_KEY or DOUBAO_SPEECH_API_KEY + preferred Stage 2 login/key
Global / Aggregator Single-Key (High Quality) openrouter (microsoft/mai-transcribe-2 ✅, ~$0.10/hr, two-stage) or openai (gpt-transcribe ✅) openrouter (google/gemini-3.8-flash ✅) or openai (gpt-6-luna ✅) Just 1 key: OPENROUTER_API_KEY or OPENAI_API_KEY
Minimal 1-Key Budget or Single-Hop deepseek ✅ (budget two-stage), dashscope ✅ (two-stage or qwen3.8-omni-flash single-hop), or gemini ✅ (native single-hop) Built-in default for two-stage, or skipped in single-hop Just 1 key: DEEPSEEK_API_KEY, DASHSCOPE_API_KEY, or GEMINI_API_KEY

Note on OpenRouter: Use OpenRouter in two-stage mode (microsoft/mai-transcribe-2 + google/gemini-3.8-flash). Single-hop multimodal chat-audio on OpenRouter is intentionally omitted from recommended recipes because skipping explicit cache writes on < 50K sessions makes repeated single-hop audio calls pricier than two-stage.

On local / self-hosted models: This release focuses on thoroughly tested mainstream cloud APIs and existing CLI logins (codex / agy). While a generic openai-compatible custom base_url hook already exists under the hood (🧪), fully verified first-class support for local / private self-hosted models (compact local ASR + refiner) is planned for v1.1+.


Privacy & Data-Flow Commitments

  1. No Author Servers, Zero Middleman — 100% User-Controlled: agent-voice-input has no author-hosted servers, relays, or hidden telemetry. All audio and context go directly from your machine to the model provider you explicitly configure; every model and credential stays strictly under your own control (Apache-2.0 open source).
  2. No Audio or Transcripts Stored by Default: Status snapshots, logs, and the local diagnostic log (diag.jsonl) redact secrets and never write user speech transcripts, session context, or hotword lists. Audio is only stashed (0600, 24h TTL, max 10 clips) in failed/ when recognition/delivery fails or an in-flight job is cancelled so retry can recover it (recording-time cancels drop immediately). Optional local history under [archive] (save_transcripts → transcripts/YYYY-MM.jsonl, save_audio → audio/<id>.mp3) is off by default, uses 0700/0600 permissions, and is excluded by .gitignore.
  3. 0700/0600 Isolation & No Invasive Scraping: Runtime/config files enforce private permissions. Context lookup only inspects the focused window title, macOS AXDocument, plain-text CLI agent logs, and read-only AGY/Codex session indexes—never VS Code/Cursor internal state DBs (state.vscdb) and never Accessibility/UIAutomation DOM trees in chat apps or browsers. Non-terminal windows hard-skip terminal CLI sessions, and SSH remote probing only queries explicitly whitelisted hosts with zero remote keys.
  4. Scoped Context Only (Never Full Repo) & Transparent auto Detection: Coding mode sends only recent dialogue from the active window plus git status/shallow filenames—never your full repository source. Note that default provider = "auto" checks your environment/.env keys and existing local codex CLI login (agy is explicit opt-in only and never auto-selected); set explicit provider values or refiner.provider = "off" if you want fixed routing.

FAQ, Daily Operations & Common Gotchas

  • My MacBook doesn't have a Right Ctrl key—what should I use?
    Both agent-voice-input init and zero-init runtime automatically detect MacBook built-in keyboards and default to key = "RCommand" (Right Command, recommended first), while desktop Macs (e.g., Mac mini) and external full-size keyboards keep key = "RControl"; an explicit key in config.toml or CLI --hotkey always takes precedence. Avoid common conflicts: ROption collides with Doubao IME, Fn collides with the macOS 🌐 Globe key (to use Fn, set System Settings → Keyboard → "Press 🌐 key to" → Do Nothing), and RShift collides with third-party Chinese IME single-tap toggling. You can change [hotkey] in ~/.agent-voice-input/config.toml anytime, run agent-voice-input restart, or inspect keycodes with agent-voice-input key-test.
  • Why isn't bare pip install agent-voice-input recommended in Quick Start?
    Homebrew Python on macOS (and modern Debian/Ubuntu distros) enforces PEP 668 (externally-managed-environment), causing bare pip install outside a virtualenv to fail. Use uv tool install agent-voice-input or pipx install agent-voice-input for isolated PyPI installs, or clone the repo and symlink bin/agent-voice-input directly with zero dependencies.
  • How do I auto-start, upgrade, or completely uninstall?
    • Idempotent terminal auto-start (add 1 line to ~/.zshrc or ~/.bashrc):
      [ -z "$SSH_CONNECTION" ] && command -v agent-voice-input >/dev/null 2>&1 && agent-voice-input start >/dev/null 2>&1
      

      Warning (macOS): Never use launchd (LaunchAgent) to launch the daemon in the background on macOS. Background launchd agents lose the GUI terminal's Microphone & Automation TCC attribution and silently record all-zero audio; always start from your authorized GUI terminal.

    • Upgrade: uv tool upgrade agent-voice-input && agent-voice-input restart (or pipx upgrade agent-voice-input && agent-voice-input restart; if running from a git clone, git pull && agent-voice-input restart).
    • Uninstall:
      agent-voice-input stop
      agent-voice-input integrate --uninstall   # optional: remove managed CLI hooks
      uv tool uninstall agent-voice-input       # or pipx uninstall / rm ~/.local/bin/agent-voice-input
      # Optional: remove config, runtime & cache files listed below
      
    • Where files live:
      Path Purpose
      ~/.agent-voice-input/ App home (config.toml, .env, hotwords/personal.txt, opt-in audio/ & transcripts/; override via AGENT_VOICE_INPUT_HOME)
      ~/.cache/agent-voice-input/ (or $XDG_RUNTIME_DIR/agent-voice-input) Runtime dir (control.sock, daemon.lock, daemon.log, diag.jsonl, failed/, sessions/, integrate-backups/)
      ~/Library/Caches/agent-voice-input/ (macOS) Cached compiled mac_shim binary
  • Why does macOS record pure silence when I start the daemon over SSH?
    macOS binds Microphone TCC permission to the responsible GUI process; daemons launched under sshd (or launchd) receive silent all-zero audio frames. Always run agent-voice-input start / restart inside an authorized local GUI terminal (such as Ghostty or Terminal.app).
  • Why can't WSL2 auto-paste into Windows Administrator windows?
    Windows UIPI (User Interface Privilege Isolation) blocks non-elevated win_shim from synthesizing Ctrl+V into elevated Administrator windows. The refined text is safely copied to your clipboard—press Ctrl+V manually.
  • How do I route the background daemon through a proxy?
    Export HTTPS_PROXY (and NO_PROXY=127.0.0.1,localhost for loopback endpoints) in your shell or set it in ~/.agent-voice-input/.env (shell environment variables take precedence), then run agent-voice-input restart. Because the pure-stdlib HTTP client only speaks http:// proxies, if your proxy client only sets ALL_PROXY=socks5://..., also set its HTTP/HTTPS mixed port (HTTPS_PROXY=http://127.0.0.1:<port>) and verify with agent-voice-input doctor --ping.
  • Why does it only paste and never auto-press Enter?
    In terminals and SSH sessions, auto-executing a misheard command is dangerous. Paste-only lets you glance before hitting Enter, and if you switch windows mid-processing, output safely falls back to your clipboard instead of pasting into the wrong window.
  • Should I choose two-stage (STT + Refiner) or single-hop multimodal?
    Two-stage gives the widest provider choice (including 1-key openrouter and deepseek two-stage), lets you reuse existing Codex/AGY logins for top-tier refinement, and handles long technical dictation most reliably. Single-hop (gemini, DashScope qwen3.8-omni-flash, or OpenAI gpt-audio-1.5 / gpt-audio-mini) is simpler with one request and one key, and sends audio plus session context directly to that single multimodal provider.

CLI Commands & Optional Integrations

agent-voice-input init [--asr P] [--refiner P] [--hotkey K] [--force]  # Create ~/.agent-voice-input/ (0600 config.toml & .env + .gitignore)
agent-voice-input start | restart | stop                # Manage background daemon (start is idempotent and warns on code/version drift)
agent-voice-input status [--history N] [--json]         # Inspect daemon health, active pipeline, Archive: state, hotwords counts, and drift
agent-voice-input doctor [--ping] [--remote] [--json]   # Check audio, native shim, credentials, hotwords, hooks, SSH readiness, and endpoint ping
agent-voice-input integrate [--status] [--dry-run] [--cli claude|codex|agy] [--uninstall] [--json]  # Safe optional CLI hook setup
agent-voice-input diagnose [--last N] [--json]          # Read-only diagnostics: latency p50, cache hits, failed/ count, redacted log tail
agent-voice-input retry [--list] [--print]              # List or re-run stashed failed recordings
agent-voice-input hotwords list|add|remove|path         # Manage flat personal.txt hotwords, !pinning & <- aliases (--pin, --alias, --json)
agent-voice-input once --duration 4 --dry-run           # Record once and print without pasting (or `--file <wav> --dry-run` on Linux)
agent-voice-input toggle | cancel [--seq N] [--json]    # Trigger start/stop or cancel active/in-flight jobs
agent-voice-input key-test                              # Inspect raw key scancodes / modifier events
  • AI Agent setup & troubleshooting contract: docs/agent-setup.md
  • Optional multi-window hooks & SSH remote Linux ([remote]): Single-window terminals, Ghostty splits, and tmux panes work with zero hooks. For multiple standalone WSL2 windows in the same project directory (use agent-voice-input integrate), or to enable zero-install SSH remote context ([remote] hosts = ["devbox"], verified with agent-voice-input doctor --remote), see integrations/README.md (SSH section: SSH Remote Linux Hosts) and docs/context-routing.md (in Chinese).

Hotwords & Agent-Assisted Vocabulary

Keep your personal names, project brands, and recurring ASR mishearings in a single flat plain-text file—and let Claude Code, Codex, or AGY bootstrap or tidy it for you:

  • Unified flat file, starter vocabulary & dotfiles symlink: ~/.agent-voice-input/hotwords/personal.txt (locate via agent-voice-input hotwords path; hot-reloads automatically; directory-fd flock leaves zero .lock files). On your first agent-voice-input init, creating personal.txt seeds ~18 common AI, Agent, and developer starter terms (visible, editable, and removable; never overwritten even by init --force; active across both agent and general modes). To sync across machines via a dotfiles repo, symlink the hotwords/ directory rather than personal.txt itself (single-file symlinks are rejected on read/write; .gitignore under ~/.agent-voice-input/ intentionally does not traverse a symlinked hotwords/ directory):
    • Before your first init: mkdir -p ~/.agent-voice-input && ln -s ~/.dotfiles/avi-hotwords ~/.agent-voice-input/hotwords (then agent-voice-input init keeps the symlink and preserves any existing personal.txt inside it).
    • After init already created a local hotwords/ directory: merge or back up ~/.agent-voice-input/hotwords/personal.txt into ~/.dotfiles/avi-hotwords/ first, remove the local ~/.agent-voice-input/hotwords directory, then run ln -s ~/.dotfiles/avi-hotwords ~/.agent-voice-input/hotwords (running ln -sfn while hotwords/ is still a real directory creates a nested link inside it instead of replacing it).
  • Pinning (!) & mishearing aliases (<-): Prefix critical terms with ! (!Antigravity or agent-voice-input hotwords add Antigravity --pin) to pin them ahead of all other entries. Add mishearing aliases with CanonicalTerm <- mishearing1, mishearing2 or agent-voice-input hotwords add Harness --alias 哈尼斯,哈尼思 (max 5 aliases per entry; single-character aliases rejected; 2-character aliases warn; ambiguous aliases shared by multiple terms are hidden automatically while keeping both canonical terms). Stage 1 ASR receives canonical terms only; Stage 2 / single-hop uses aliases to fix stubborn mishearings.
  • Decoupled Stage 1 & Stage 2 budgets:
    • Stage 1 ASR: Orders entries by tier (!pinned → aliased → plain, preserving file line order within each tier so CJK names are never pushed out by ASCII order). In general mode, 100% of the provider quota goes to personal terms; in agent mode, at least 30% of slots are reserved for dynamic repo/session terms with unused space refilled from overflow (e.g., DashScope 250 terms / 2,800 chars, Doubao 50 / 1,000, OpenAI keywords[] 50, OpenRouter keyterms 50, Whisper 35 / 353; deepseek-asr relies on Stage 2).
    • Stage 2 / Single-Hop Block 0 (<vocabulary_hints>): Selects and renders up to 200 items / 3,000 chars in priority-tier order (!pinned → effective <- aliased → plain entries, preserving file top-to-bottom order within each tier) across both agent and general modes, so placing high-priority personal/project terms near the top of personal.txt keeps them inside the budget without A–Z reordering. Inspect live budgets & diagnostics anytime via agent-voice-input hotwords list [--json].
  • Two rules for your Agent: always show the diff and wait for your confirmation before editing personal.txt, and never guess mishearing aliases up front—only add <- aliases after observing a real ASR mistake.

Copy-paste prompts for your coding agent:

# 1. Bootstrap from scratch (canonical terms only)
Read my recent projects, READMEs, and specs to draft a clean flat list of proper nouns I actually speak aloud for ~/.agent-voice-input/hotwords/personal.txt (use `!` only for top-priority terms). Do not guess mishearing aliases; show me the diff first and write only after I confirm.

# 2. Fix a real mishearing on the spot
Voice input just misheard "Harness" as "哈尼斯". Add a mishearing alias with `agent-voice-input hotwords add Harness --alias 哈尼斯` (show me the change first).

# 3. Periodic cleanup & prioritization
Run `agent-voice-input hotwords list --json`, prune low-frequency or stale entries if we are near Stage 1/2 budgets, pin my highest-frequency cross-project terms with `!`, and show me the diff before applying.

Detailed Reference

Built-in Providers, Verification Matrix & Common config.toml Recipes

Configuration priority: CLI flags > ~/.agent-voice-input/config.toml > built-in defaults (root overridable via AGENT_VOICE_INPUT_HOME). Credentials live in ~/.agent-voice-input/.env (see config.example.env).

provider Stages Verification Built-in Default asr.model Built-in Default refiner.model Credential Source / Env
codex refiner ✅ — gpt-6-luna (auto-falls back to gpt-5.4-mini / gpt-5-codex-mini if unavailable on the account) Local codex CLI login (stateless HTTP /responses + 30m safe refresh; never enables Fast mode)
agy refiner ✅ — gemini-3.8-flash (default effort = "low"; explicit opt-in only, never chosen by auto) Local agy CLI login (zero-tool agy acp stdio JSON-RPC with incremental session resume)
deepseek asr, refiner ✅ (both stages) deepseek-asr (official POST /v1/tools/asr; asr.api = "auto" only; auto-detects 21 languages, no hotwords/language params) deepseek-flash DEEPSEEK_API_KEY (compat: API_KEY_DEEPSEEK; 1 key runs full two-stage)
dashscope asr, refiner ✅ (STT, single-hop & refiner) qwen3-asr-flash (or single-hop qwen3.8-omni-flash) qwen3.8-flash DASHSCOPE_API_KEY (compat: ALI_API_KEY)
doubao asr ✅ (1.0 & 2.0) bigmodel — DOUBAO_SPEECH_API_KEY (single-header X-Api-Key, no APP_ID needed; compat: DOUBAO_ASR_API_KEY or legacy DOUBAO_ASR_APP_ID + DOUBAO_ASR_API_KEY; asr.doubao_resource_id = "auto" prefers sync volc.bigasr.auc_turbo with cached fallback to volc.seedasr.auc / volc.bigasr.auc)
volcengine refiner ✅ (doctor --ping & refiner) — doubao-seed-2-0-mini-260428 ARK_API_KEY (compat: VOLCENGINE_API_KEY, HUOSHAN_API_KEY)
openrouter asr, refiner ✅ (STT & refiner) microsoft/mai-transcribe-2 (~$0.10/hr, native keyterms) google/gemini-3.8-flash (default effort = "low") OPENROUTER_API_KEY
gemini asr, refiner ✅ (single-hop & refiner) gemini-3.7-flash (single-hop) gemini-3.7-flash GEMINI_API_KEY
openai asr, refiner ✅ (STT, single-hop & refiner) gpt-transcribe (or single-hop gpt-audio-1.5 / gpt-audio-mini) gpt-6-luna 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)
off refiner ✅ — (Stage 2 disabled; raw Stage 1 output) None
  • asr.provider = "auto" (default): picks the first configured credential in order dashscope -> doubao -> deepseek -> openai -> gemini -> groq -> openrouter -> siliconflow.
  • refiner.provider = "auto" (default): prefers local codex CLI login when present, else picks openrouter -> deepseek -> dashscope -> gemini -> volcengine -> openai -> groq -> siliconflow, or degrades cleanly to "off". (agy is explicit opt-in only.)
# Recipe 1: Reuse local Codex or AGY CLI login for Stage 2 + fast Stage 1 STT
[asr]
provider = "dashscope"           # Or "openrouter" / "doubao" / "openai" / "deepseek"

[refiner]
provider = "codex"               # Or "agy" for Antigravity CLI login
# Recipe 2: Single-key two-stage via OpenRouter or DeepSeek (uses built-in defaults)
[asr]
provider = "openrouter"          # microsoft/mai-transcribe-2; or "deepseek" (deepseek-asr)

[refiner]
provider = "openrouter"          # google/gemini-3.8-flash; or "deepseek" (deepseek-flash)
# Recipe 3: Single-hop multimodal audio + 50K cached session context (skips Stage 2)
[asr]
provider = "gemini"              # Or "dashscope" + model = "qwen3.8-omni-flash", or "openai" + model = "gpt-audio-1.5" / "gpt-audio-mini"
Platform Details (WSL2 WASAPI / macOS TCC Permissions & Delivery)

Windows Terminal + WSL2 (Including Remote Desktop & tmux)

  • Global Scope, Remote-Desktop Yielding & HiDPI Capsule: Isolated Right Ctrl tap toggles recording across terminals, IDEs, and desktop apps by default (hotkey.scope = "all", or "coding" / "terminals"; chords like RControl+C pass through untouched) with an anti-aliased Per-Monitor V2 HiDPI capsule. Remote desktop / VM clients (mstsc, vmconnect, Parsec, RustDesk, etc.) automatically yield new triggers (yield_remote_desktop = true; bare msrdc stays unblocked for Win11 WSLg—non-WSLg AVD / Windows 365 users can add ignore_apps = ["msrdc"]). Even inside tmux, WSL2 delivers via win_shim transient clipboard snapshots + per-process paste shortcuts (Ctrl+V, Ctrl+Shift+V for WezTerm/Alacritty/Ghostty/Tabby/Hyper/Rio/Warp/WindTerm/SecureCRT/Termius/Electerm, and Shift+Insert for mintty/PuTTY/KiTTY/MobaXterm/Xshell) without clobbering existing clipboard contents.
  • Native WASAPI Capture: Captures 16 kHz audio via Windows WASAPI in a resident win_shim, avoiding WSLg RDPSource zero-packet deadlocks; start/stop beeps default to off to avoid RDP audio wake-up lag.
  • Zero-Config tmux Pane Resolution: Tracks the active pane of the attached tmux client without editing ~/.tmux.conf.

macOS (Ghostty, tmux & Other Terminals)

  • Native Retina HUD & Context-Safe Delivery: Uses a cached native mac_shim compiled via /usr/bin/swiftc for Right Ctrl / RCommand / ROption / Fn tap or ptt hold, remote-desktop hotkey yielding (Windows App, Screen Sharing, Parsec, VMware/Parallels, etc.), and Retina capsule rendering. Injects directly in macOS Ghostty and macOS tmux without touching your system clipboard; other apps lock onto the origin window ID and paste via native CGEvent Cmd+V with clipboard snapshot/restore.
  • Zero-Hook Tab/Split & tmux Binding: Reads Ghostty split tty/cwd, Terminal.app (🧪) selected tab tty, iTerm2 (🧪, Automation preflight with PTY fallback), or child PTY trees (plus active tmux pane) to bind codex, claude, or agy sessions while skipping session lookup in non-terminal GUI apps (including IDE integrated terminals). Audio input defaults to system mic ([audio] macos_device = "default").
  • Minimal macOS Permissions (TCC): All TCC permissions are attributed to the terminal app that starts the daemon (restarting from another terminal requires re-granting). Requires Microphone (for ffmpeg) plus Automation → Ghostty (or Terminal / iTerm2 for exact tty). Input Monitoring is not required for default modifier hotkeys (RControl / RCommand / ROption / Fn). Accessibility is needed for native Cmd+V paste into desktop GUI apps / non-Ghostty terminals outside tmux and for reading window titles/session bindings in third-party terminals and desktop apps (not needed inside Ghostty or tmux).
Advanced Configuration Mechanics (Protocols, Caching, Hotwords, Retries & Archiving)
  • Provider-first defaults (model) & HUD locale (ui.language): Leave model = "" to use each provider's built-in default; overriding provider via CLI without --*-model resets to the new provider's default. Explicit model values are passed upstream verbatim. ui.language accepts "auto", "zh", "en", as well as standard BCP 47 tags such as "zh-CN" / "en-US".
  • Two-stage vs. single-hop (asr.api, asr.doubao_resource_id): "auto" routes dedicated STT models (qwen3-asr-flash, doubao, deepseek-asr, whisper-*, *-transcribe, SenseVoiceSmall) to Stage 1 + Stage 2, and routes native gemini, DashScope qwen*-omni*, official OpenAI gpt-audio-1.5 / gpt-audio-mini (or explicit asr.api = "chat-completions"), and multimodal chat-audio models on OpenRouter/OpenAI-compatible to single-hop (sharing the 50K sealed <session_reference_log> prefix blocks, in-memory 64 kbps MP3 compression for >= 3s clips, and 610s single-chunk cap; skips Stage 2 unless refiner.force_on_single_hop = true). DeepSeek official ASR (POST https://api.deepseek.com/v1/tools/asr) supports asr.api = "auto" only (21-language auto-detection, no hotword/language params). Doubao slot selection uses asr.doubao_resource_id = "auto" (or explicit slot ID) plus asr.doubao_mode. For uncataloged models on openrouter, set asr.api = "audio-transcriptions" or "chat-completions" explicitly.
  • Stage 2 protocol & reasoning budget (refiner.api, effort, session_max_turns): refiner.api = "auto" uses stateless HTTP /responses (store=false, stream=true) for codex and official openai (api.openai.com), local agy acp stdio JSON-RPC for agy, native :generateContent for gemini, and /chat/completions for custom third-party openai base_urls and other providers (explicit "responses" / "chat-completions" always overrides). asr.effort and refiner.effort default to "" (tool-recommended per-provider default: "low" for codex/agy/openai/openrouter refinement, "none" for Stage 1 single-hop audio and all other Stage 2 providers) and accept "default" (omit thinking parameters and defer to upstream defaults) or "none" | "minimal" | "low" | "medium" | "high" | "xhigh" | "max" ("none" disables thinking where supported, clamps to the lowest valid level on mandatory-thinking models, and is ignored on non-thinking models). For agy, refiner.session_max_turns = 0 (default) imposes no fixed turn cap and rotates naturally on 200K eviction or vocabulary changes.
  • Extra instructions, prompt caching & cold-start fallback (refiner.extra_instructions, include_git_status, context_max_chars, cold_start_fallback): Built-in adaptive agent / general dictation-editor prompts stay active by default; append custom preferences safely via refiner.extra_instructions (list of strings, single string, or multiline string; max 20 items / 2,000 chars; applies to both two-stage and single-hop; empty keeps the default prompt byte-identical). Dialogue up to context_max_chars = 200000 is evicted in 50K sealed prefix blocks ahead of <workspace_git_status> (falls back to core tracked filenames when clean) and <asr_draft_to_clean>. When a new coding session starts empty/short, cold_start_fallback = "auto" (or "hotwords" / "off") supplements Stage 1 hotwords and prepends one frozen <= 25K <prior_session_reference> block from recent exact-same-directory sessions.
  • Personal flat hotwords (hotwords/personal.txt & hotwords CLI): Edit ~/.agent-voice-input/hotwords/personal.txt (seeded with ~18 editable developer starter terms on first init) or use agent-voice-input hotwords list|add [--pin] [--alias]|remove|path—hot-reloads automatically on the next dictation with directory-fd locking (zero .lock files). Stage 1 applies priority tiers (!pinned > aliased > plain, preserving file order within tiers) with 30% dynamic-term reservation & overflow refill in agent mode (100% personal quota in general mode; DashScope 250/2,800, Doubao 50/1,000, OpenAI 50, OpenRouter 50, Whisper 35/353), while Stage 2 / single-hop selects and renders up to 200 items / 3,000 chars into Block 0 in the same priority-tier order (!pinned > effective <- aliased > plain, preserving file order within each tier).
  • Same-provider retries & opt-in local archive (max_retries, [archive]): Both stages default to max_retries = 2 (0..10) under stage timeout_sec with a 9s connect/TLS handshake cap, separating 429/QPS throttling from transient network/5xx errors. Under [archive] (both off by default, 0700 dirs / 0600 files, excluded by .gitignore, surfaced as an Archive: row in status/doctor/start), save_transcripts = true appends 12-field JSONL records (ASR draft, final text, and flat metadata only—never context/hotwords/secrets) to ~/.agent-voice-input/transcripts/YYYY-MM.jsonl, and save_audio = true archives voiced clips as 16 kHz 64 kbps MP3s to ~/.agent-voice-input/audio/<id>.mp3 (audio_max_count = 1000, 0 = unlimited). Transcripts, audio files, and diag.jsonl share the same short utterance ID (YYYYMMDD-HHMMSS-<4hex>) for 1:1 correlation.
Runtime CLI Override Flags
CLI Flag Description
--config PATH Path to config.toml or config.json (also supports AGENT_VOICE_INPUT_CONFIG and AGENT_VOICE_INPUT_HOME)
--asr, --asr-provider Stage 1 provider (auto, dashscope, doubao, deepseek, openai, gemini, groq, openrouter, siliconflow, openai-compatible; aliases volcengine/volc → doubao, bailian → dashscope)
--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 (auto, codex, agy, deepseek, dashscope, volcengine, openrouter, gemini, openai, groq, siliconflow, openai-compatible, off; aliases doubao/volc/ark → volcengine, bailian → dashscope)
--refiner-model Stage 2 upstream model ID
--refiner-api Stage 2 protocol (auto, chat-completions, responses)
--refiner-effort, --effort Stage 2 thinking budget

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


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.18.1

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.18.1
File Size Uploaded Provenance Actions
agent_voice_input-0.18.1.tar.gz 1.5 MB With provenance Details for agent_voice_input-0.18.1.tar.gz

Built distribution (wheel)

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

Total release size: 2.2 MB

Release files / agent_voice_input-0.18.1.tar.gz

Download URL agent_voice_input-0.18.1.tar.gz
Size 1.5 MB
Tags Source
SHA-256 checksum
How to use checksums
4b05cdc3e305a0b5268514dee58b373d17a49598ec83de0b162d9cc7e4a90fbd
BLAKE2b-256 checksum
How to use checksums
d48b023096d97c9233d25acfdc2920fb7132b6b2b90804de3e3f925215bdb155
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 28, 2026.

Transparency log

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

Download URL agent_voice_input-0.18.1-py3-none-any.whl
Size 629.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
be22ae3a03572845f97557f8a98fbb35c8b8f02fe424ae7e48e60e6bb2e4c7fd
BLAKE2b-256 checksum
How to use checksums
e948ab2b77ae13460b9c80d5bcf24ec496ce03365b124d65067ba997684e3a9a
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 28, 2026.

Transparency log

Security for agent-voice-input 0.18.1

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.18.1.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 28, 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