Initial commit: Voice Assistant Gateway mit Konfig-/Routing-Fundament
- FastAPI-Gateway mit REST-Endpunkten (chat/speak/transcribe/devices/sessions/config) - Geschichtete Konfiguration mit Profilen (local-dev/hybrid/cloud) via TOML + ENV - Registry-Pattern + einheitliche Route-Aufloesung (Default->Profil->ENV->Session->Request) - Device Router (strikt, Singleton) und Output-Lifecycle im Orchestrator - OpenRouter-Adapter (STT multipart/LLM/TTS) + lokale Provider-Stubs - Regelbasierte Pipeline (Cleaner/Spoken-Adapter/TTS-Normalizer) - 22 automatisierte Tests; Doku: README, BEDIENUNGSANLEITUNG, Architektur - Secrets ausschliesslich ueber Umgebung; .env und lokale config gitignored Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
commit
293ed257db
72 changed files with 2612 additions and 0 deletions
50
app/api/transcribe.py
Normal file
50
app/api/transcribe.py
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
from fastapi import APIRouter, File, Form, HTTPException, Query, UploadFile
|
||||
|
||||
from app.errors import RoutingError
|
||||
from app.dependencies import (
|
||||
resolve_route,
|
||||
build_orchestrator,
|
||||
resolve_input_endpoint,
|
||||
)
|
||||
|
||||
router = APIRouter()
|
||||
|
||||
|
||||
@router.post("/transcribe")
|
||||
async def transcribe(
|
||||
file: UploadFile = File(...),
|
||||
language: str | None = Form(default=None),
|
||||
input_endpoint: str | None = Form(default=None),
|
||||
stt_provider: str | None = Form(default=None),
|
||||
session_id: str | None = Query(
|
||||
default=None,
|
||||
description="Optional session id to apply a stored route",
|
||||
),
|
||||
):
|
||||
overrides = {
|
||||
"input_endpoint": input_endpoint,
|
||||
"language": language,
|
||||
"stt_provider": stt_provider,
|
||||
}
|
||||
route = resolve_route(session_id, overrides)
|
||||
|
||||
try:
|
||||
orchestrator = build_orchestrator(route)
|
||||
source = await resolve_input_endpoint(route)
|
||||
except RoutingError as exc:
|
||||
raise HTTPException(status_code=422, detail=str(exc))
|
||||
|
||||
content = await file.read()
|
||||
suffix = (file.filename or "audio.wav").rsplit(".", 1)[-1].lower()
|
||||
|
||||
try:
|
||||
trace = await orchestrator.transcribe_only(
|
||||
content,
|
||||
fmt=suffix,
|
||||
language=route.language,
|
||||
input=source,
|
||||
)
|
||||
except Exception as exc:
|
||||
raise HTTPException(status_code=502, detail=str(exc))
|
||||
|
||||
return {"route": route.as_dict(), "trace": trace.model_dump()}
|
||||
Loading…
Add table
Add a link
Reference in a new issue