Spaces:
Sleeping
Sleeping
Commit
·
b3cc831
1
Parent(s):
e7e829d
Code fixing
Browse files
app.py
CHANGED
|
@@ -822,6 +822,13 @@ def create_interface():
|
|
| 822 |
outputs=[status_output]
|
| 823 |
)
|
| 824 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 825 |
# Auto-refresh every 2 seconds when recording
|
| 826 |
refresh_timer = gr.Timer(2.0)
|
| 827 |
refresh_timer.tick(
|
|
@@ -841,21 +848,6 @@ gradio_interface = create_interface()
|
|
| 841 |
# 3) Mount Gradio onto FastAPI at root
|
| 842 |
app = gr.mount_gradio_app(app, gradio_interface, path="/")
|
| 843 |
|
| 844 |
-
# 4)
|
| 845 |
-
rtc_stream = setup_fastrtc_handler()
|
| 846 |
-
rtc_stream.mount(app)
|
| 847 |
-
|
| 848 |
-
# 5) Expose an endpoint to trigger the client-side RTC handshake
|
| 849 |
-
@app.post("/start-rtc")
|
| 850 |
-
async def start_rtc(request: Request):
|
| 851 |
-
try:
|
| 852 |
-
# Initialize client connection
|
| 853 |
-
await rtc_stream.start_client()
|
| 854 |
-
return {"status": "success"}
|
| 855 |
-
except Exception as e:
|
| 856 |
-
print(f"Error starting RTC client: {e}")
|
| 857 |
-
return {"status": "error", "error": str(e)}
|
| 858 |
-
|
| 859 |
-
# 6) Local dev via uvicorn; HF Spaces will auto-detect 'app' and ignore this
|
| 860 |
if __name__ == "__main__":
|
| 861 |
uvicorn.run(app, host="0.0.0.0", port=7860)
|
|
|
|
| 822 |
outputs=[status_output]
|
| 823 |
)
|
| 824 |
|
| 825 |
+
# Connect audio input to processing function
|
| 826 |
+
audio_input.stream(
|
| 827 |
+
process_audio_stream,
|
| 828 |
+
inputs=[audio_input],
|
| 829 |
+
outputs=[conversation_output]
|
| 830 |
+
)
|
| 831 |
+
|
| 832 |
# Auto-refresh every 2 seconds when recording
|
| 833 |
refresh_timer = gr.Timer(2.0)
|
| 834 |
refresh_timer.tick(
|
|
|
|
| 848 |
# 3) Mount Gradio onto FastAPI at root
|
| 849 |
app = gr.mount_gradio_app(app, gradio_interface, path="/")
|
| 850 |
|
| 851 |
+
# 4) Local dev via uvicorn; HF Spaces will auto-detect 'app' and ignore this
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 852 |
if __name__ == "__main__":
|
| 853 |
uvicorn.run(app, host="0.0.0.0", port=7860)
|