Spaces:
Running
on
L4
Running
on
L4
Sofia Casadei
commited on
Commit
·
74081c9
1
Parent(s):
d4e500e
up
Browse files- static/index.html → index.html +0 -0
- main.py +9 -8
static/index.html → index.html
RENAMED
File without changes
|
main.py
CHANGED
@@ -1,12 +1,12 @@
|
|
1 |
import os
|
2 |
import logging
|
|
|
3 |
|
4 |
import gradio as gr
|
5 |
import numpy as np
|
6 |
from dotenv import load_dotenv
|
7 |
from fastapi import FastAPI
|
8 |
from fastapi.responses import StreamingResponse, HTMLResponse
|
9 |
-
from fastapi.staticfiles import StaticFiles
|
10 |
|
11 |
from fastrtc import (
|
12 |
AdditionalOutputs,
|
@@ -126,12 +126,17 @@ stream = Stream(
|
|
126 |
],
|
127 |
additional_outputs_handler=lambda current, new: current + " " + new,
|
128 |
rtc_configuration=get_rtc_credentials(provider="hf") if os.getenv("APP_MODE") == "deployed" else None,
|
129 |
-
concurrency_limit=6
|
130 |
)
|
131 |
|
132 |
app = FastAPI()
|
133 |
stream.mount(app)
|
134 |
-
|
|
|
|
|
|
|
|
|
|
|
135 |
|
136 |
@app.get("/transcript")
|
137 |
def _(webrtc_id: str):
|
@@ -146,8 +151,4 @@ def _(webrtc_id: str):
|
|
146 |
logger.error(f"Error in transcript stream for {webrtc_id}: {str(e)}")
|
147 |
raise
|
148 |
|
149 |
-
return StreamingResponse(output_stream(), media_type="text/event-stream")
|
150 |
-
|
151 |
-
@app.get("/")
|
152 |
-
async def root():
|
153 |
-
return HTMLResponse(content=open("static/index.html").read())
|
|
|
1 |
import os
|
2 |
import logging
|
3 |
+
import uvicorn
|
4 |
|
5 |
import gradio as gr
|
6 |
import numpy as np
|
7 |
from dotenv import load_dotenv
|
8 |
from fastapi import FastAPI
|
9 |
from fastapi.responses import StreamingResponse, HTMLResponse
|
|
|
10 |
|
11 |
from fastrtc import (
|
12 |
AdditionalOutputs,
|
|
|
126 |
],
|
127 |
additional_outputs_handler=lambda current, new: current + " " + new,
|
128 |
rtc_configuration=get_rtc_credentials(provider="hf") if os.getenv("APP_MODE") == "deployed" else None,
|
129 |
+
#concurrency_limit=6
|
130 |
)
|
131 |
|
132 |
app = FastAPI()
|
133 |
stream.mount(app)
|
134 |
+
|
135 |
+
@app.get("/")
|
136 |
+
async def index():
|
137 |
+
html_content = open("index.html").read()
|
138 |
+
rtc_config = get_rtc_credentials(provider="hf") if os.getenv("APP_MODE") == "deployed" else None
|
139 |
+
return HTMLResponse(content=html_content.replace("__RTC_CONFIGURATION__", json.dumps(rtc_config)))
|
140 |
|
141 |
@app.get("/transcript")
|
142 |
def _(webrtc_id: str):
|
|
|
151 |
logger.error(f"Error in transcript stream for {webrtc_id}: {str(e)}")
|
152 |
raise
|
153 |
|
154 |
+
return StreamingResponse(output_stream(), media_type="text/event-stream")
|
|
|
|
|
|
|
|