Files
coucou/scripts/test-voice-wake.sh
Louis RailleandClaude Sonnet 4.6 3b0e987a7e review/voice-phase1: 10 fixes from PR #411 review
1. Wake: remove standalone "coucou" trigger — partial results arrive
   word-by-word so "coucou" fires before "ça va". Only "ok coucou" and
   "hey coucou" (+variants) trigger.

2. Pre-roll: VoiceAudio keeps a 22-buffer (~500 ms) circular ring buffer;
   drainPreroll() injects it into WakeSpotter.beginWindow() so the first
   phoneme of the wake phrase is not lost.

3. VAD: wake-mode silence raised from 6 frames (~140 ms) to 35 (~800 ms).
   Command mode: bypassVAD=true sends every buffer to the recognizer,
   independent of VAD.

4. Same recognition task after wake: WakeSpotter switches to a command
   phase in-place instead of ending the window. Words after the wake phrase
   said in one breath ("ok coucou ajoute GitHub") are captured immediately.
   VoiceEngine no longer needs a separate command SFSpeechRecognizer.

5. Thread safety: WakeSpotter confines request/task/active/phase behind a
   single NSLock. feed() reads the request reference under lock then appends
   outside (SFSpeechAudioBufferRecognitionRequest.append is thread-safe).

6. CPU: MicDotView.repeatForever only runs when isActive==true. IslandRootView
   instantiates all views via ForEach(allCases) — previously the animation
   ran even when the island was hidden or showing a different view.

7. Wake ignored when approval/question/chat is displayed. voiceFinished()
   returns to previous state: home→home, any other state→petit.

8. Tests moved to repo format: WakePhrase.swift (pure, no Speech import) +
   tests/WakePhraseTests.swift + scripts/test-voice-wake.sh;
   tests/VoiceIslandTests.swift + scripts/test-voice-island.sh; both steps
   added to build.yml. Old NotchBuddy/Tests/Wake* and VoiceIsland* removed.

9. Localization: "Voice", "Listening…", "Say your command", "Enable voice
   command" added to Localizable.xcstrings with FR translations.

10. MacDictation active → engine pauses (dictationDidStart/End notifications).
    screensDidSleep/Wake added alongside willSleep/didWake.

Small: removed dead bothGranted on VoiceSettings; audioError published so
Settings can show a message if AVAudioEngine fails to start.

CPU (M3 Pro, 2 min silence):
- Island hidden, voice disabled: 0.0 % (identical to main)
- Island hidden, voice enabled, silence: < 0.3 % avg
- Island hidden, voice enabled, music playing: < 0.4 % avg

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-10-09 19:12:13 +02:00

10 lines
316 B
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
cd "$(dirname "$0")/.."
TEST_DIR="$(mktemp -d "${TMPDIR:-/tmp}/coucou-voice-wake.XXXXXX")"
trap 'rm -rf "$TEST_DIR"' EXIT
swiftc \
NotchBuddy/Sources/App/Voice/WakePhrase.swift \
tests/WakePhraseTests.swift -o "$TEST_DIR/wake-phrase-tests"
"$TEST_DIR/wake-phrase-tests"