freddyaboulton commited on
Commit
4ff6b18
·
1 Parent(s): 84a59c3
Files changed (2) hide show
  1. app.py +18 -1
  2. requirements.txt +2 -1
app.py CHANGED
@@ -6,6 +6,22 @@ from pydub import AudioSegment
6
  import openai
7
  import time
8
  import base64
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
 
10
 
11
  def create_client(api_key):
@@ -129,7 +145,8 @@ with gr.Blocks() as demo:
129
  set_key_button = gr.Button("Set API Key", variant="primary")
130
  with gr.Column(scale=3):
131
  audio = WebRTC(modality="audio", mode="send-receive",
132
- label="Audio Stream")
 
133
 
134
  client_state = gr.State(None)
135
  lepton_conversation = gr.State([])
 
6
  import openai
7
  import time
8
  import base64
9
+ import os
10
+
11
+ account_sid = os.environ.get("TWILIO_ACCOUNT_SID")
12
+ auth_token = os.environ.get("TWILIO_AUTH_TOKEN")
13
+
14
+ if account_sid and auth_token:
15
+ client = Client(account_sid, auth_token)
16
+
17
+ token = client.tokens.create()
18
+
19
+ rtc_configuration = {
20
+ "iceServers": token.ice_servers,
21
+ "iceTransportPolicy": "relay",
22
+ }
23
+ else:
24
+ rtc_configuration = None
25
 
26
 
27
  def create_client(api_key):
 
145
  set_key_button = gr.Button("Set API Key", variant="primary")
146
  with gr.Column(scale=3):
147
  audio = WebRTC(modality="audio", mode="send-receive",
148
+ label="Audio Stream",
149
+ rtc_configuration=rtc_configuration)
150
 
151
  client_state = gr.State(None)
152
  lepton_conversation = gr.State([])
requirements.txt CHANGED
@@ -1,2 +1,3 @@
1
  gradio_webrtc[vad]==0.0.11
2
- openai
 
 
1
  gradio_webrtc[vad]==0.0.11
2
+ openai
3
+ twilio