Loren commited on
Commit
55a67b4
Β·
verified Β·
1 Parent(s): 89ac223

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -13
app.py CHANGED
@@ -214,9 +214,9 @@ def process_chat(question: str, audio_path: str) -> str:
214
  decoded_outputs = processor.batch_decode(outputs[:, inputs.input_ids.shape[1]:], skip_special_tokens=True)
215
 
216
  result = decoded_outputs[0]
217
- status = "βœ… **Success!** Translation done."
218
  except Exception as e:
219
- status = gr.Markdown(f"❌ **Unexpected error during translation:** {e}")
220
 
221
  return result, status
222
  ###
@@ -229,7 +229,7 @@ def enable_buttons():
229
  ###
230
 
231
  def clear_audio():
232
- return None, None, None, None
233
  ###
234
 
235
  @spaces.GPU
@@ -245,7 +245,7 @@ def voice_extract_demucs():
245
  "audio_file.wav"
246
  ]
247
  subprocess.run(cmd, check=True)
248
- voice_path = os.path.join("demucs", "htdemucs", "audio_file", "vocals.wav")
249
  success_message = "βœ… **Success!** Voice extracted. ("+voice_path+")"
250
  return voice_path, voice_path, gr.Markdown(success_message)
251
  except Exception as e:
@@ -404,11 +404,6 @@ def secure_download_youtube_audio(url: str):
404
  return None, None, gr.Markdown(f"❌ **Error:** An unexpected ERROR occurred: {e}")
405
  ###
406
 
407
-
408
- def clear_audio():
409
- return None, None, None, None
410
- ###
411
-
412
  def get_sel_audio(audio_path: str) -> str:
413
  return audio_path, gr.Markdown("βœ… **Original** audio is considered.")
414
  ###
@@ -465,7 +460,9 @@ with gr.Blocks(title="Voxtral") as voxtral:
465
  clear_audio1 = gr.Button("Clear audio")
466
  clear_audio1.click(
467
  fn=clear_audio,
468
- outputs=[sel_audio, sel_audio, sel_audio1, status_output1])
 
 
469
 
470
  with gr.Tab("From file url (audio or video file)"):
471
  gr.Markdown("### **Enter the url of the file (mp3, wav, mp4, ...):**")
@@ -496,7 +493,9 @@ with gr.Blocks(title="Voxtral") as voxtral:
496
  clear_audio1 = gr.Button("Clear audio")
497
  clear_audio1.click(
498
  fn=clear_audio,
499
- outputs=[sel_audio, url_input2, input_audio2, status_output2])
 
 
500
 
501
  with gr.Tab("From Youtube url:"):
502
  gr.Markdown("### **Enter the url of the Youtube video:**")
@@ -518,7 +517,9 @@ with gr.Blocks(title="Voxtral") as voxtral:
518
  clear_audio1 = gr.Button("Clear audio")
519
  clear_audio1.click(
520
  fn=clear_audio,
521
- outputs=[sel_audio, url_input3, input_audio3, status_output3])
 
 
522
 
523
  with gr.Row():
524
  gr.Markdown("### **2. Choose one of theese tasks:**")
@@ -546,7 +547,7 @@ with gr.Blocks(title="Voxtral") as voxtral:
546
  )
547
  submit_translate = gr.Button("Translate audio file", variant="primary")
548
  text_translate = gr.Textbox(label="πŸ’¬ Generated translation", lines=10)
549
- status_translate = gr.Markdown()
550
 
551
  with gr.Column():
552
  with gr.Accordion("πŸ€– Ask audio file", open=True):
 
214
  decoded_outputs = processor.batch_decode(outputs[:, inputs.input_ids.shape[1]:], skip_special_tokens=True)
215
 
216
  result = decoded_outputs[0]
217
+ status = "βœ… **Success!**"
218
  except Exception as e:
219
+ status = gr.Markdown(f"❌ **Unexpected error during chat process:** {e}")
220
 
221
  return result, status
222
  ###
 
229
  ###
230
 
231
  def clear_audio():
232
+ return None, None, None, None, None, None, None, None, None, None, None
233
  ###
234
 
235
  @spaces.GPU
 
245
  "audio_file.wav"
246
  ]
247
  subprocess.run(cmd, check=True)
248
+ voice_path = os.path.join(".", "demucs", "htdemucs", "audio_file", "vocals.wav")
249
  success_message = "βœ… **Success!** Voice extracted. ("+voice_path+")"
250
  return voice_path, voice_path, gr.Markdown(success_message)
251
  except Exception as e:
 
404
  return None, None, gr.Markdown(f"❌ **Error:** An unexpected ERROR occurred: {e}")
405
  ###
406
 
 
 
 
 
 
407
  def get_sel_audio(audio_path: str) -> str:
408
  return audio_path, gr.Markdown("βœ… **Original** audio is considered.")
409
  ###
 
460
  clear_audio1 = gr.Button("Clear audio")
461
  clear_audio1.click(
462
  fn=clear_audio,
463
+ outputs=[sel_audio, sel_audio, sel_audio1, status_output1, text_transcript,
464
+ status_transcript, text_translate, text_translate, question_chat,
465
+ text_chat, status_chat])
466
 
467
  with gr.Tab("From file url (audio or video file)"):
468
  gr.Markdown("### **Enter the url of the file (mp3, wav, mp4, ...):**")
 
493
  clear_audio1 = gr.Button("Clear audio")
494
  clear_audio1.click(
495
  fn=clear_audio,
496
+ outputs=[sel_audio, sel_audio, sel_audio1, status_output1, text_transcript,
497
+ status_transcript, text_translate, text_translate, question_chat,
498
+ text_chat, status_chat])
499
 
500
  with gr.Tab("From Youtube url:"):
501
  gr.Markdown("### **Enter the url of the Youtube video:**")
 
517
  clear_audio1 = gr.Button("Clear audio")
518
  clear_audio1.click(
519
  fn=clear_audio,
520
+ outputs=[sel_audio, sel_audio, sel_audio1, status_output1, text_transcript,
521
+ status_transcript, text_translate, text_translate, question_chat,
522
+ text_chat, status_chat])
523
 
524
  with gr.Row():
525
  gr.Markdown("### **2. Choose one of theese tasks:**")
 
547
  )
548
  submit_translate = gr.Button("Translate audio file", variant="primary")
549
  text_translate = gr.Textbox(label="πŸ’¬ Generated translation", lines=10)
550
+ text_translate = gr.Markdown()
551
 
552
  with gr.Column():
553
  with gr.Accordion("πŸ€– Ask audio file", open=True):