feat: 音频活动阈值开放为用户可设的灵敏度档位 - #99
Merged
Merged
Conversation
Add two independent sensitivity presets (conservative/standard/sensitive) in the Audio settings section: one for the recording gate (hasMeaningfulAudio) and one for the weak-speech heuristic. Standard resolves exactly to the shipped defaults, so existing users keep their behavior. Settings persist via UserDefaults, unknown raw values fall back to standard, and resolved thresholds are clamped to safe bounds. VoicePipeline and InputSessionCoordinator read the resolved thresholds before each recording, so changes apply without a restart. The diagnostics switch and release behavior are untouched. Co-authored-by: multica-agent <github@multica.ai>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
背景
接 #95:
AudioActivityThresholds已把闸门与弱语音启发式解耦,本轮把它开放给用户,用「灵敏度」档位而非原始 RMS。改动
设置面(General → 音频区)新增两个独立档位,各 3 档(保守 / 标准 / 灵敏):
gate(语音检测)avg / peakweakSpeechEvidence(低音量清理)avg / peak持久化、校验与生效
AppSettings新增audioGateSensitivity/audioWeakSpeechSensitivity,沿用@Published+ UserDefaults 持久化约定。standard;解析出的阈值经AudioActivityThresholds.clamped做上下限截断([0.0001, 0.05],非有限值回退默认)。VoicePipeline与InputSessionCoordinator在每次录音开始前读取settings.audioActivityThresholds写入AudioCaptureManager.thresholds,修改后即时生效、无需重启。UTTER_AUDIO_DIAGNOSTICS)与 release 行为。测试
新增
Tests/OpenTypeTests/AudioSensitivityThresholdTests.swift(6 条):hasWeakSpeechEvidence(refactor: 音频活动阈值解耦 + RMS 诊断(不改默认数值,release 不输出) #95 解耦语义)。结果:
swift build→Build complete! (4.27 secs)Processing|Speech|Sanitizer|Audio|Configuration|Voice|Text|Prompt|Lexicon|Integration|Recognition|Transcript|Whisper|ASR|Guard|Fidelity|Replacement|Output|Sensitivity→ 434 passed / 7 skipped / 0 failuresplutil -lint两份Localizable.strings均 OK。范围
10 个文件(7 源 + 2 本地化 + 1 测试),未改护栏、ASR 引擎与诊断逻辑。