yuangongfdu commited on
Commit
13eee94
1 Parent(s): f8004f8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -2
app.py CHANGED
@@ -38,7 +38,11 @@ def upload_audio_13b(audio_path):
38
  except:
39
  return None
40
 
41
- def predict(audio_path, question, model):
 
 
 
 
42
  if model == '7B (Default)':
43
  upload_statues = upload_audio(audio_path)
44
  if upload_statues == None:
@@ -79,7 +83,7 @@ if __name__ == '__main__':
79
  sample_audio_link = "https://drive.google.com/drive/folders/17yeBevX0LIS1ugt0DZDOoJolwxvncMja?usp=sharing"
80
  sample_audio_text = "[sample audios from AudioSet evaluation set]"
81
  demo = gr.Interface(fn=predict,
82
- inputs=[gr.Audio(type="filepath"),
83
  gr.Textbox(value='What can be inferred from the spoken text and sounds? Why?', label='Edit the textbox to ask your own questions!'),
84
  gr.Radio(["7B (Default)", "13B (Beta)"], value='7B (Default)', label="LLM size", info="All experiments in the ASRU paper are 7B LLM.")],
85
  outputs=[gr.Textbox(label="LTU-AS-Output")],
 
38
  except:
39
  return None
40
 
41
+ def predict(audio_path_m, audio_path_t, question, model):
42
+ if ((audio_path_m is None) != (audio_path_t is None)) == False:
43
+ return "Please upload and only upload one recording, either upload the audio file or record using microphone.", "Please upload and only upload one recording, either upload the audio file or record using microphone."
44
+ else:
45
+ audio_path = audio_path_m or audio_path_t
46
  if model == '7B (Default)':
47
  upload_statues = upload_audio(audio_path)
48
  if upload_statues == None:
 
83
  sample_audio_link = "https://drive.google.com/drive/folders/17yeBevX0LIS1ugt0DZDOoJolwxvncMja?usp=sharing"
84
  sample_audio_text = "[sample audios from AudioSet evaluation set]"
85
  demo = gr.Interface(fn=predict,
86
+ inputs=[gr.Audio(type="filepath", source='microphone', label='Please either upload an audio file or record using the microphone.', show_label=True), gr.Audio(type="filepath"),
87
  gr.Textbox(value='What can be inferred from the spoken text and sounds? Why?', label='Edit the textbox to ask your own questions!'),
88
  gr.Radio(["7B (Default)", "13B (Beta)"], value='7B (Default)', label="LLM size", info="All experiments in the ASRU paper are 7B LLM.")],
89
  outputs=[gr.Textbox(label="LTU-AS-Output")],