Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -1,4 +1,4 @@
|
|
1 |
-
import
|
2 |
import edge_tts
|
3 |
import asyncio
|
4 |
import tempfile
|
@@ -11,7 +11,7 @@ import random
|
|
11 |
|
12 |
default_lang = "en"
|
13 |
|
14 |
-
engines = {default_lang: Model(default_lang)}
|
15 |
|
16 |
def transcribe(audio):
|
17 |
lang = "en"
|
@@ -34,6 +34,7 @@ Respond in a normal, conversational manner while being friendly and helpful.
|
|
34 |
"""
|
35 |
|
36 |
def models(text, seed=42):
|
|
|
37 |
seed = int(randomize_seed_fn(seed))
|
38 |
generator = torch.Generator().manual_seed(seed)
|
39 |
|
@@ -61,25 +62,35 @@ async def respond(audio, model, seed):
|
|
61 |
with tempfile.NamedTemporaryFile(delete=False, suffix=".wav") as tmp_file:
|
62 |
tmp_path = tmp_file.name
|
63 |
await communicate.save(tmp_path)
|
64 |
-
|
65 |
|
66 |
DESCRIPTION = """ # <center><b>JARVIS⚡</b></center>
|
67 |
### <center>A personal Assistant of Tony Stark for YOU
|
68 |
### <center>Voice Chat with your personal Assistant</center>
|
69 |
"""
|
70 |
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
import edge_tts
|
3 |
import asyncio
|
4 |
import tempfile
|
|
|
11 |
|
12 |
default_lang = "en"
|
13 |
|
14 |
+
engines = { default_lang: Model(default_lang) }
|
15 |
|
16 |
def transcribe(audio):
|
17 |
lang = "en"
|
|
|
34 |
"""
|
35 |
|
36 |
def models(text, seed=42):
|
37 |
+
|
38 |
seed = int(randomize_seed_fn(seed))
|
39 |
generator = torch.Generator().manual_seed(seed)
|
40 |
|
|
|
62 |
with tempfile.NamedTemporaryFile(delete=False, suffix=".wav") as tmp_file:
|
63 |
tmp_path = tmp_file.name
|
64 |
await communicate.save(tmp_path)
|
65 |
+
yield tmp_path
|
66 |
|
67 |
DESCRIPTION = """ # <center><b>JARVIS⚡</b></center>
|
68 |
### <center>A personal Assistant of Tony Stark for YOU
|
69 |
### <center>Voice Chat with your personal Assistant</center>
|
70 |
"""
|
71 |
|
72 |
+
with gr.Blocks(css="style.css") as demo:
|
73 |
+
gr.Markdown(DESCRIPTION)
|
74 |
+
with gr.Row():
|
75 |
+
seed = gr.Slider(
|
76 |
+
label="Seed",
|
77 |
+
minimum=0,
|
78 |
+
maximum=999999,
|
79 |
+
step=1,
|
80 |
+
value=0,
|
81 |
+
visible=False
|
82 |
+
)
|
83 |
+
input = gr.Audio(label="User", sources="microphone", type="filepath", waveform_options=False)
|
84 |
+
output = gr.Audio(label="AI", type="filepath",
|
85 |
+
interactive=False,
|
86 |
+
autoplay=True,
|
87 |
+
elem_classes="audio")
|
88 |
+
gr.Interface(
|
89 |
+
batch=True,
|
90 |
+
max_batch_size=10,
|
91 |
+
fn=respond,
|
92 |
+
inputs=[input, select, seed],
|
93 |
+
outputs=[output], live=True)
|
94 |
+
|
95 |
+
if __name__ == "__main__":
|
96 |
+
demo.queue(max_size=200).launch()
|