Commit
·
678e06c
1
Parent(s):
0d96746
Code fixing
Browse files
app.py
CHANGED
@@ -857,22 +857,25 @@ def create_interface():
|
|
857 |
return interface
|
858 |
|
859 |
|
860 |
-
# Create FastAPI app
|
861 |
app = FastAPI()
|
862 |
|
863 |
-
#
|
864 |
-
rtc_stream = setup_fastrtc_handler()
|
865 |
-
rtc_stream.mount(app)
|
866 |
-
|
867 |
-
# Create Gradio interface
|
868 |
gradio_interface = create_interface()
|
|
|
|
|
869 |
app = gr.mount_gradio_app(app, gradio_interface, path="/")
|
870 |
|
871 |
-
#
|
|
|
|
|
|
|
|
|
872 |
@app.post("/start-rtc")
|
873 |
-
def start_rtc():
|
|
|
874 |
return {"status": "success"}
|
875 |
|
|
|
876 |
if __name__ == "__main__":
|
877 |
-
|
878 |
-
uvicorn.run(app, host="0.0.0.0", port=7860)
|
|
|
857 |
return interface
|
858 |
|
859 |
|
860 |
+
# 1) Create FastAPI app
|
861 |
app = FastAPI()
|
862 |
|
863 |
+
# 2) Create Gradio interface
|
|
|
|
|
|
|
|
|
864 |
gradio_interface = create_interface()
|
865 |
+
|
866 |
+
# 3) Mount Gradio onto FastAPI at root
|
867 |
app = gr.mount_gradio_app(app, gradio_interface, path="/")
|
868 |
|
869 |
+
# 4) Initialize and mount FastRTC stream on the same app
|
870 |
+
rtc_stream = setup_fastrtc_handler()
|
871 |
+
rtc_stream.mount(app)
|
872 |
+
|
873 |
+
# 5) Expose an endpoint to trigger the client-side RTC handshake
|
874 |
@app.post("/start-rtc")
|
875 |
+
async def start_rtc():
|
876 |
+
await rtc_stream.start_client()
|
877 |
return {"status": "success"}
|
878 |
|
879 |
+
# 6) Local dev via uvicorn; HF Spaces will auto-detect 'app' and ignore this
|
880 |
if __name__ == "__main__":
|
881 |
+
uvicorn.run(app, host="0.0.0.0", port=7860)
|
|