Files
desklock/gateway/src/desklock_gateway/stt.py
T
jpmschweitzerandClaude Fable 5 576fd7d237 Initial scaffold: ESP32-P4 firmware + voice gateway for Tatlock endpoint
DeskLock gives the Tatlock butler a face and voice on a Waveshare
ESP32-P4-WIFI6-Touch-LCD-3.4C round display in the living room.

- firmware/: ESP-IDF project targeting esp32p4 with the Waveshare XC BSP
- gateway/: FastAPI voice bridge (faster-whisper STT, Tatlock chat, Piper TTS)
- docs/architecture.md: component design and device<->gateway WS protocol

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-14 16:58:59 +02:00

25 lines
767 B
Python

"""Speech-to-text: faster-whisper on the tower-of-joy GPU.
Import of faster_whisper is deferred so the gateway can run (health checks,
protocol tests) without the heavy speech extras installed.
"""
from .config import settings
_model = None
def transcribe(pcm: bytes, sample_rate: int | None = None) -> str:
"""Transcribe raw s16le mono PCM to text."""
global _model
if _model is None:
from faster_whisper import WhisperModel
_model = WhisperModel(settings.stt_model, device=settings.stt_device)
import numpy as np
audio = np.frombuffer(pcm, dtype=np.int16).astype(np.float32) / 32768.0
segments, _info = _model.transcribe(audio, language="en")
return " ".join(segment.text.strip() for segment in segments).strip()