agent-voice-input 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. agent_voice_input-0.1.0/LICENSE +191 -0
  2. agent_voice_input-0.1.0/MANIFEST.in +5 -0
  3. agent_voice_input-0.1.0/PKG-INFO +118 -0
  4. agent_voice_input-0.1.0/README.md +94 -0
  5. agent_voice_input-0.1.0/README.zh-CN.md +94 -0
  6. agent_voice_input-0.1.0/bin/agent-voice-input +15 -0
  7. agent_voice_input-0.1.0/config.example.env +23 -0
  8. agent_voice_input-0.1.0/config.example.toml +59 -0
  9. agent_voice_input-0.1.0/integrations/README.md +87 -0
  10. agent_voice_input-0.1.0/integrations/README.zh-CN.md +87 -0
  11. agent_voice_input-0.1.0/integrations/claude/settings.hooks.json +24 -0
  12. agent_voice_input-0.1.0/integrations/claude/voice-title.sh +8 -0
  13. agent_voice_input-0.1.0/integrations/codex/config.toml +3 -0
  14. agent_voice_input-0.1.0/integrations/gemini/hooks.json +18 -0
  15. agent_voice_input-0.1.0/pyproject.toml +47 -0
  16. agent_voice_input-0.1.0/setup.cfg +4 -0
  17. agent_voice_input-0.1.0/src/agent_voice_input/__init__.py +6 -0
  18. agent_voice_input-0.1.0/src/agent_voice_input/asr_providers.py +1638 -0
  19. agent_voice_input-0.1.0/src/agent_voice_input/audio_proc.py +313 -0
  20. agent_voice_input-0.1.0/src/agent_voice_input/cli.py +287 -0
  21. agent_voice_input-0.1.0/src/agent_voice_input/config.py +1441 -0
  22. agent_voice_input-0.1.0/src/agent_voice_input/daemon.py +326 -0
  23. agent_voice_input-0.1.0/src/agent_voice_input/platform_macos.py +100 -0
  24. agent_voice_input-0.1.0/src/agent_voice_input/platform_wsl.py +407 -0
  25. agent_voice_input-0.1.0/src/agent_voice_input/refiner.py +292 -0
  26. agent_voice_input-0.1.0/src/agent_voice_input/session_ctx.py +2081 -0
  27. agent_voice_input-0.1.0/src/agent_voice_input/session_title.py +321 -0
  28. agent_voice_input-0.1.0/src/agent_voice_input/win_shim.ps1 +527 -0
  29. agent_voice_input-0.1.0/src/agent_voice_input.egg-info/PKG-INFO +118 -0
  30. agent_voice_input-0.1.0/src/agent_voice_input.egg-info/SOURCES.txt +36 -0
  31. agent_voice_input-0.1.0/src/agent_voice_input.egg-info/dependency_links.txt +1 -0
  32. agent_voice_input-0.1.0/src/agent_voice_input.egg-info/entry_points.txt +2 -0
  33. agent_voice_input-0.1.0/src/agent_voice_input.egg-info/top_level.txt +1 -0
  34. agent_voice_input-0.1.0/tests/__init__.py +1 -0
  35. agent_voice_input-0.1.0/tests/test_asr_and_session.py +1355 -0
  36. agent_voice_input-0.1.0/tests/test_config_and_audio.py +726 -0
  37. agent_voice_input-0.1.0/tests/test_refiner_and_daemon.py +1055 -0
  38. agent_voice_input-0.1.0/tests/test_title_hooks.py +496 -0
