diff --git a/src/api/v1/api.py b/src/api/v1/api.py index 14368cd..e54aca0 100644 --- a/src/api/v1/api.py +++ b/src/api/v1/api.py @@ -8,12 +8,14 @@ DynamixelMotor, DYNAMIXEL_MX_12_ADDR_CONFIG, ) +from pygame import mixer import asyncio import cv2 app = FastAPI() camera = cv2.VideoCapture(1, cv2.CAP_DSHOW) templates = Jinja2Templates(directory="templates") +mixer.init() origins = [ "http://localhost:3000", @@ -62,3 +64,15 @@ async def command(request: Request): ctrl.set_velocity(Position2D(x_val, y_val, 0)) return {"status": "success"} + +@app.post("/sfx") +async def command(request: Request): + data = await request.json() + + if data.get("sfx") == "bloop": + mixer.music.load("./bloop.mp3") + elif data.get("sfx") == "bong": + mixer.music.load("./bong.mp3") + mixer.music.play() + + return {"status": "success"} \ No newline at end of file diff --git a/src/api/v1/bloop.mp3 b/src/api/v1/bloop.mp3 new file mode 100644 index 0000000..4e8f14a Binary files /dev/null and b/src/api/v1/bloop.mp3 differ diff --git a/src/api/v1/bong.mp3 b/src/api/v1/bong.mp3 new file mode 100644 index 0000000..83e2faf Binary files /dev/null and b/src/api/v1/bong.mp3 differ