From 964123682fd482f74f879e8be8c2849693635839 Mon Sep 17 00:00:00 2001 From: javis-bot Date: Tue, 9 Jun 2026 16:16:55 +0900 Subject: [PATCH] Review fixes: correct Piper TTS API + bot env gating Code review of the bridge/bot/docker work found: - TTS bug: bridge called PiperVoice.synthesize(text, wav) but that method returns AudioChunks and takes a SynthesisConfig as its 2nd arg, not a wav file -> TTS would fail. Switched to synthesize_wav(text, wav_file). Verified: produces a valid 22050Hz mono WAV. - run-bot.sh now waits if ANY of DISCORD_BOT_TOKEN/APP_ID/GUILD_ID is missing (config.ts throws on a missing one), preventing a supervisor crash-loop. Verified clean: discord.js Events.ClientReady == 'clientReady' (existing handler correct); image rebuilds. --- bridge/server.py | 5 ++++- docker/run-bot.sh | 7 +++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/bridge/server.py b/bridge/server.py index 5f46c0d..c68b798 100644 --- a/bridge/server.py +++ b/bridge/server.py @@ -197,7 +197,10 @@ def synthesize(text: str) -> Optional[bytes]: return None buf = io.BytesIO() with wave.open(buf, "wb") as wf: - _piper_voice.synthesize(text, wf) + # piper-tts API: synthesize_wav(text, wav_file) writes a full WAV; + # plain synthesize() returns AudioChunks and takes a SynthesisConfig + # (NOT a wav file) as its 2nd arg. + _piper_voice.synthesize_wav(text, wf) return buf.getvalue() diff --git a/docker/run-bot.sh b/docker/run-bot.sh index a67c9a8..1ad801b 100755 --- a/docker/run-bot.sh +++ b/docker/run-bot.sh @@ -7,8 +7,11 @@ set -e cd /app/bot -if [ -z "${DISCORD_BOT_TOKEN:-}" ]; then - echo "[bot] DISCORD_BOT_TOKEN 미설정 — 봇 대기 중. .env에 토큰을 넣고 'docker compose up -d' 하면 시작됩니다." +# The bot needs all three to log in AND register slash commands. If any is +# missing, wait instead of crash-looping (config.ts throws on a missing var). +if [ -z "${DISCORD_BOT_TOKEN:-}" ] || [ -z "${DISCORD_APP_ID:-}" ] || [ -z "${DISCORD_GUILD_ID:-}" ]; then + echo "[bot] DISCORD_BOT_TOKEN/DISCORD_APP_ID/DISCORD_GUILD_ID 중 일부 미설정 — 봇 대기 중." + echo "[bot] .env에 셋 다 넣고 'docker compose up -d' 하면 시작됩니다." echo "[bot] (그동안 VNC 데스크톱 / 브릿지 / Ollama 는 정상 동작합니다.)" exec sleep infinity fi