Spaces:
Running
on
Zero
Running
on
Zero
Commit
·
5cb0b21
1
Parent(s):
0b8cb49
rest
Browse files- app.py +18 -0
- requirements.txt +2 -1
app.py
CHANGED
@@ -5,11 +5,28 @@ from io import BytesIO
|
|
5 |
import numpy as np
|
6 |
import librosa
|
7 |
import tempfile
|
|
|
|
|
8 |
from transformers import Qwen2AudioForConditionalGeneration, AutoProcessor
|
9 |
|
10 |
processor = AutoProcessor.from_pretrained("Qwen/Qwen2-Audio-7B-Instruct")
|
11 |
model = Qwen2AudioForConditionalGeneration.from_pretrained("Qwen/Qwen2-Audio-7B-Instruct", device_map="auto")
|
12 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
|
14 |
def transcribe(audio: tuple[int, np.ndarray], transformers_convo: list[dict], gradio_convo: list[dict]):
|
15 |
segment = AudioSegment(
|
@@ -51,6 +68,7 @@ with gr.Blocks() as demo:
|
|
51 |
with gr.Row():
|
52 |
with gr.Column():
|
53 |
audio = WebRTC(
|
|
|
54 |
label="Stream",
|
55 |
mode="send",
|
56 |
modality="audio",
|
|
|
5 |
import numpy as np
|
6 |
import librosa
|
7 |
import tempfile
|
8 |
+
from twilio.rest import Client
|
9 |
+
import os
|
10 |
from transformers import Qwen2AudioForConditionalGeneration, AutoProcessor
|
11 |
|
12 |
processor = AutoProcessor.from_pretrained("Qwen/Qwen2-Audio-7B-Instruct")
|
13 |
model = Qwen2AudioForConditionalGeneration.from_pretrained("Qwen/Qwen2-Audio-7B-Instruct", device_map="auto")
|
14 |
|
15 |
+
account_sid = os.environ.get("TWILIO_ACCOUNT_SID")
|
16 |
+
auth_token = os.environ.get("TWILIO_AUTH_TOKEN")
|
17 |
+
|
18 |
+
if account_sid and auth_token:
|
19 |
+
client = Client(account_sid, auth_token)
|
20 |
+
|
21 |
+
token = client.tokens.create()
|
22 |
+
|
23 |
+
rtc_configuration = {
|
24 |
+
"iceServers": token.ice_servers,
|
25 |
+
"iceTransportPolicy": "relay",
|
26 |
+
}
|
27 |
+
else:
|
28 |
+
rtc_configuration = None
|
29 |
+
|
30 |
|
31 |
def transcribe(audio: tuple[int, np.ndarray], transformers_convo: list[dict], gradio_convo: list[dict]):
|
32 |
segment = AudioSegment(
|
|
|
68 |
with gr.Row():
|
69 |
with gr.Column():
|
70 |
audio = WebRTC(
|
71 |
+
rtc_configuration=rtc_configuration,
|
72 |
label="Stream",
|
73 |
mode="send",
|
74 |
modality="audio",
|
requirements.txt
CHANGED
@@ -1,2 +1,3 @@
|
|
1 |
gradio_webrtc[vad]==0.0.11a1
|
2 |
-
transformers@git+https://github.com/huggingface/transformers
|
|
|
|
1 |
gradio_webrtc[vad]==0.0.11a1
|
2 |
+
transformers@git+https://github.com/huggingface/transformers
|
3 |
+
twilio
|