Helw150 commited on
Commit
0d5fe86
1 Parent(s): 68dbc76

Spinning DiVA

Browse files
app.py CHANGED
@@ -17,7 +17,8 @@ from transformers import AutoModel
17
  from transformers.modeling_outputs import CausalLMOutputWithPast
18
 
19
  orca = pvorca.create(
20
- access_key=os.environ.get("ORCA_KEY"), model_path="./orca_params_masculine.pv"
 
21
  )
22
  LOADER_STR = "♫♪.ılılıll|̲̅̅●̲̅̅|̲̅̅=̲̅̅|̲̅̅●̲̅̅|llılılı.♫♪loading♫♪.ılılıll|̲̅̅●̲̅̅|̲̅̅=̲̅̅|̲̅̅●̲̅̅|llılılı.♫♪loading♫♪.ılılıll|̲̅̅●̲̅̅|̲̅̅=̲̅̅|̲̅̅●̲̅̅|llılılı.♫♪♫"
23
  if gr.NO_RELOAD:
@@ -101,6 +102,7 @@ def response(state: AppState, audio: tuple):
101
  state.model_outs = None
102
  prev_outs = causal_outs
103
  stream = orca.stream_open()
 
104
  for resp, outs in diva_audio(
105
  (audio[0], audio[1]),
106
  prev_outs=(prev_outs if prev_outs is not None else None),
@@ -183,6 +185,8 @@ async function main() {
183
  if (record != null) {
184
  console.log(record);
185
  record.click();
 
 
186
  }
187
  },
188
  onSpeechEnd: (audio) => {
@@ -190,6 +194,8 @@ async function main() {
190
  if (stop != null) {
191
  console.log(stop);
192
  stop.click();
 
 
193
  }
194
  }
195
  })
@@ -208,21 +214,47 @@ js_reset = """
208
  var record = document.querySelector('.record-button');
209
  record.textContent = "Just Start Talking!"
210
  record.style = "width: 11vw"
 
 
 
 
 
 
 
 
 
 
 
 
 
211
  }
212
  """
213
 
214
- with gr.Blocks(theme=theme, js=js) as demo:
215
  with gr.Row():
216
- input_audio = gr.Audio(
217
- label="Input Audio",
218
- sources=["microphone"],
219
- type="numpy",
220
- streaming=False,
221
- )
 
 
 
 
 
 
 
 
222
  with gr.Row():
223
  chatbot = gr.Chatbot(label="Conversation", type="messages")
224
- with gr.Row():
225
- output_audio = gr.Audio(label="Output Audio", streaming=True, autoplay=True)
 
 
 
 
 
226
  state = gr.State(value=AppState())
227
  stream = input_audio.start_recording(
228
  process_audio,
 
17
  from transformers.modeling_outputs import CausalLMOutputWithPast
18
 
19
  orca = pvorca.create(
20
+ access_key=os.environ.get("ORCA_KEY"),
21
+ model_path="./static/orca_params_masculine.pv",
22
  )
23
  LOADER_STR = "♫♪.ılılıll|̲̅̅●̲̅̅|̲̅̅=̲̅̅|̲̅̅●̲̅̅|llılılı.♫♪loading♫♪.ılılıll|̲̅̅●̲̅̅|̲̅̅=̲̅̅|̲̅̅●̲̅̅|llılılı.♫♪loading♫♪.ılılıll|̲̅̅●̲̅̅|̲̅̅=̲̅̅|̲̅̅●̲̅̅|llılılı.♫♪♫"
24
  if gr.NO_RELOAD:
 
102
  state.model_outs = None
103
  prev_outs = causal_outs
104
  stream = orca.stream_open()
105
+
106
  for resp, outs in diva_audio(
107
  (audio[0], audio[1]),
108
  prev_outs=(prev_outs if prev_outs is not None else None),
 
185
  if (record != null) {
186
  console.log(record);
187
  record.click();
188
+ var logo = document.querySelector('.spinning-logo');
189
+ logo.style = "animation: rotation 10s infinite linear; height: 10vw; margin: auto;"
190
  }
191
  },
192
  onSpeechEnd: (audio) => {
 
194
  if (stop != null) {
195
  console.log(stop);
196
  stop.click();
197
+ var logo = document.querySelector('.spinning-logo');
198
+ logo.style = "animation: rotation 1s infinite linear; height: 10vw; margin: auto;"
199
  }
200
  }
201
  })
 
214
  var record = document.querySelector('.record-button');
215
  record.textContent = "Just Start Talking!"
216
  record.style = "width: 11vw"
217
+ var logo = document.querySelector('.spinning-logo');
218
+ logo.style = "height: 10vw; margin: auto;"
219
+ }
220
+ """
221
+
222
+ css = """
223
+ @keyframes rotation {
224
+ from {
225
+ transform: rotate(0deg);
226
+ }
227
+ to {
228
+ transform: rotate(360deg);
229
+ }
230
  }
231
  """
232
 
233
+ with gr.Blocks(theme=theme, js=js, css=css) as demo:
234
  with gr.Row():
235
+ with gr.Column(scale=9):
236
+ gr.HTML(
237
+ """
238
+ <img class="spinning-logo" src="https://diva-audio.github.io/static/DiVA-logo.png" alt="A Cute Small Robot with DiVA Written on It's Chest" style="height: 10vw; margin: auto;">
239
+ """
240
+ )
241
+ with gr.Column(scale=1):
242
+ input_audio = gr.Audio(
243
+ label="Input Audio",
244
+ sources=["microphone"],
245
+ type="numpy",
246
+ streaming=False,
247
+ waveform_options=gr.WaveformOptions(show_recording_waveform=False),
248
+ )
249
  with gr.Row():
250
  chatbot = gr.Chatbot(label="Conversation", type="messages")
251
+ with gr.Row(max_height="50vh"):
252
+ output_audio = gr.Audio(
253
+ label="Output Audio",
254
+ streaming=True,
255
+ autoplay=True,
256
+ visible=False,
257
+ )
258
  state = gr.State(value=AppState())
259
  stream = input_audio.start_recording(
260
  process_audio,
orca_params_masculine.pv → static/orca_params_masculine.pv RENAMED
File without changes