d901208032
- pipeline.py: switched LLM from OpenClaw/Claude to local Ollama, added settings loading, sentence aggregator, async SpeechBrain, tuned VAD - main.py: simplified (no more token server thread, just pipeline) - token_server.py: NEW - standalone token + settings API server - docker-compose.yml: all services on GPU machine, added token-server service, CUDA speaches, Ollama LLM - web-client/index.html: added settings panel with sliders - web-client/app.js: settings management, localStorage persistence, push to server - web-client/style.css: settings panel styles - web-client/nginx.conf: proxy to token-server instead of pipecat-agent - patch_livekit.py: updated with proper indentation-safe patching
35 lines
986 B
Python
Executable File
35 lines
986 B
Python
Executable File
"""
|
|
Piper TTS client for Pipecat pipeline.
|
|
Calls the self-hosted Piper HTTP service.
|
|
"""
|
|
import io
|
|
import logging
|
|
import wave
|
|
import httpx
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
class PiperTTSClient:
|
|
"""HTTP client for the Piper TTS service."""
|
|
|
|
def __init__(self, base_url: str = "http://piper-tts:8003"):
|
|
self.base_url = base_url.rstrip("/")
|
|
self._client = httpx.AsyncClient(timeout=10.0)
|
|
|
|
async def synthesize(self, text: str) -> bytes:
|
|
"""Convert text to WAV audio bytes via Piper service."""
|
|
try:
|
|
response = await self._client.post(
|
|
f"{self.base_url}/synthesize",
|
|
json={"text": text, "length_scale": 0.95, "sentence_silence": 0.15},
|
|
)
|
|
response.raise_for_status()
|
|
return response.content
|
|
except Exception as e:
|
|
logger.error(f"Piper TTS failed: {e}")
|
|
return b""
|
|
|
|
async def close(self):
|
|
await self._client.aclose()
|