KingNish commited on
Commit
6229408
1 Parent(s): 08863b4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +29 -18
app.py CHANGED
@@ -1,4 +1,4 @@
1
- import streamlit as st
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
- return tmp_path
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
- st.markdown(DESCRIPTION)
72
- st.title("JARVIS")
73
-
74
- uploaded_file = st.file_uploader("Upload audio file", type=["wav"])
75
- seed = st.slider("Seed", min_value=0, max_value=999999, value=0)
76
- if uploaded_file is not None:
77
- # Convert the uploaded file to a BytesIO object
78
- audio_bytes = uploaded_file.read()
79
-
80
- # Process the audio using the respond function
81
- response_path = asyncio.run(respond(audio_bytes, models, seed))
82
-
83
- # Display the audio response
84
- st.audio(response_path, format="audio/wav")
85
- os.remove(response_path)
 
 
 
 
 
 
 
 
 
 
 
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()