Files
ai1/services/vad/app.py
2026-02-20 02:40:50 +03:00

27 lines
782 B
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
from fastapi import FastAPI
import redis
import os
app = FastAPI()
redis_host = os.getenv("REDIS_HOST", "localhost")
redis_port = int(os.getenv("REDIS_PORT", 6379))
r = redis.Redis(host=redis_host, port=redis_port, decode_responses=True)
@app.get("/health")
async def health():
return {"status": "ok", "service": "vad"}
@app.websocket("/audio-stream")
async def audio_stream(websocket):
await websocket.accept()
print("Client connected to VAD")
try:
while True:
data = await websocket.receive_bytes()
# Пока ничего не делаем с данными
# В будущем здесь будет VAD-обработка
pass
except Exception as e:
print(f"VAD connection closed: {e}")