her
This commit is contained in:
parent
133b557512
commit
ed629ff60e
7 changed files with 948 additions and 525 deletions
10
app.py
10
app.py
|
|
@ -6,17 +6,21 @@ from typing import Any, Awaitable, Callable
|
|||
|
||||
from fastapi import FastAPI, WebSocket, WebSocketDisconnect
|
||||
from fastapi.responses import FileResponse, JSONResponse
|
||||
from fastapi.staticfiles import StaticFiles
|
||||
|
||||
from supertonic_gateway import SuperTonicGateway
|
||||
from voice_rtc import WebRTCVoiceSession
|
||||
|
||||
|
||||
BASE_DIR = Path(__file__).resolve().parent
|
||||
INDEX_PATH = BASE_DIR / "static" / "index.html"
|
||||
STATIC_DIR = BASE_DIR / "static"
|
||||
INDEX_PATH = STATIC_DIR / "index.html"
|
||||
|
||||
app = FastAPI(title="Nanobot SuperTonic Wisper Web")
|
||||
gateway = SuperTonicGateway()
|
||||
|
||||
app.mount("/static", StaticFiles(directory=str(STATIC_DIR)), name="static")
|
||||
|
||||
|
||||
@app.get("/health")
|
||||
async def health() -> JSONResponse:
|
||||
|
|
@ -64,13 +68,15 @@ async def websocket_chat(websocket: WebSocket) -> None:
|
|||
voice_session.set_push_to_talk_pressed(
|
||||
bool(message.get("pressed", False))
|
||||
)
|
||||
elif msg_type == "user-message":
|
||||
await gateway.send_user_message(str(message.get("text", "")))
|
||||
else:
|
||||
await safe_send_json(
|
||||
{
|
||||
"role": "system",
|
||||
"text": (
|
||||
"Unknown message type. Use spawn, stop, rtc-offer, "
|
||||
"rtc-ice-candidate, or voice-ptt."
|
||||
"rtc-ice-candidate, voice-ptt, or user-message."
|
||||
),
|
||||
"timestamp": "",
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue