Spaces:
Sleeping
Sleeping
Christopher H.
commited on
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,10 +1,15 @@
|
|
| 1 |
import time
|
|
|
|
| 2 |
import numpy as np
|
| 3 |
import gradio as gr
|
| 4 |
import random
|
| 5 |
|
| 6 |
from fastrtc import AdditionalOutputs, WebRTC, ReplyOnPause
|
| 7 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
possible_responses = [
|
| 9 |
"hello",
|
| 10 |
"hi",
|
|
@@ -39,19 +44,10 @@ with gr.Blocks() as demo:
|
|
| 39 |
with gr.Column():
|
| 40 |
audio = WebRTC(
|
| 41 |
label="Stream",
|
| 42 |
-
mode="send",
|
| 43 |
modality="audio",
|
| 44 |
-
rtc_configuration=
|
| 45 |
-
|
| 46 |
-
"iceTransportPolicy": "all",
|
| 47 |
-
"iceCandidatePoolSize": 10,
|
| 48 |
-
"bundlePolicy": "max-bundle",
|
| 49 |
-
"rtcpMuxPolicy": "require",
|
| 50 |
-
"sdpSemantics": "unified-plan",
|
| 51 |
-
},
|
| 52 |
-
server_rtc_configuration={
|
| 53 |
-
"iceServers": [{"urls": ["stun:stun.l.google.com:19302"]}]
|
| 54 |
-
},
|
| 55 |
)
|
| 56 |
with gr.Column():
|
| 57 |
transcript = gr.Chatbot(label="transcript", type="messages")
|
|
|
|
| 1 |
import time
|
| 2 |
+
import os
|
| 3 |
import numpy as np
|
| 4 |
import gradio as gr
|
| 5 |
import random
|
| 6 |
|
| 7 |
from fastrtc import AdditionalOutputs, WebRTC, ReplyOnPause
|
| 8 |
|
| 9 |
+
hf_token = os.getenv("TOKEN")
|
| 10 |
+
async def get_credentials():
|
| 11 |
+
return await get_cloudflare_turn_credentials_async(hf_token=TOKEN)
|
| 12 |
+
|
| 13 |
possible_responses = [
|
| 14 |
"hello",
|
| 15 |
"hi",
|
|
|
|
| 44 |
with gr.Column():
|
| 45 |
audio = WebRTC(
|
| 46 |
label="Stream",
|
| 47 |
+
mode="send-receive",
|
| 48 |
modality="audio",
|
| 49 |
+
rtc_configuration=get_credentials,
|
| 50 |
+
server_rtc_configuration=get_cloudflare_turn_credentials(ttl=360_000),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 51 |
)
|
| 52 |
with gr.Column():
|
| 53 |
transcript = gr.Chatbot(label="transcript", type="messages")
|