Skip to content

Commit 159e67f

Browse files
Mikarina13claude
andcommitted
fix(tts_say): read tts_model from config (was kokoro_model) + WAV format
Bug: skill was reading config key "kokoro_model" but ~/.codec/config.json stores it under "tts_model". Fell back to literal string "kokoro" which mlx-audio rejects with HTTP 500, silently degrading to macOS `say` voice on every MCP tts_say invocation. Fix: - Read tts_model first, fall back to legacy kokoro_model, then sane default - Request response_format: wav explicitly - Save tempfile with .wav extension (mlx-audio returns PCM WAV at 24kHz) - Bump timeout 20s -> 30s for first-token latency on cold model Verified: Kokoro TTS now plays real Kokoro voice (bm_george/am_adam/af_bella) on both direct CLI test and MCP invocation from claude.ai. Also fixed during same sweep (n8n, not in repo): - Daily Report.MF workflow had YOUR_LOCAL_IP placeholder -> 192.168.1.73 - Lucy QWEN 5.1/5.2 workflows pointed doc-extract at kokoro port -> 8086 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 32a0716 commit 159e67f

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

skills/tts_say.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
_cfg = {}
1818

1919
KOKORO_URL = _cfg.get("tts_url", "http://localhost:8085/v1/audio/speech")
20-
KOKORO_MODEL = _cfg.get("kokoro_model", "kokoro")
20+
# Read "tts_model" (canonical key in config.json), fall back to legacy "kokoro_model"
21+
KOKORO_MODEL = _cfg.get("tts_model", _cfg.get("kokoro_model", "mlx-community/Kokoro-82M-bf16"))
2122
TTS_VOICE = _cfg.get("tts_voice", "af_bella")
2223

2324
_WRITE_VERBS = (
@@ -54,16 +55,21 @@ def run(task, app="", ctx=""):
5455
try:
5556
resp = requests.post(
5657
KOKORO_URL,
57-
json={"model": KOKORO_MODEL, "input": clean, "voice": TTS_VOICE},
58+
json={
59+
"model": KOKORO_MODEL,
60+
"input": clean,
61+
"voice": TTS_VOICE,
62+
"response_format": "wav",
63+
},
5864
stream=True,
59-
timeout=20,
65+
timeout=30,
6066
)
6167
if resp.status_code != 200:
6268
# Fallback to macOS say
6369
subprocess.Popen(["say", clean])
6470
return f"🔊 (fallback) Speaking: {clean}"
6571

66-
tmp = tempfile.NamedTemporaryFile(suffix=".mp3", delete=False)
72+
tmp = tempfile.NamedTemporaryFile(suffix=".wav", delete=False)
6773
for chunk in resp.iter_content(chunk_size=4096):
6874
tmp.write(chunk)
6975
tmp.close()

0 commit comments

Comments
 (0)