KevinGeng commited on
Commit
88cfae4
1 Parent(s): 41e352d
Files changed (1) hide show
  1. app.py +24 -20
app.py CHANGED
@@ -11,6 +11,7 @@ import torch
11
  import torchaudio
12
  from transformers import pipeline
13
  from pathlib import Path
 
14
 
15
  # local import
16
  import sys
@@ -151,10 +152,6 @@ def ASRTTS_clean(audio_file, spk_name):
151
  return save_id
152
 
153
 
154
- # def ref_reg_callback(audio_file, spk_name, ref_text):
155
- # reg_text = ref_text
156
- # return audio_file, spk_name, reg_text
157
-
158
  reference_textbox = gr.Textbox(
159
  value="",
160
  placeholder="Input reference here",
@@ -168,17 +165,6 @@ recognization_textbox = gr.Textbox(
168
  )
169
 
170
  speaker_option = gr.Radio(choices=spk_names, label="Speaker")
171
- # speaker_profiles = {
172
- # "Male_1": "speaker_icons/male1.png",
173
- # "Male_2": "speaker_icons/male2.png",
174
- # "Female_1": "speaker_icons/female1.png",
175
- # "Female_2": "speaker_icons/female2.png",
176
- # }
177
-
178
- # speaker_option = gr.Image(label="Choose your speaker profile",
179
- # image_mode="RGB",
180
- # options=speaker_profiles
181
- # )
182
 
183
  input_audio = gr.Audio(
184
  source="upload", type="filepath", label="Audio_to_Evaluate"
@@ -215,21 +201,35 @@ def show_icon(choice):
215
  spk_icon = gr.Image.update(value="speaker_icons/female2.png", visible=True)
216
  return spk_icon
217
 
 
 
 
 
 
 
 
 
 
 
 
 
 
218
 
219
  with gr.Blocks(
220
  analytics_enabled=False,
221
  css=".gradio-container {background-color: #78BD91}",
222
  ) as demo:
223
- with gr.Column():
224
  input_format = gr.Radio(
225
- choices=["microphone", "upload"], label="Choose your input format"
226
  )
227
  input_audio = gr.Audio(
228
- source="upload",
229
  type="filepath",
230
  label="Input Audio",
231
  interactive=True,
232
  visible=False,
 
233
  )
234
  input_format.change(
235
  fn=change_audiobox, inputs=input_format, outputs=input_audio
@@ -248,14 +248,18 @@ with gr.Blocks(
248
  )
249
 
250
  b2 = gr.Button("Convert")
251
-
252
  output_audio = gr.Audio(
253
- source="upload", file="filepath", label="Converted Audio"
254
  )
 
255
  b2.click(
256
  ASRTTS_clean,
257
  inputs=[input_audio, speaker_option],
258
  outputs=output_audio,
 
259
  )
 
 
260
 
261
  demo.launch(share=False)
 
11
  import torchaudio
12
  from transformers import pipeline
13
  from pathlib import Path
14
+ from flask import Flask, send_file
15
 
16
  # local import
17
  import sys
 
152
  return save_id
153
 
154
 
 
 
 
 
155
  reference_textbox = gr.Textbox(
156
  value="",
157
  placeholder="Input reference here",
 
165
  )
166
 
167
  speaker_option = gr.Radio(choices=spk_names, label="Speaker")
 
 
 
 
 
 
 
 
 
 
 
168
 
169
  input_audio = gr.Audio(
170
  source="upload", type="filepath", label="Audio_to_Evaluate"
 
201
  spk_icon = gr.Image.update(value="speaker_icons/female2.png", visible=True)
202
  return spk_icon
203
 
204
+ def get_download_file(audio_file=None):
205
+ if audio_file == None:
206
+ output_audio_file = gr.File.update(visible=False)
207
+ else:
208
+ output_audio_file = gr.File.update(visible=True)
209
+ return output_audio_file
210
+
211
+ def download_file(audio_file):
212
+ return gr.File(value=audio_file)
213
+ # pdb.set_trace()
214
+
215
+ # if __name__ == "__main__":
216
+ # file_share_app.run(port=3000)
217
 
218
  with gr.Blocks(
219
  analytics_enabled=False,
220
  css=".gradio-container {background-color: #78BD91}",
221
  ) as demo:
222
+ with gr.Column(elem_id="Column"):
223
  input_format = gr.Radio(
224
+ choices=["microphone", "upload"], label="Choose your input format", elem_id="input_format"
225
  )
226
  input_audio = gr.Audio(
227
+ source="microphone",
228
  type="filepath",
229
  label="Input Audio",
230
  interactive=True,
231
  visible=False,
232
+ elem_id="input_audio"
233
  )
234
  input_format.change(
235
  fn=change_audiobox, inputs=input_format, outputs=input_audio
 
248
  )
249
 
250
  b2 = gr.Button("Convert")
251
+
252
  output_audio = gr.Audio(
253
+ source="upload", file="filepath", label="Converted Audio", interactive=False
254
  )
255
+
256
  b2.click(
257
  ASRTTS_clean,
258
  inputs=[input_audio, speaker_option],
259
  outputs=output_audio,
260
+ api_name="convert"
261
  )
262
+
263
+ # download_file("wav/001_F1_spkembs.wav")
264
 
265
  demo.launch(share=False)