feat(hearing): comprehensive VAD decoupling, i18n, and UI refactor#1569
feat(hearing): comprehensive VAD decoupling, i18n, and UI refactor#1569Iris0fTheValley wants to merge 1 commit intomoeru-ai:mainfrom
Conversation
There was a problem hiding this comment.
Code Review
This pull request implements global, persistent Voice Activity Detection (VAD) settings and introduces an 'auto-send' toggle. When auto-send is disabled, transcribed text is broadcast to UI components like ChatArea and InteractiveArea for manual review instead of being sent directly to the backend. The settings interface was also updated with internationalization and a testing playground. Review feedback identifies a potential conflict in the hearing store's callback handling and warns of duplicate text entry if multiple components listen to the broadcast channel simultaneously. Additionally, a reduction in the speechPadMs value was suggested to optimize latency.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c4191e52cf
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
c4191e5 to
27858c0
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 27858c09a6
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
27858c0 to
50b9c72
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 50b9c722d7
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
e34b20c to
a590dbf
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a590dbf8e3
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
⏳ Approval required for deploying to Cloudflare Workers (Preview) for stage-web.
Hey, @nekomeowww, @sumimakito, @luoling8192, @LemonNekoGH, kindly take some time to review and approve this deployment when you are available. Thank you! 🙏 |
a590dbf to
974f36a
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 974f36a73b
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
974f36a to
5f5d236
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5f5d236e47
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
5f5d236 to
53758fc
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 53758fc022
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
53758fc to
c603b66
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c603b66d4d
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
c603b66 to
6f873db
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6f873db6fd
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
6f873db to
cf1fc2e
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: cf1fc2e7df
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
cf1fc2e to
3134b31
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3134b31af1
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
3134b31 to
9c66c1a
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9c66c1ac38
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
9c66c1a to
fe319b0
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: fe319b0d19
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
fe319b0 to
a5fe454
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a5fe45425a
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
a5fe454 to
20b58b6
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 20b58b6280
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
20b58b6 to
f5c8dfa
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f5c8dfaf22
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
f5c8dfa to
e6d8b4f
Compare
- Refactor: Extract VAD \speechPadMs\ and \minSilenceDurationMs\ from hardcoded magic numbers into global \hearingStore\ for dynamic configuration. Increased default \speechPadMs\ to 800ms. - Feature: Retain local playground state for non-destructive VAD testing and implement \�iri-chat-input-commands\ via BroadcastChannel. When \�utoSend\ is disabled, transcribed text is routed to the active message input for manual editing. - Fix: Audio recording pipeline previously bypassed \�utoSendEnabled\ settings. Added explicit state checks in \onStopRecord\ hooks across stage apps. - Chore: Refactored legacy hardcoded English strings to use i18n in hearing.vue. - Style: Migrated touched UI components to array-based UnoCSS bindings and applied \errorMessageFrom\ utility per FP guidelines.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e6d8b4ff6d
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| audioSessionId++ // 废弃所有仍在 inflight 的启动流程 | ||
|
|
||
| // NOTICE: 必须 await 等待录音 finalize 完成并触发回调后,才能卸载钩子,否则最后一句会被丢弃 | ||
| await stopRecord() |
There was a problem hiding this comment.
Run teardown even when stopRecord rejects
stopAudioInteraction() puts the entire teardown sequence behind one try, so if await stopRecord() rejects (for example while the recorder is finalizing during a device/stream transition), execution jumps to catch and skips unregistering hooks, stopping analyzer updates, and disposing VAD. In that failure path the audio pipeline can remain partially active and later restarts become flaky; the rest of teardown should run in a finally (or after a guarded stopRecord) so cleanup is guaranteed. The same pattern appears in the pocket/tamagotchi page implementations.
Useful? React with 👍 / 👎.
Fixes Issues / 修复问题
Fixes https://github.com/moeru-ai/airi/issues/1551
Fixes https://github.com/moeru-ai/airi/issues/1535
Overview / 概览
This PR fundamentally refactors the audio input and VAD (Voice Activity Detection) pipeline to resolve severe truncation issues and auto-send configuration bypasses, while significantly improving the Hearing module's UX and configuration flexibility.
本 PR 从根本上重构了音频输入与 VAD(语音活动检测)的数据流,彻底解决了严重的语音截断问题与自动发送配置失效的 Bug,同时大幅提升了听觉模块的用户体验与配置灵活性。
Key Changes | 主要修改内容
Prevented Truncation & Decoupled VAD Config | 修复截断与解耦 VAD 参数: Increased the hardcoded default speechPadMs to 800ms to successfully prevent initial syllable cutoff. Additionally, extracted minSilenceDurationMs into global hearingStore for dynamic configuration to tolerate natural breathing pauses.
将底层硬编码的前置缓冲 speechPadMs 从 80ms 提升至 800ms,彻底解决了句首辅音被截断(掐头去尾)的问题。同时,将 minSilenceDurationMs 提取至全局 hearingStore 以支持动态配置,容忍说话时正常的换气停顿。
Auto-send Pipeline Fix | 修复自动发送拦截机制: The audio recording pipeline previously bypassed autoSendEnabled settings. Added explicit state checks in onStopRecord hooks across all stage apps (stage-tamagotchi, stage-web, stage-pocket).
修复了录音通道会无视 autoSendEnabled 开关强制发送的 Bug。在所有端(桌面、Web、移动)的 onStopRecord 钩子中均增加了显式的状态拦截。
Cross-Component Text Routing | 跨组件文本流转: Implemented airi-chat-input-commands via BroadcastChannel. When autoSend is disabled, transcribed text is now seamlessly broadcasted to the active message input (ChatArea / InteractiveArea) for manual editing.
基于 BroadcastChannel 实现了 airi-chat-input-commands 文本传送带。当自动发送关闭时,拦截下的转录文本会被广播推送至当前激活的输入框(ChatArea 或 InteractiveArea)中供用户二次编辑。
Parameter Persistence | 参数持久化: Extracted VAD and volume thresholds into persistent global settings in useHearingStore, allowing user preferences to be saved across sessions.
将 VAD 和音量阈值提取到 useHearingStore 的全局持久化设置中,确保用户的偏好配置在不同会话间能够自动保存。
Playground Isolation | 实验区状态隔离: Retained a local state for the VAD testing playground, enabling users to experiment with parameters without immediately affecting global production settings.
为 VAD 测试实验区保留了本地状态,允许用户在不立即改变全局生产配置的情况下尝试各种参数。
Full i18n Support | 完整多语言支持: Refactored all legacy hardcoded English strings in hearing.vue to use the t() function, with complete translation mappings added for both English and Chinese.
重构了 hearing.vue 中所有陈旧的硬编码英文字符串,统一使用 t() 函数调用,并补齐了英文和中文的完整翻译映射。
Code Quality & Style | 代码质量与风格: Migrated touched UI components to use array-based UnoCSS bindings per project guidelines, and applied the errorMessageFrom utility from @moeru/std.
按照项目的最新规范,将受影响的 UI 组件迁移到了基于数组的 UnoCSS 绑定写法,并统一采用了 @moeru/std 提供的 errorMessageFrom。
Additional Context | 补充上下文

VAD vs. Volume: The logic now correctly toggles between Model-based (VAD) and Raw Volume-based detection settings depending on user selection.
逻辑现在可以根据用户的选择,正确地在“基于模型的检测 (VAD)”和“原始音量检测”之间切换。