Spaces:
Sleeping
Sleeping
Upload folder using huggingface_hub
Browse files
app.py
CHANGED
@@ -1,7 +1,8 @@
|
|
1 |
-
|
|
|
2 |
from fastapi.responses import RedirectResponse
|
|
|
3 |
from gradio.utils import get_space
|
4 |
-
import numpy as np
|
5 |
|
6 |
|
7 |
def detection(audio: tuple[int, np.ndarray]):
|
@@ -18,8 +19,12 @@ stream = Stream(
|
|
18 |
concurrency_limit=20 if get_space() else None,
|
19 |
)
|
20 |
|
|
|
|
|
|
|
21 |
|
22 |
-
|
|
|
23 |
async def index():
|
24 |
return RedirectResponse(
|
25 |
url="/ui" if not get_space() else "https://fastrtc-echo-audio.hf.space/ui/"
|
@@ -27,6 +32,13 @@ async def index():
|
|
27 |
|
28 |
|
29 |
if __name__ == "__main__":
|
30 |
-
import
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
31 |
|
32 |
-
|
|
|
1 |
+
import numpy as np
|
2 |
+
from fastapi import FastAPI
|
3 |
from fastapi.responses import RedirectResponse
|
4 |
+
from fastrtc import ReplyOnPause, Stream, get_twilio_turn_credentials
|
5 |
from gradio.utils import get_space
|
|
|
6 |
|
7 |
|
8 |
def detection(audio: tuple[int, np.ndarray]):
|
|
|
19 |
concurrency_limit=20 if get_space() else None,
|
20 |
)
|
21 |
|
22 |
+
app = FastAPI()
|
23 |
+
|
24 |
+
stream.mount(app)
|
25 |
|
26 |
+
|
27 |
+
@app.get("/")
|
28 |
async def index():
|
29 |
return RedirectResponse(
|
30 |
url="/ui" if not get_space() else "https://fastrtc-echo-audio.hf.space/ui/"
|
|
|
32 |
|
33 |
|
34 |
if __name__ == "__main__":
|
35 |
+
import os
|
36 |
+
|
37 |
+
if (mode := os.getenv("MODE")) == "UI":
|
38 |
+
stream.ui.launch(server_port=7860, server_name="0.0.0.0")
|
39 |
+
elif mode == "PHONE":
|
40 |
+
stream.fastphone(host="0.0.0.0", port=7860)
|
41 |
+
else:
|
42 |
+
import uvicorn
|
43 |
|
44 |
+
uvicorn.run(app, host="0.0.0.0", port=7860)
|