akshansh36 commited on
Commit
60d7050
1 Parent(s): 0faaa99

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -49
app.py CHANGED
@@ -286,30 +286,13 @@ def index_conf():
286
  interactive=True,
287
  )
288
 
289
- # def audio_conf():
290
- # return gr.Audio(
291
- # label="Upload or Record Audio",
292
- # sources=["upload", "microphone"], # Allows recording via microphone
293
- # type="filepath",
294
-
295
- # )
296
-
297
-
298
- def get_audio_input(source_type):
299
- if source_type == "Upload Audio File":
300
- return gr.Files(
301
- label="Upload Audio Files",
302
- type="filepath",
303
- file_count="multiple"
304
- )
305
- else:
306
- return gr.Audio(
307
- label="Record Audio",
308
- sources=["microphone"],
309
- type="filepath"
310
- )
311
-
312
 
 
313
 
314
  def button_conf():
315
  return gr.Button(
@@ -324,42 +307,29 @@ def get_gui(theme):
324
  with gr.Blocks(theme=theme, delete_cache=(3200, 3200)) as app:
325
  gr.Markdown(title)
326
 
327
- source_type = gr.Radio(
328
- choices=["Upload Audio File", "Record Audio"],
329
- label="Input Audio Type",
330
- value="Upload Audio File",
331
- interactive=True
332
- )
333
-
334
- audio_input = gr.State()
335
-
336
-
337
-
338
- audio_input_component = gr.Column()
339
-
340
- def update_audio_input(choice):
341
- return gr.Row([get_audio_input(choice)])
342
-
343
- source_type.change(
344
- update_audio_input,
345
- inputs=source_type,
346
- outputs=audio_input_component
347
- )
348
-
349
  model = model_conf()
350
  indx = index_conf()
351
  button_base = button_conf()
352
  output_file, output_audio = output_conf()
353
 
354
- with audio_input_component:
355
- audio_input = get_audio_input("Upload Audio File") # Default
356
-
357
  button_base.click(
358
  process_audio,
359
- inputs=[audio_input, model, indx],
360
  outputs=[output_file, output_audio],
361
  )
362
 
 
 
 
 
 
 
 
 
 
 
 
363
  return app
364
 
365
  if __name__ == "__main__":
@@ -374,3 +344,4 @@ if __name__ == "__main__":
374
  allowed_paths=["./downloads/"],
375
  )
376
 
 
 
286
  interactive=True,
287
  )
288
 
289
+ def audio_conf():
290
+ return gr.Audio(
291
+ label="Upload or Record Audio",
292
+ sources=["upload", "microphone"], # Allows recording via microphone
293
+ type="filepath",
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
294
 
295
+ )
296
 
297
  def button_conf():
298
  return gr.Button(
 
307
  with gr.Blocks(theme=theme, delete_cache=(3200, 3200)) as app:
308
  gr.Markdown(title)
309
 
310
+ aud = audio_conf()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
311
  model = model_conf()
312
  indx = index_conf()
313
  button_base = button_conf()
314
  output_file, output_audio = output_conf()
315
 
 
 
 
316
  button_base.click(
317
  process_audio,
318
+ inputs=[aud, model, indx],
319
  outputs=[output_file, output_audio],
320
  )
321
 
322
+ gr.Examples(
323
+ examples=[
324
+ ["./test.ogg", "./model.pth", "./model.index"],
325
+ ["./example2/test2.ogg", "./example2/model.pth", "./example2/model.index"],
326
+ ],
327
+ fn=process_audio,
328
+ inputs=[aud, model, indx],
329
+ outputs=[output_file, output_audio],
330
+ cache_examples=False,
331
+ )
332
+
333
  return app
334
 
335
  if __name__ == "__main__":
 
344
  allowed_paths=["./downloads/"],
345
  )
346
 
347
+