Refactor tool-speechtotext: extract sttlib shared library and add tests

Extract duplicated code (Whisper loading, audio recording, transcription,
VAD processing) into reusable sttlib/ package. Rewrite all 3 scripts as
thin wrappers. Add 24 unit tests with mocked hardware. Fix GPU fallback
bug in assistant.py and args.system assignment bug.
This commit is contained in:
local
2026-02-08 00:40:31 +00:00
parent 848681087e
commit 104da381fb
15 changed files with 480 additions and 195 deletions

View File

@@ -0,0 +1,7 @@
from sttlib.whisper_loader import load_whisper_model
from sttlib.audio import record_until_enter, pcm_bytes_to_float32
from sttlib.transcription import transcribe, is_hallucination, HALLUCINATION_PATTERNS
from sttlib.vad import (
VADProcessor, audio_callback, audio_queue,
SAMPLE_RATE, CHANNELS, FRAME_DURATION_MS, FRAME_SIZE, MIN_UTTERANCE_FRAMES,
)