Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -27,6 +27,14 @@ from deepseek import DeepSeekAPI
|
|
27 |
# Load environment variables
|
28 |
load_dotenv()
|
29 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
30 |
# Initialize clients
|
31 |
elevenlabs_client = ElevenLabs(api_key=os.getenv("ELEVENLABS_API_KEY"))
|
32 |
stt_model = get_stt_model()
|
@@ -76,7 +84,8 @@ stream = Stream(
|
|
76 |
additional_outputs_handler=lambda a, b: b,
|
77 |
additional_inputs=[chatbot],
|
78 |
additional_outputs=[chatbot],
|
79 |
-
ui_args={"title": "LLM Voice Chat (Powered by DeepSeek & ElevenLabs)"}
|
|
|
80 |
)
|
81 |
|
82 |
# Create FastAPI app and mount stream
|
@@ -243,22 +252,6 @@ if __name__ == "__main__":
|
|
243 |
import fastrtc
|
244 |
print(f"FastRTC version: {fastrtc.__version__ if hasattr(fastrtc, '__version__') else 'unknown'}")
|
245 |
|
246 |
-
#
|
247 |
-
|
248 |
-
|
249 |
-
print(f"FastPhone signature: {inspect.signature(stream.fastphone) if hasattr(stream, 'fastphone') else 'Not available'}")
|
250 |
-
|
251 |
-
try:
|
252 |
-
# Fix: Use keyword argument instead of positional
|
253 |
-
phone_service = stream.fastphone(
|
254 |
-
token=os.getenv("HF_TOKEN"),
|
255 |
-
host="127.0.0.1",
|
256 |
-
port=8000,
|
257 |
-
share_server_tls_certificate=True # Use keyword argument format
|
258 |
-
)
|
259 |
-
print("Phone service started successfully")
|
260 |
-
except Exception as e:
|
261 |
-
print(f"Error starting phone service: {e}")
|
262 |
-
print("Falling back to web interface...")
|
263 |
-
# Launch with web interface as fallback
|
264 |
-
stream.ui.launch(server_port=7860)
|
|
|
27 |
# Load environment variables
|
28 |
load_dotenv()
|
29 |
|
30 |
+
# Add this RTC configuration for Hugging Face Spaces
|
31 |
+
# This is critical for WebRTC to work properly in Spaces
|
32 |
+
rtc_config = {
|
33 |
+
"iceServers": [
|
34 |
+
{"urls": ["stun:stun.l.google.com:19302", "stun:stun1.l.google.com:19302"]}
|
35 |
+
]
|
36 |
+
}
|
37 |
+
|
38 |
# Initialize clients
|
39 |
elevenlabs_client = ElevenLabs(api_key=os.getenv("ELEVENLABS_API_KEY"))
|
40 |
stt_model = get_stt_model()
|
|
|
84 |
additional_outputs_handler=lambda a, b: b,
|
85 |
additional_inputs=[chatbot],
|
86 |
additional_outputs=[chatbot],
|
87 |
+
ui_args={"title": "LLM Voice Chat (Powered by DeepSeek & ElevenLabs)"},
|
88 |
+
rtc_configuration=rtc_config # Add this line
|
89 |
)
|
90 |
|
91 |
# Create FastAPI app and mount stream
|
|
|
252 |
import fastrtc
|
253 |
print(f"FastRTC version: {fastrtc.__version__ if hasattr(fastrtc, '__version__') else 'unknown'}")
|
254 |
|
255 |
+
# Use a simpler startup method compatible with Hugging Face Spaces
|
256 |
+
import uvicorn
|
257 |
+
uvicorn.run(app, host="0.0.0.0", port=7860)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|