266ea11447
FRIDAY Voice (speaches GPU STT/TTS + hermes agent + push-to-talk console) on .150 Docker Desktop, fronted by coach.hobbs.farm. Also captures the VoiceCoach compose/agent trees and deploy notes it replaced, which had never been committed. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
36 lines
1.2 KiB
Python
36 lines
1.2 KiB
Python
"""
|
|
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
|