Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions tests/test_tts.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import asyncio
import json
import stat
import sys

import pytest

Expand Down Expand Up @@ -211,6 +212,19 @@ async def test_worker_start_failure_raises():
await failing.start(timeout=5)


async def test_worker_immediate_death_hints_full_disk_access(tmp_path):
"""A worker dying before its ready line is the Full Disk Access signature:
the error must name the fix and the exact Python binary to grant."""
path = tmp_path / "dying-apple-tts"
path.write_text("#!/bin/sh\nexit 1\n")
path.chmod(path.stat().st_mode | stat.S_IEXEC)

worker = TtsWorker(str(path))
with pytest.raises(TtsWorkerError, match="Full Disk Access") as excinfo:
await worker.start(timeout=10)
assert sys.executable in str(excinfo.value)


# --- TtsWorkerPool ---


Expand Down
16 changes: 15 additions & 1 deletion wyoming_apple_speech/tts.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import json
import logging
import re
import sys
from dataclasses import dataclass
from typing import AsyncIterator, Optional

Expand Down Expand Up @@ -236,7 +237,20 @@ async def start(self, timeout: float = 60) -> None:
header = await asyncio.wait_for(self._read_header(), timeout=timeout)
except (asyncio.TimeoutError, TtsWorkerError) as exc:
await self.stop()
raise TtsWorkerError(f"worker did not become ready: {exc}") from exc
message = f"worker did not become ready: {exc}"
if not isinstance(exc, asyncio.TimeoutError):
# The worker's output pipe broke, i.e. the process died at
# startup — the signature of the Python binary lacking Full
# Disk Access (Siri voices load a TCC-protected model cache).
message += (
" — a TTS worker dying at startup usually means the Python"
f" running this server ({sys.executable}) lacks Full Disk"
" Access. Grant it in System Settings → Privacy & Security"
" → Full Disk Access and restart the service; re-grant"
" after every Python upgrade (the path changes). See the"
" README's TTS section."
)
raise TtsWorkerError(message) from exc

if header.get("type") != "ready":
await self.stop()
Expand Down
Loading