Download local.py from jibay/test: direct link, hf CLI and curl.
- Browser
- Download file 552 Bytes
-
https://huggingface.co/spaces/jibay/test/resolve/main/local.py
- Command line
-
hf download hf://spaces/jibay/test/local.py
-
curl -L -o local.py https://huggingface.co/spaces/jibay/test/resolve/main/local.py
552 Bytes
| from fastapi import FastAPI, Response, WebSocket | |
| import sounddevice as sd | |
| import numpy as np | |
| app = FastAPI() | |
| async def audio_stream(websocket: WebSocket): | |
| try: | |
| with sd.InputStream(callback=websocket.send) as stream: | |
| while True: | |
| data, _ = stream.read(1024) | |
| if not websocket.application_state: | |
| break | |
| except Exception as e: | |
| print(e) | |
| async def audio_stream(): | |
| return Response(content_type="audio/x-wav") |