Skip to content

Graceful TTS degradation + document Full Disk Access requirement - #6

Merged
FI-153 merged 1 commit into
developfrom
feature/tts-graceful-degradation
Jul 15, 2026
Merged

FI-153 merged 1 commit into
developfrom
feature/tts-graceful-degradation

Conversation

@FI-153

@FI-153 FI-153 commented Jul 14, 2026

Copy link
Copy Markdown
Owner

Fixes the TTS failure surfaced as HA ffmpeg invalid start code [0][0][0][0] in RIFF header.

Root cause: neural Siri voices load their model cache from ~/Library/Group Containers/group.com.apple.SiriTTS, a TCC-protected location. A launchd background service without Full Disk Access gets EPERM, so apple-tts workers die on startup. The handler then let TtsWorkerError propagate out of handle_event, crashing the connection and sending HA a half-open/empty stream that ffmpeg rejects.

Changes:

  • Guarded worker acquisition (_acquire_tts_worker) in the synthesize and synthesize-start paths — on failure, emit a clean empty AudioStart/AudioStop envelope instead of crashing the connection. _speak_text skips when no worker is held; its replace+retry is fully guarded.
  • Document the Full Disk Access requirement (install.sh NOTE + README) with the exact fix.

Tests: 2 new handler tests (worker-unavailable → empty envelope, streaming + non-streaming); full suite 72/72, ruff + mypy clean.

For v2.0.0-beta2.

🤖 Generated with Claude Code

When the apple-tts pool can't hand out a worker (e.g. the engine can't load a
voice because the launchd service lacks Full Disk Access to the Siri model
cache), the handler let TtsWorkerError propagate out of handle_event, crashing
the connection mid-stream. Home Assistant then received a half-open/empty audio
stream and ffmpeg failed with "invalid start code [0][0][0][0] in RIFF header".

Acquire the worker through a guarded _acquire_tts_worker() in both the
synthesize and synthesize-start paths: on failure it logs and returns False so
the caller emits a clean empty AudioStart/AudioStop envelope instead. _speak_text
skips when no worker is held and its replace+retry is fully guarded.

Also document the Full Disk Access requirement (install.sh NOTE + README), the
root cause behind the ffmpeg error, since neural Siri voices load their model
cache from the TCC-protected ~/Library/Group Containers/group.com.apple.SiriTTS.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VgEMUdF2PNywdnyfzn4E89
@FI-153
FI-153 merged commit e01ae04 into develop Jul 15, 2026
2 checks passed
@FI-153
FI-153 deleted the feature/tts-graceful-degradation branch July 18, 2026 08:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant