SefyanKehail commited on
Commit
a064a63
·
1 Parent(s): 1af470c

added progress instead of spinner

Browse files
Files changed (1) hide show
  1. app.py +14 -17
app.py CHANGED
@@ -65,20 +65,18 @@ def convert_speech(filename, progress=gr.Progress()):
65
 
66
  """Convert to the target speaker:"""
67
 
68
- def enable_convert_button(audio):
69
- if audio is not None:
70
- return gr.update(interactive=True)
71
- return gr.update(interactive=False)
72
 
73
  def clear_components():
74
  return None, None
75
 
76
- def show_progress(progress):
77
- return gr.update(visible=True)
78
-
79
- def hide_progress(progress):
80
- return gr.update(visible=False)
81
-
82
 
83
  # Gradio interface
84
  with gr.Blocks() as interface:
@@ -89,18 +87,17 @@ with gr.Blocks() as interface:
89
  with gr.Column():
90
  audio_input = gr.Audio(type="filepath", label="Upload Audio", sources=["upload", "microphone"])
91
  convert_button = gr.Button("Convert Speech", interactive=False)
92
-
 
93
  with gr.Column():
94
  converted_audio = gr.Audio(type="numpy", label="Converted Speech")
95
 
96
 
97
- progress = gr.Progress(visible=False)
98
-
99
- audio_input.change(show_progress, inputs=[audio_input], outputs=[progress])
100
-
101
- audio_input.change(enable_convert_button, inputs=[audio_input], outputs=[convert_button])
102
 
103
- audio_input.change(hide_progress, inputs=[audio_input], outputs=[progress])
104
 
105
  convert_button.click(convert_speech, inputs=[audio_input], outputs=[converted_audio])
106
 
 
65
 
66
  """Convert to the target speaker:"""
67
 
68
+ # def enable_convert_button(audio):
69
+ # if audio is not None:
70
+ # return gr.update(interactive=True)
71
+ # return gr.update(interactive=False)
72
 
73
  def clear_components():
74
  return None, None
75
 
76
+ def enable_convert_button(audio, progress=gr.Progress()):
77
+ if audio is not None:
78
+ return gr.update(interactive=True), gr.update(value=None) # Enable button and hide progress
79
+ return gr.update(interactive=False), gr.update(value=None) # Hide progress if no audio
 
 
80
 
81
  # Gradio interface
82
  with gr.Blocks() as interface:
 
87
  with gr.Column():
88
  audio_input = gr.Audio(type="filepath", label="Upload Audio", sources=["upload", "microphone"])
89
  convert_button = gr.Button("Convert Speech", interactive=False)
90
+ progress = gr.Progress(visible=False)
91
+
92
  with gr.Column():
93
  converted_audio = gr.Audio(type="numpy", label="Converted Speech")
94
 
95
 
96
+ def process_audio(audio):
97
+ progress.update(visible=True) # Show progress
98
+ return enable_convert_button(audio, progress)
 
 
99
 
100
+ audio_input.change(process_audio, inputs=[audio_input], outputs=[convert_button, progress])
101
 
102
  convert_button.click(convert_speech, inputs=[audio_input], outputs=[converted_audio])
103