updated skeleton with true data
This commit is contained in:
7
gateway/api/health.py
Normal file
7
gateway/api/health.py
Normal file
@ -0,0 +1,7 @@
|
||||
from fastapi import APIRouter
|
||||
|
||||
router = APIRouter()
|
||||
|
||||
@router.get("/")
|
||||
async def health():
|
||||
return {"status": "ok"}
|
||||
19
gateway/api/openai_speech.py
Normal file
19
gateway/api/openai_speech.py
Normal file
@ -0,0 +1,19 @@
|
||||
from fastapi import APIRouter, Response
|
||||
from pydantic import BaseModel
|
||||
from core.queue_client import push_job, await_result
|
||||
|
||||
router = APIRouter()
|
||||
|
||||
class SpeechRequest(BaseModel):
|
||||
model: str
|
||||
input: str
|
||||
voice: str = "auto"
|
||||
format: str = "wav"
|
||||
voice_sample_url: str | None = None
|
||||
voice_sample_base64: str | None = None
|
||||
|
||||
@router.post("/speech")
|
||||
async def speech(req: SpeechRequest):
|
||||
job_id = push_job(req.dict())
|
||||
audio_bytes, mime = await_result(job_id)
|
||||
return Response(content=audio_bytes, media_type=mime)
|
||||
21
gateway/api/voices.py
Normal file
21
gateway/api/voices.py
Normal file
@ -0,0 +1,21 @@
|
||||
from fastapi import APIRouter
|
||||
import json
|
||||
from pathlib import Path
|
||||
|
||||
router = APIRouter()
|
||||
REG = Path("voices/registry.json")
|
||||
|
||||
@router.post("/register")
|
||||
async def register(data: dict):
|
||||
reg = {}
|
||||
if REG.exists():
|
||||
reg = json.loads(REG.read_text())
|
||||
reg[data["name"]] = data
|
||||
REG.write_text(json.dumps(reg, indent=2))
|
||||
return {"status": "ok", "voices": list(reg.keys())}
|
||||
|
||||
@router.get("/list")
|
||||
async def list_voices():
|
||||
if not REG.exists():
|
||||
return []
|
||||
return json.loads(REG.read_text())
|
||||
Reference in New Issue
Block a user