mirror of
https://github.com/bitbaum/loki.git
synced 2026-12-04 11:48:24 +01:00
UX — the composer mic was a bare icon. While recording/transcribing it now shows a Grok-style overlay over the composer: a live animated waveform, a pulsing record dot, an elapsed timer, and cancel (✕) / confirm (✓) controls (globals.css ui-voice-*). Transcript still appends to the input. Backend (a)+(b): the route already orchestrates Groq-first → local-Whisper fallback. Two fixes to make the fallback real on the box: (1) the local path was gated by isRuntimeAvailable() (false on the stateless box) — now also enabled by TRANSCRIBE_LOCAL_AVAILABLE so the box runs it; (2) transcribe.py switched from openai-whisper (heavy torch) to faster-whisper (CTranslate2 int8, no torch) — far lighter on the shared CX22. Groq (whisper-large-v3-turbo) verified working. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
31 lines
1.0 KiB
Python
Executable File
31 lines
1.0 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
"""Transcribe audio via local faster-whisper (CTranslate2 — no torch, int8 CPU).
|
|
|
|
Prints the transcript to stdout. Used as the self-hosted fallback when Groq is
|
|
unavailable (see src/app/api/beacon/transcribe/route.ts). Lighter on RAM/CPU
|
|
than openai-whisper, which matters on the shared Hetzner box.
|
|
|
|
Usage: transcribe.py <audio.wav> [model_size] (model defaults to "base")
|
|
"""
|
|
import sys
|
|
import warnings
|
|
|
|
warnings.filterwarnings("ignore")
|
|
from faster_whisper import WhisperModel # noqa: E402
|
|
|
|
|
|
def main() -> None:
|
|
if len(sys.argv) < 2:
|
|
sys.exit(1)
|
|
audio = sys.argv[1]
|
|
model_size = sys.argv[2] if len(sys.argv) > 2 else "base"
|
|
# int8 on CPU keeps memory ~200MB for base; the model is cached under
|
|
# ~/.cache/huggingface after first download.
|
|
model = WhisperModel(model_size, device="cpu", compute_type="int8")
|
|
segments, _info = model.transcribe(audio, vad_filter=True)
|
|
print(" ".join(seg.text.strip() for seg in segments).strip())
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|