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
36 lines
1.2 KiB
Python
Executable File
36 lines
1.2 KiB
Python
Executable File
"""
|
|
Local STT service using faster-whisper.
|
|
Replaces Deepgram with fully self-hosted speech-to-text.
|
|
"""
|
|
import io
|
|
import logging
|
|
import wave
|
|
import numpy as np
|
|
from faster_whisper import WhisperModel
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
class LocalWhisperSTT:
|
|
"""Wraps faster-whisper for use in the Pipecat pipeline."""
|
|
|
|
def __init__(self, model_size: str = "medium", device: str = "cpu", compute_type: str = "int8"):
|
|
logger.info(f"Loading faster-whisper model: {model_size} on {device}")
|
|
self.model = WhisperModel(model_size, device=device, compute_type=compute_type)
|
|
logger.info("faster-whisper model loaded.")
|
|
|
|
def transcribe(self, audio_bytes: bytes, sample_rate: int = 16000) -> str:
|
|
"""Transcribe raw PCM audio bytes to text."""
|
|
audio_array = np.frombuffer(audio_bytes, dtype=np.int16).astype(np.float32) / 32768.0
|
|
|
|
segments, info = self.model.transcribe(
|
|
audio_array,
|
|
beam_size=5,
|
|
language="en",
|
|
vad_filter=True,
|
|
vad_parameters=dict(min_silence_duration_ms=500),
|
|
)
|
|
|
|
text = " ".join(seg.text.strip() for seg in segments)
|
|
return text
|