fix: update Piper TTS endpoint and request format

Piper is on 192.168.129.9:5100, not :5000. It expects POST with
JSON body {"text": "..."}, not GET with query params. Also update
Whisper default to 192.168.129.9.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
user
2026-02-22 04:56:24 +01:00
parent 9783365b1e
commit eded764f6a

View File

@@ -14,7 +14,6 @@ import logging
import threading
import time
import wave
from urllib.parse import quote_plus
import urllib.request
from derp.http import urlopen as _urlopen
@@ -36,8 +35,8 @@ _MAX_BYTES = int(_MAX_DURATION * _SAMPLE_RATE * _SAMPLE_WIDTH)
_FLUSH_INTERVAL = 0.5 # flush monitor poll interval
_MAX_SAY_LEN = 500 # max characters for !say
_WHISPER_URL = "http://192.168.122.1:8080/inference"
_PIPER_URL = "http://192.168.122.1:5000/"
_WHISPER_URL = "http://192.168.129.9:8080/inference"
_PIPER_URL = "http://192.168.129.9:5100/"
# -- Per-bot state -----------------------------------------------------------
@@ -185,11 +184,16 @@ async def _flush_monitor(bot):
# -- TTS: Piper fetch + playback --------------------------------------------
def _fetch_tts(url: str) -> str | None:
"""Fetch TTS WAV from Piper to a temp file. Blocking."""
def _fetch_tts(piper_url: str, text: str) -> str | None:
"""POST text to Piper TTS and save the WAV response. Blocking."""
import tempfile
try:
resp = _urlopen(url, timeout=30, proxy=False)
payload = json.dumps({"text": text}).encode()
req = urllib.request.Request(
piper_url, data=payload, method="POST",
)
req.add_header("Content-Type", "application/json")
resp = _urlopen(req, timeout=30, proxy=False)
data = resp.read()
resp.close()
if not data:
@@ -210,9 +214,10 @@ async def _tts_play(bot, text: str):
from pathlib import Path
ps = _ps(bot)
url = ps["piper_url"] + "?text=" + quote_plus(text)
loop = asyncio.get_running_loop()
wav_path = await loop.run_in_executor(None, _fetch_tts, url)
wav_path = await loop.run_in_executor(
None, _fetch_tts, ps["piper_url"], text,
)
if wav_path is None:
return
try: