fffiloni commited on
Commit
4e010a1
1 Parent(s): 981a861

Handle custom audio input correctly

Browse files
Files changed (1) hide show
  1. app.py +25 -12
app.py CHANGED
@@ -11,11 +11,34 @@ def convert_to_mp4_with_aac(input_path, output_path):
11
 
12
  return output_path
13
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
14
  def load_audio(audio_listed):
15
  if audio_listed is None:
16
  return None
17
  else:
18
- return f"data/audio/{audio_listed}"
 
 
 
 
 
 
 
19
 
20
  def execute_command(command: str) -> None:
21
  subprocess.run(command, check=True)
@@ -88,17 +111,7 @@ with gr.Blocks(css=css) as demo:
88
  with gr.Row():
89
  audio_list = gr.Dropdown(
90
  label="Choose an audio (optional)",
91
- choices=[
92
- "German1.wav", "German2.wav", "German3.wav", "German4.wav",
93
- "acknowledgement_chinese.m4a", "acknowledgement_english.m4a",
94
- "chinese1_haierlizhi.wav", "chinese2_guanyu.wav",
95
- "french1.wav", "french2.wav", "french3.wav",
96
- "italian1.wav", "italian2.wav", "italian3.wav",
97
- "japan1.wav", "japan2.wav", "japan3.wav",
98
- "korean1.wav", "korean2.wav", "korean3.wav",
99
- "noisy_audio_cafeter_snr_0.wav", "noisy_audio_meeting_snr_0.wav", "noisy_audio_meeting_snr_10.wav", "noisy_audio_meeting_snr_20.wav", "noisy_audio_narrative.wav", "noisy_audio_office_snr_0.wav", "out_of_domain_narrative.wav",
100
- "spanish1.wav", "spanish2.wav", "spanish3.wav"
101
- ],
102
  value = "acknowledgement_english.m4a"
103
  )
104
  audio_list.change(
 
11
 
12
  return output_path
13
 
14
+ audio_list = [
15
+ "German1.wav", "German2.wav", "German3.wav", "German4.wav",
16
+ "acknowledgement_chinese.m4a", "acknowledgement_english.m4a",
17
+ "chinese1_haierlizhi.wav", "chinese2_guanyu.wav",
18
+ "french1.wav", "french2.wav", "french3.wav",
19
+ "italian1.wav", "italian2.wav", "italian3.wav",
20
+ "japan1.wav", "japan2.wav", "japan3.wav",
21
+ "korean1.wav", "korean2.wav", "korean3.wav",
22
+ "noisy_audio_cafeter_snr_0.wav", "noisy_audio_meeting_snr_0.wav", "noisy_audio_meeting_snr_10.wav", "noisy_audio_meeting_snr_20.wav", "noisy_audio_narrative.wav", "noisy_audio_office_snr_0.wav", "out_of_domain_narrative.wav",
23
+ "spanish1.wav", "spanish2.wav", "spanish3.wav"
24
+ ]
25
+
26
+ # Function to check if the audio file path exists in the list
27
+ def check_file_exists(file_path, audio_list):
28
+ return file_path in audio_list
29
+
30
  def load_audio(audio_listed):
31
  if audio_listed is None:
32
  return None
33
  else:
34
+ if check_file_exists(audio_listed, audio_list):
35
+ print(f"The file {audio_listed} exists in the list.")
36
+ return f"data/audio/{audio_listed}"
37
+
38
+ else:
39
+ print(f"The file {audio_listed} does not exist in the list.")
40
+ return f"{audio_listed}"
41
+
42
 
43
  def execute_command(command: str) -> None:
44
  subprocess.run(command, check=True)
 
111
  with gr.Row():
112
  audio_list = gr.Dropdown(
113
  label="Choose an audio (optional)",
114
+ choices=audio_list,
 
 
 
 
 
 
 
 
 
 
115
  value = "acknowledgement_english.m4a"
116
  )
117
  audio_list.change(