burtenshaw commited on
Commit
6f66039
·
1 Parent(s): d28bf05

add rtc configuration

Browse files
Files changed (2) hide show
  1. README.md +0 -10
  2. app.py +10 -3
README.md CHANGED
@@ -60,16 +60,6 @@ This launches a Gradio UI at http://localhost:7860 with:
60
  - A chat interface showing the conversation
61
  - An image display panel for generated images
62
 
63
- ### With FastAPI (Advanced)
64
-
65
- ```bash
66
- python app.py
67
- ```
68
-
69
- This serves a FastAPI app at http://localhost:7860 that provides:
70
- - WebRTC-based audio communication
71
- - The same smolagents functionality in a more flexible API
72
-
73
  ## How to Use
74
 
75
  1. Click the microphone button to start streaming your voice.
 
60
  - A chat interface showing the conversation
61
  - An image display panel for generated images
62
 
 
 
 
 
 
 
 
 
 
 
63
  ## How to Use
64
 
65
  1. Click the microphone button to start streaming your voice.
app.py CHANGED
@@ -2,7 +2,13 @@ from pathlib import Path
2
  from typing import List, Dict
3
 
4
  from dotenv import load_dotenv
5
- from fastrtc import get_stt_model, get_tts_model, Stream, ReplyOnPause
 
 
 
 
 
 
6
  from smolagents import CodeAgent, HfApiModel, DuckDuckGoSearchTool
7
 
8
  # Load environment variables
@@ -73,7 +79,7 @@ def process_response(audio):
73
 
74
  # Convert response to audio using TTS model
75
  for audio_chunk in tts_model.stream_tts_sync(response_content or ""):
76
- # Yield the audio chunk
77
  yield audio_chunk
78
 
79
 
@@ -86,7 +92,8 @@ stream = Stream(
86
  "icon_button_color": "rgb(255, 255, 255)",
87
  "title": "🧑‍💻The Coworking Agent",
88
  },
 
89
  )
90
 
91
  if __name__ == "__main__":
92
- stream.ui.launch()
 
2
  from typing import List, Dict
3
 
4
  from dotenv import load_dotenv
5
+ from fastrtc import (
6
+ get_stt_model,
7
+ get_tts_model,
8
+ Stream,
9
+ ReplyOnPause,
10
+ get_twilio_turn_credentials,
11
+ )
12
  from smolagents import CodeAgent, HfApiModel, DuckDuckGoSearchTool
13
 
14
  # Load environment variables
 
79
 
80
  # Convert response to audio using TTS model
81
  for audio_chunk in tts_model.stream_tts_sync(response_content or ""):
82
+ # Yield the audio chunk
83
  yield audio_chunk
84
 
85
 
 
92
  "icon_button_color": "rgb(255, 255, 255)",
93
  "title": "🧑‍💻The Coworking Agent",
94
  },
95
+ rtc_configuration=get_twilio_turn_credentials(),
96
  )
97
 
98
  if __name__ == "__main__":
99
+ stream.ui.launch(server_port=7860)