feat: initial commit — VoiceCoach real-time voice coaching pipeline
Services: Pipecat agent (LiveKit + Claude + Whisper STT + Piper TTS), SpeechBrain analysis service, Piper TTS service, web client (nginx). Includes LiveKit server config and docker-compose orchestration. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Executable
+35
@@ -0,0 +1,35 @@
|
||||
"""
|
||||
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
|
||||
Reference in New Issue
Block a user