bharathmunakala commited on
Commit
84913ca
·
verified ·
1 Parent(s): 6b86949

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -2
app.py CHANGED
@@ -219,11 +219,20 @@ def response(
219
  def create_stream() -> Stream:
220
  """
221
  Create and configure a Stream instance with audio capabilities.
222
- Optimized for low latency.
223
 
224
  Returns:
225
  Stream: Configured FastRTC Stream instance
226
  """
 
 
 
 
 
 
 
 
 
227
  return Stream(
228
  modality="audio",
229
  mode="send-receive",
@@ -233,6 +242,7 @@ def create_stream() -> Stream:
233
  speech_threshold=0.4, # Slightly lower for faster detection
234
  ),
235
  ),
 
236
  )
237
 
238
 
@@ -253,4 +263,8 @@ if __name__ == "__main__":
253
  stream.fastphone()
254
  else:
255
  logger.info("🌈 Launching with Gradio UI...")
256
- stream.ui.launch()
 
 
 
 
 
219
  def create_stream() -> Stream:
220
  """
221
  Create and configure a Stream instance with audio capabilities.
222
+ Optimized for low latency with RTC configuration for cloud deployment.
223
 
224
  Returns:
225
  Stream: Configured FastRTC Stream instance
226
  """
227
+ # RTC Configuration for Hugging Face Spaces deployment
228
+ rtc_config = {
229
+ "iceServers": [
230
+ {
231
+ "urls": ["stun:stun.l.google.com:19302", "stun:stun1.l.google.com:19302"]
232
+ }
233
+ ]
234
+ }
235
+
236
  return Stream(
237
  modality="audio",
238
  mode="send-receive",
 
242
  speech_threshold=0.4, # Slightly lower for faster detection
243
  ),
244
  ),
245
+ rtc_configuration=rtc_config, # Required for Hugging Face Spaces
246
  )
247
 
248
 
 
263
  stream.fastphone()
264
  else:
265
  logger.info("🌈 Launching with Gradio UI...")
266
+ # Configure for both local and Hugging Face Spaces deployment
267
+ stream.ui.launch(
268
+ server_name="0.0.0.0", # Bind to all interfaces for cloud deployment
269
+ server_port=int(os.getenv("PORT", 7860)), # Use PORT env var if available, default to 7860
270
+ )