SubashUbahs commited on
Commit
3a10bdf
·
verified ·
1 Parent(s): fbaf364

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -11
app.py CHANGED
@@ -131,7 +131,7 @@ footer { display: none !important; }
131
 
132
  def separate_audio(audio_file, progress=gr.Progress()):
133
  if audio_file is None:
134
- return {results_row: gr.update(visible=False)}
135
 
136
  # Step 1: Initialization
137
  progress(0, desc="Initializing...")
@@ -155,6 +155,8 @@ def separate_audio(audio_file, progress=gr.Progress()):
155
  audio_file
156
  ]
157
 
 
 
158
  result = subprocess.run(cmd, capture_output=True, text=True)
159
 
160
  if result.returncode != 0:
@@ -183,13 +185,7 @@ def separate_audio(audio_file, progress=gr.Progress()):
183
  AudioSegment.from_wav(karaoke_wav).export(karaoke_mp3, format="mp3", bitrate="320k")
184
 
185
  progress(1.0, desc="Done!")
186
-
187
- # Return updated visibility and files
188
- return {
189
- results_row: gr.update(visible=True),
190
- karaoke_output: karaoke_mp3,
191
- vocals_output: vocals_mp3
192
- }
193
 
194
  except Exception as e:
195
  print(f"Error: {str(e)}")
@@ -262,8 +258,8 @@ with gr.Blocks(css=custom_css, title="Karaoke Extractor") as app:
262
  audio_input = gr.Audio(type="filepath", label="", sources=["upload"], container=False, interactive=True)
263
  process_btn = gr.Button("✨ Extract Tracks Now", elem_classes="primary-btn")
264
 
265
- # Results Area (Initially Hidden)
266
- with gr.Group(elem_classes="glass-card", visible=False) as results_row:
267
  gr.Markdown("<h2 style='text-align: center; margin-bottom: 20px;'>✨ Your Extracted Tracks</h2>")
268
 
269
  with gr.Row():
@@ -278,7 +274,7 @@ with gr.Blocks(css=custom_css, title="Karaoke Extractor") as app:
278
  process_btn.click(
279
  fn=separate_audio,
280
  inputs=[audio_input],
281
- outputs=[results_row, karaoke_output, vocals_output]
282
  )
283
 
284
  if __name__ == "__main__":
 
131
 
132
  def separate_audio(audio_file, progress=gr.Progress()):
133
  if audio_file is None:
134
+ return None, None
135
 
136
  # Step 1: Initialization
137
  progress(0, desc="Initializing...")
 
155
  audio_file
156
  ]
157
 
158
+ # We can't track real-time Demucs progress easily in subprocess without parsing output
159
+ # So we just run it. The user will see the 0.2 bar while waiting.
160
  result = subprocess.run(cmd, capture_output=True, text=True)
161
 
162
  if result.returncode != 0:
 
185
  AudioSegment.from_wav(karaoke_wav).export(karaoke_mp3, format="mp3", bitrate="320k")
186
 
187
  progress(1.0, desc="Done!")
188
+ return karaoke_mp3, vocals_mp3
 
 
 
 
 
 
189
 
190
  except Exception as e:
191
  print(f"Error: {str(e)}")
 
258
  audio_input = gr.Audio(type="filepath", label="", sources=["upload"], container=False, interactive=True)
259
  process_btn = gr.Button("✨ Extract Tracks Now", elem_classes="primary-btn")
260
 
261
+ # Results Area
262
+ with gr.Group(elem_classes="glass-card", visible=True):
263
  gr.Markdown("<h2 style='text-align: center; margin-bottom: 20px;'>✨ Your Extracted Tracks</h2>")
264
 
265
  with gr.Row():
 
274
  process_btn.click(
275
  fn=separate_audio,
276
  inputs=[audio_input],
277
+ outputs=[karaoke_output, vocals_output]
278
  )
279
 
280
  if __name__ == "__main__":