@@ -0,0 +1,191 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ Copyright 2026 xiaohuaxi
180
+
181
+ Licensed under the Apache License, Version 2.0 (the "License");
182
+ you may not use this file except in compliance with the License.
183
+ You may obtain a copy of the License at
184
+
185
+ http://www.apache.org/licenses/LICENSE-2.0
186
+
187
+ Unless required by applicable law or agreed to in writing, software
188
+ distributed under the License is distributed on an "AS IS" BASIS,
189
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
190
+ See the License for the specific language governing permissions and
191
+ limitations under the License.
@@ -0,0 +1,5 @@
1
+ include LICENSE README.md README.zh-CN.md config.example.toml config.example.env
2
+ include bin/agent-voice-input
3
+ recursive-include integrations *
4
+ recursive-include tests *.py
5
+ global-exclude __pycache__ *.py[cod]
@@ -0,0 +1,118 @@
1
+ Metadata-Version: 2.4
2
+ Name: agent-voice-input
3
+ Version: 0.1.0
4
+ Summary: Two-stage context-aware voice input for CLI coding agents.
5
+ License-Expression: Apache-2.0
6
+ Project-URL: Homepage, https://github.com/xiaohuaxi/agent-voice-input
7
+ Project-URL: Repository, https://github.com/xiaohuaxi/agent-voice-input
8
+ Project-URL: Issues, https://github.com/xiaohuaxi/agent-voice-input/issues
9
+ Keywords: voice-input,asr,speech-to-text,cli-agent,codex,claude-code,wsl2
10
+ Classifier: Development Status :: 4 - Beta
11
+ Classifier: Environment :: Console
12
+ Classifier: Operating System :: POSIX :: Linux
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3.10
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Programming Language :: Python :: 3.13
18
+ Classifier: Topic :: Software Development :: User Interfaces
19
+ Classifier: Topic :: Multimedia :: Sound/Audio :: Speech
20
+ Requires-Python: >=3.10
21
+ Description-Content-Type: text/markdown
22
+ License-File: LICENSE
23
+ Dynamic: license-file
24
+
25
+ [English](README.md) | [简体中文](README.zh-CN.md)
26
+
27
+ # agent-voice-input
28
+
29
+ Context-aware voice input for CLI coding agents (such as **Codex**, **Claude Code**, and **Antigravity CLI / `agy`**).
30
+
31
+ Instead of treating terminal dictation like generic chat input, `agent-voice-input` pairs fast speech recognition with lightweight refinement grounded in your active coding session—fixing homophone identifiers, mixed Chinese–English technical terms, and spoken self-corrections before pasting safely into the terminal.
32
+
33
+ > **Early Release (`v0.1.0`)**: This project currently provides a foundational setup verified primarily on **Windows Terminal + WSL2 (including Remote Desktop)**. Broader terminal support, deeper `tmux` integration, native macOS terminal polish, and more flexible Stage 2 model choices are actively in progress.
34
+
35
+ ---
36
+
37
+ ## How It Works
38
+
39
+ 1. **Active Session Context**: Locates the foreground agent session (via optional terminal title tags or `/proc` root-session scanning while ignoring background subagents) and extracts recent dialogue plus `git status` filenames as context.
40
+ 2. **Stage 1 — Speech Recognition**: Applies a local silence gate (`-50 dBFS`) and RMS loudness normalization (`-20 dBFS`), then transcribes audio via cloud ASR (defaults to Alibaba Bailian `qwen3-asr-flash`; also supports Volcengine Doubao, Gemini, or OpenAI-compatible endpoints).
41
+ 3. **Stage 2 — Lightweight Context Refinement**: Cleans up technical terms and explicit spoken self-corrections against the extracted session context. For now, Stage 2 defaults to invoking a lightweight model through local Codex CLI (`codex-luna`), and can also be pointed to an OpenAI-compatible API or turned off (`off`).
42
+ 4. **Focus-Safe Paste**: Shows recording/recognition/refinement stages in a non-activating HUD pill on Windows, verifies terminal focus right before pasting (never auto-pressing Enter), and keeps text in the clipboard only if you switched to another window.
43
+ 5. **Lightweight Setup**: Currently relies only on the Python 3.10+ standard library plus host `ffmpeg` (and built-in `powershell.exe` on WSL2), requiring no extra Python packages.
44
+
45
+ ---
46
+
47
+ ## Quick Start
48
+
49
+ ### 1. Prerequisites
50
+
51
+ - **Python** `>= 3.10`
52
+ - **ffmpeg** (`sudo apt install ffmpeg` on Ubuntu/WSL2)
53
+
54
+ ### 2. Install
55
+
56
+ ```bash
57
+ uv tool install agent-voice-input
58
+ # Or with pipx / pip:
59
+ # pipx install agent-voice-input
60
+ ```
61
+
62
+ For local development from source:
63
+
64
+ ```bash
65
+ git clone https://github.com/xiaohuaxi/agent-voice-input.git ~/repos/agent-voice-input
66
+ mkdir -p ~/.local/bin
67
+ ln -s ~/repos/agent-voice-input/bin/agent-voice-input ~/.local/bin/agent-voice-input
68
+ ```
69
+
70
+ ### 3. Configure
71
+
72
+ Create `~/.config/agent-voice-input/agent-voice-input.env` (or export variables in your shell) with at least one Stage 1 ASR key:
73
+
74
+ ```bash
75
+ mkdir -p ~/.config/agent-voice-input && chmod 700 ~/.config/agent-voice-input
76
+ cat > ~/.config/agent-voice-input/agent-voice-input.env <<'EOF'
77
+ ALI_API_KEY="<your-dashscope-api-key>"
78
+ EOF
79
+ chmod 600 ~/.config/agent-voice-input/agent-voice-input.env
80
+ ```
81
+
82
+ Other supported credentials include `DOUBAO_ASR_APP_ID` + `DOUBAO_ASR_API_KEY` (Doubao), `GEMINI_API_KEY`, and `OPENAI_API_KEY`. To customize hotkeys, ASR models, or Stage 2 refinement (such as running without Codex CLI via `refiner.provider = "openai-compatible"` or `"off"`), copy [`config.example.toml`](config.example.toml) to `~/.config/agent-voice-input/config.toml` (also see [`config.example.env`](config.example.env)).
83
+
84
+ ### 4. Verify & Run
85
+
86
+ ```bash
87
+ # Check audio bridge, credentials, and session detection
88
+ agent-voice-input doctor
89
+
90
+ # Start background daemon (defaults to isolated Right Ctrl tap on WSL2)
91
+ agent-voice-input start
92
+
93
+ # Other common commands
94
+ agent-voice-input status
95
+ agent-voice-input toggle
96
+ agent-voice-input once --duration 4 --dry-run
97
+ agent-voice-input stop
98
+ ```
99
+
100
+ ### Optional: Multi-Window Session Title Hooks
101
+
102
+ If you run multiple agent windows side by side in the same directory, see [`integrations/`](integrations/README.md) for optional terminal title hooks for Codex, Claude Code, and Antigravity CLI.
103
+
104
+ ---
105
+
106
+ ## Development
107
+
108
+ ```bash
109
+ PYTHONPATH=src python3 -m unittest discover -s tests -v
110
+ ```
111
+
112
+ ## Acknowledgments
113
+
114
+ Early exploration for this project was inspired by [`Einstellung/voice-asr`](https://github.com/Einstellung/voice-asr), particularly around pairing `Qwen3-ASR` with technical terminology context biasing for mixed Chinese–English speech, as well as pre-transcription silence gating and loudness normalization.
115
+
116
+ ## License
117
+
118
+ [Apache-2.0 License](LICENSE)
@@ -0,0 +1,94 @@
1
+ [English](README.md) | [简体中文](README.zh-CN.md)
2
+
3
+ # agent-voice-input
4
+
5
+ Context-aware voice input for CLI coding agents (such as **Codex**, **Claude Code**, and **Antigravity CLI / `agy`**).
6
+
7
+ Instead of treating terminal dictation like generic chat input, `agent-voice-input` pairs fast speech recognition with lightweight refinement grounded in your active coding session—fixing homophone identifiers, mixed Chinese–English technical terms, and spoken self-corrections before pasting safely into the terminal.
8
+
9
+ > **Early Release (`v0.1.0`)**: This project currently provides a foundational setup verified primarily on **Windows Terminal + WSL2 (including Remote Desktop)**. Broader terminal support, deeper `tmux` integration, native macOS terminal polish, and more flexible Stage 2 model choices are actively in progress.
10
+
11
+ ---
12
+
13
+ ## How It Works
14
+
15
+ 1. **Active Session Context**: Locates the foreground agent session (via optional terminal title tags or `/proc` root-session scanning while ignoring background subagents) and extracts recent dialogue plus `git status` filenames as context.
16
+ 2. **Stage 1 — Speech Recognition**: Applies a local silence gate (`-50 dBFS`) and RMS loudness normalization (`-20 dBFS`), then transcribes audio via cloud ASR (defaults to Alibaba Bailian `qwen3-asr-flash`; also supports Volcengine Doubao, Gemini, or OpenAI-compatible endpoints).
17
+ 3. **Stage 2 — Lightweight Context Refinement**: Cleans up technical terms and explicit spoken self-corrections against the extracted session context. For now, Stage 2 defaults to invoking a lightweight model through local Codex CLI (`codex-luna`), and can also be pointed to an OpenAI-compatible API or turned off (`off`).
18
+ 4. **Focus-Safe Paste**: Shows recording/recognition/refinement stages in a non-activating HUD pill on Windows, verifies terminal focus right before pasting (never auto-pressing Enter), and keeps text in the clipboard only if you switched to another window.
19
+ 5. **Lightweight Setup**: Currently relies only on the Python 3.10+ standard library plus host `ffmpeg` (and built-in `powershell.exe` on WSL2), requiring no extra Python packages.
20
+
21
+ ---
22
+
23
+ ## Quick Start
24
+
25
+ ### 1. Prerequisites
26
+
27
+ - **Python** `>= 3.10`
28
+ - **ffmpeg** (`sudo apt install ffmpeg` on Ubuntu/WSL2)
29
+
30
+ ### 2. Install
31
+
32
+ ```bash
33
+ uv tool install agent-voice-input
34
+ # Or with pipx / pip:
35
+ # pipx install agent-voice-input
36
+ ```
37
+
38
+ For local development from source:
39
+
40
+ ```bash
41
+ git clone https://github.com/xiaohuaxi/agent-voice-input.git ~/repos/agent-voice-input
42
+ mkdir -p ~/.local/bin
43
+ ln -s ~/repos/agent-voice-input/bin/agent-voice-input ~/.local/bin/agent-voice-input
44
+ ```
45
+
46
+ ### 3. Configure
47
+
48
+ Create `~/.config/agent-voice-input/agent-voice-input.env` (or export variables in your shell) with at least one Stage 1 ASR key:
49
+
50
+ ```bash
51
+ mkdir -p ~/.config/agent-voice-input && chmod 700 ~/.config/agent-voice-input
52
+ cat > ~/.config/agent-voice-input/agent-voice-input.env <<'EOF'
53
+ ALI_API_KEY="<your-dashscope-api-key>"
54
+ EOF
55
+ chmod 600 ~/.config/agent-voice-input/agent-voice-input.env
56
+ ```
57
+
58
+ Other supported credentials include `DOUBAO_ASR_APP_ID` + `DOUBAO_ASR_API_KEY` (Doubao), `GEMINI_API_KEY`, and `OPENAI_API_KEY`. To customize hotkeys, ASR models, or Stage 2 refinement (such as running without Codex CLI via `refiner.provider = "openai-compatible"` or `"off"`), copy [`config.example.toml`](config.example.toml) to `~/.config/agent-voice-input/config.toml` (also see [`config.example.env`](config.example.env)).
59
+
60
+ ### 4. Verify & Run
61
+
62
+ ```bash
63
+ # Check audio bridge, credentials, and session detection
64
+ agent-voice-input doctor
65
+
66
+ # Start background daemon (defaults to isolated Right Ctrl tap on WSL2)
67
+ agent-voice-input start
68
+
69
+ # Other common commands
70
+ agent-voice-input status
71
+ agent-voice-input toggle
72
+ agent-voice-input once --duration 4 --dry-run
73
+ agent-voice-input stop
74
+ ```
75
+
76
+ ### Optional: Multi-Window Session Title Hooks
77
+
78
+ If you run multiple agent windows side by side in the same directory, see [`integrations/`](integrations/README.md) for optional terminal title hooks for Codex, Claude Code, and Antigravity CLI.
79
+
80
+ ---
81
+
82
+ ## Development
83
+
84
+ ```bash
85
+ PYTHONPATH=src python3 -m unittest discover -s tests -v
86
+ ```
87
+
88
+ ## Acknowledgments
89
+
90
+ Early exploration for this project was inspired by [`Einstellung/voice-asr`](https://github.com/Einstellung/voice-asr), particularly around pairing `Qwen3-ASR` with technical terminology context biasing for mixed Chinese–English speech, as well as pre-transcription silence gating and loudness normalization.
91
+
92
+ ## License
93
+
94
+ [Apache-2.0 License](LICENSE)
@@ -0,0 +1,94 @@
1
+ [English](README.md) | [简体中文](README.zh-CN.md)
2
+
3
+ # agent-voice-input
4
+
5
+ 面向命令行 Coding Agent(如 **Codex**、**Claude Code**、**Antigravity CLI / `agy`**)的语境感知语音输入工具。
6
+
7
+ 不同于缺乏代码上下文的通用语音输入法,`agent-voice-input` 采用「极速语音识别 + 结合当前活跃会话上下文的轻量精修」两阶段设计,在粘贴进终端前自动修准同音代码标识符、中英混说术语与口语中途改口。
8
+
9
+ > **早期版本说明(`v0.1.0`)**:当前版本刚搭好基础框架并跑通核心特性,目前主要在 **Windows Terminal + WSL2(含远程桌面)** 下完成打磨与日常验证;更多终端支持、`tmux` 深度配合、macOS 常用终端真机完善以及更灵活的二阶段精修模型选择等工作仍在持续推进中。
10
+
11
+ ---
12
+
13
+ ## 核心思路
14
+
15
+ 1. **活跃会话上下文抽取**:自动定位前台终端中的主 Agent 会话(支持可选终端标题标签,或通过 `/proc` 扫描并排除后台 subagent),增量提取近期对话与 `git status` 文件名作为上下文参考。
16
+ 2. **一阶段语音识别(ASR)**:先在本地做 `-50 dBFS` 静音门控与 `-20 dBFS` 响度归一化,再调用云端语音识别(默认阿里百炼 `qwen3-asr-flash`,亦支持火山豆包、Gemini 或 OpenAI 兼容接口)。
17
+ 3. **二阶段轻量语境精修**:结合抽取出的会话上下文修正同音标识符并理顺口语改口。目前暂时默认通过本地 Codex CLI 调用轻量模型(`codex-luna`)完成整理,也可在配置中切换为 OpenAI 兼容接口或直接关闭(`off`)。
18
+ 4. **焦点安全粘贴**:Windows 下通过无焦点抢占的顶部胶囊显示录音、识别、精修阶段;上屏前核对终端焦点,仅粘贴不自动按回车,若中途切到其他窗口则只写入剪贴板。
19
+ 5. **依赖精简**:当前仅使用 Python 3.10+ 标准库与宿主机 `ffmpeg`(WSL2 下复用系统自带 `powershell.exe`),无需额外安装第三方 Python 包。
20
+
21
+ ---
22
+
23
+ ## 快速开始
24
+
25
+ ### 1. 前置条件
26
+
27
+ - **Python** `>= 3.10`
28
+ - **ffmpeg**(Ubuntu / WSL2 执行 `sudo apt install ffmpeg`)
29
+
30
+ ### 2. 安装
31
+
32
+ ```bash
33
+ uv tool install agent-voice-input
34
+ # 或使用 pipx / pip:
35
+ # pipx install agent-voice-input
36
+ ```
37
+
38
+ 从源码本地软链开发:
39
+
40
+ ```bash
41
+ git clone https://github.com/xiaohuaxi/agent-voice-input.git ~/repos/agent-voice-input
42
+ mkdir -p ~/.local/bin
43
+ ln -s ~/repos/agent-voice-input/bin/agent-voice-input ~/.local/bin/agent-voice-input
44
+ ```
45
+
46
+ ### 3. 配置
47
+
48
+ 在 `~/.config/agent-voice-input/agent-voice-input.env`(或直接通过环境变量)配置至少一项一阶段语音识别凭据即可启动:
49
+
50
+ ```bash
51
+ mkdir -p ~/.config/agent-voice-input && chmod 700 ~/.config/agent-voice-input
52
+ cat > ~/.config/agent-voice-input/agent-voice-input.env <<'EOF'
53
+ ALI_API_KEY="<your-dashscope-api-key>"
54
+ EOF
55
+ chmod 600 ~/.config/agent-voice-input/agent-voice-input.env
56
+ ```
57
+
58
+ 除 `ALI_API_KEY`(百炼)外,也支持 `DOUBAO_ASR_APP_ID` + `DOUBAO_ASR_API_KEY`(豆包)、`GEMINI_API_KEY` 或 `OPENAI_API_KEY`(详见 [`config.example.env`](config.example.env))。如需自定义快捷键、模型或未安装 Codex CLI 时改用 `openai-compatible` / 关闭二阶段精修(`off`),可将 [`config.example.toml`](config.example.toml) 保存为 `~/.config/agent-voice-input/config.toml` 按需修改。
59
+
60
+ ### 4. 自检与运行
61
+
62
+ ```bash
63
+ # 检查音频桥接、凭据与会话识别状态
64
+ agent-voice-input doctor
65
+
66
+ # 启动后台守护进程(WSL2 下默认点按右 Ctrl 开始/结束录音)
67
+ agent-voice-input start
68
+
69
+ # 其它常用子命令
70
+ agent-voice-input status
71
+ agent-voice-input toggle
72
+ agent-voice-input once --duration 4 --dry-run
73
+ agent-voice-input stop
74
+ ```
75
+
76
+ ### 可选:多窗口会话标题钩子
77
+
78
+ 若常在同一项目目录下并行打开多个 Agent 终端窗口,可按 [`integrations/`](integrations/README.zh-CN.md) 为 Codex、Claude Code 或 Antigravity CLI 接入轻量终端标题标签。
79
+
80
+ ---
81
+
82
+ ## 开发与测试
83
+
84
+ ```bash
85
+ PYTHONPATH=src python3 -m unittest discover -s tests -v
86
+ ```
87
+
88
+ ## 致谢
89
+
90
+ 本项目早期探索受到 [`Einstellung/voice-asr`](https://github.com/Einstellung/voice-asr) 的启发,尤其是将 `Qwen3-ASR` 与技术术语上下文偏置结合以改善中英混说识别,以及转写前的静音门控与响度归一化思路,特此致谢。
91
+
92
+ ## License
93
+
94
+ [Apache-2.0 License](LICENSE)
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env python3
2
+ """Lightweight zero-install CLI wrapper for agent-voice-input."""
3
+ from __future__ import annotations
4
+
5
+ from pathlib import Path
6
+ import sys
7
+
8
+ _SRC_DIR = Path(__file__).resolve().parent.parent / "src"
9
+ if _SRC_DIR.is_dir() and str(_SRC_DIR) not in sys.path:
10
+ sys.path.insert(0, str(_SRC_DIR))
11
+
12
+ from agent_voice_input.cli import main # noqa: E402
13
+
14
+ if __name__ == "__main__":
15
+ raise SystemExit(main())
@@ -0,0 +1,23 @@
1
+ # agent-voice-input credential environment template
2
+ # Default location: ~/.config/agent-voice-input/agent-voice-input.env (chmod 600 recommended)
3
+ # Also falls back to ~/.config/voice-input/voice-input.env or process environment variables
4
+ # Naming rule: suffix style preferred (<VENDOR>_API_KEY); prefix aliases (API_KEY_<VENDOR>) also supported
5
+
6
+ # 1. Alibaba Cloud Bailian / DashScope (default Stage 1 provider: qwen3-asr-flash)
7
+ ALI_API_KEY="<your-dashscope-api-key>"
8
+ # Supported aliases: API_KEY_ALI / DASHSCOPE_API_KEY
9
+
10
+ # 2. Volcengine Doubao Speech (optional Stage 1 provider; requires both APP_ID and API_KEY)
11
+ DOUBAO_ASR_APP_ID="<your-volcengine-speech-app-id>"
12
+ DOUBAO_ASR_API_KEY="<your-volcengine-speech-access-token>"
13
+ # Supported aliases: APP_ID_DOUBAO_ASR / API_KEY_DOUBAO_ASR
14
+
15
+ # 3. Volcengine Ark (used when refiner.provider = "openai-compatible" points to volces.com)
16
+ HUOSHAN_API_KEY="<your-volcengine-ark-api-key>"
17
+ # Supported aliases: API_KEY_HUOSHAN / ARK_API_KEY
18
+
19
+ # 4. Google Gemini (used when asr.provider = "gemini" for single-hop audio + context transcription)
20
+ GEMINI_API_KEY="<your-gemini-api-key>"
21
+
22
+ # 5. OpenAI or OpenAI-compatible endpoints (used when asr/refiner uses openai-compatible)
23
+ OPENAI_API_KEY="<your-openai-api-key>"
@@ -0,0 +1,59 @@
1
+ # agent-voice-input example configuration
2
+ # Default location: ~/.config/agent-voice-input/config.toml (also falls back to ~/.config/voice-input/config.toml)
3
+ # Or specify explicitly via --config / AGENT_VOICE_INPUT_CONFIG
4
+
5
+ [hotkey]
6
+ # Windows global hotkey: RControl (default Right Ctrl, 0xA3) | RAlt | RShift | CapsLock | F1..F24 | 0xNN
7
+ key = "RControl"
8
+ # Trigger mode:
9
+ # - "tap_toggle": isolated tap toggles recording start/stop (chords such as RControl+C pass through untouched)
10
+ # - "ptt": push-to-talk (hold to speak, release to transcribe; pressing another key cancels)
11
+ trigger_mode = "tap_toggle"
12
+ tap_max_ms = 1200
13
+ debounce_ms = 180
14
+
15
+ [audio]
16
+ # Silence gate & RMS loudness normalization (pure stdlib; blocks accidental empty triggers before hitting cloud APIs)
17
+ floor_dbfs = -50.0
18
+ target_dbfs = -20.0
19
+ max_gain_db = 40.0
20
+ min_duration_sec = 0.3
21
+ min_voiced_sec = 0.1
22
+ # WSL2 capture source: "auto" (defaults to resident win_shim Windows WASAPI 16 kHz capture, avoiding WSLg RDPSource zero-packet deadlocks) | "wasapi" | "winmm" | "pulse"
23
+ wsl_source = "auto"
24
+ # Start/stop audio cue is disabled by default to avoid 1-2s RDP audio wake-up lag; enable locally if desired
25
+ beep = false
26
+ # Tail drain seconds after stopping recording (auto-adapts by platform when unset: 0.65s on WSL2/RDP, 0.20s on macOS)
27
+ # tail_drain_sec = 0.65
28
+
29
+ [asr]
30
+ # Stage 1 speech-to-text provider: "auto" | "ali" | "doubao" | "gemini" | "openai-compatible"
31
+ provider = "auto"
32
+ # Leave empty to select each provider's default model automatically:
33
+ # - ali -> "qwen3-asr-flash" (also supports "fun-asr-realtime" / "qwen-audio-3.0")
34
+ # - doubao -> "bigmodel"
35
+ # - gemini -> "gemini-2.5-flash" (single-hop audio + context refinement; skips Stage 2 by default)
36
+ # - openai-compatible -> "gpt-4o-transcribe" (or a local faster-whisper-server model name)
37
+ model = ""
38
+ # Doubao resource slot: "auto" (auto-probes and caches available slot) or explicit e.g. "volc.seedasr.auc"
39
+ resource_id = "auto"
40
+ base_url = ""
41
+ api_key_env = ""
42
+ hotwords_file = "~/.config/agent-voice-input/hotwords.txt"
43
+ timeout_sec = 15.0
44
+
45
+ [refiner]
46
+ # Stage 2 context-aware refinement engine:
47
+ # - "codex-luna" (default: resident codex app-server in-memory thread paired with a lightweight fast model)
48
+ # - "openai-compatible"
49
+ # - "off"
50
+ provider = "codex-luna"
51
+ model = "gpt-6-luna"
52
+ effort = "low"
53
+ # When provider = "openai-compatible", point base_url to Volcengine Ark / OpenAI / a local server:
54
+ # base_url = "https://ark.cn-beijing.volces.com/api/v3"
55
+ base_url = ""
56
+ api_key_env = ""
57
+ max_turns_per_thread = 20
58
+ timeout_sec = 12.0
59
+ force_on_single_hop = false