ASesYusuf1 commited on
Commit
b00852e
·
verified ·
1 Parent(s): a0c4c4a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -20
app.py CHANGED
@@ -11,7 +11,7 @@ from audio_separator.separator import Separator
11
  import numpy as np
12
  import librosa
13
  import soundfile as sf
14
- from ensemble import ensemble_files
15
  import shutil
16
  import gradio_client.utils as client_utils
17
  import matchering as mg
@@ -22,11 +22,11 @@ from pydub import AudioSegment
22
  import gc
23
  import time
24
 
25
- # Logging setup (mevcut)
26
  logging.basicConfig(level=logging.INFO)
27
  logger = logging.getLogger(__name__)
28
 
29
- # Gradio JSON schema yaması (düzeltilmiş)
30
  original_json_schema_to_python_type = client_utils._json_schema_to_python_type
31
 
32
  def patched_json_schema_to_python_type(schema: Any, defs: Optional[dict] = None) -> str:
@@ -53,7 +53,6 @@ device = "cuda" if torch.cuda.is_available() else "cpu"
53
  use_autocast = device == "cuda"
54
  logger.info(f"Using device: {device}")
55
 
56
-
57
  # ROFORMER_MODELS and OUTPUT_FORMATS
58
  ROFORMER_MODELS = {
59
  "Vocals": {
@@ -148,7 +147,7 @@ ROFORMER_MODELS = {
148
 
149
  OUTPUT_FORMATS = ['wav', 'flac', 'mp3', 'ogg', 'opus', 'm4a', 'aiff', 'ac3']
150
 
151
- # CSS (unchanged from provided version)
152
  CSS = """
153
  body {
154
  background: linear-gradient(to bottom, rgba(45, 11, 11, 0.9), rgba(0, 0, 0, 0.8)), url('/content/logo.jpg') no-repeat center center fixed;
@@ -217,21 +216,22 @@ button:hover {
217
  .compact-dropdown {
218
  padding: 8px 12px !important;
219
  border-radius: 8px !important;
220
- border: 2px solid #ff6b6b !important; /* Match previous style */
221
- background: rgba(46, 26, 71, 0.7) !important; /* Match previous style */
222
- color: #e0e0e0 !important; /* Match previous style */
223
  width: 100%;
224
  font-size: 1rem !important;
225
  transition: border-color 0.3s ease, box-shadow 0.3s ease !important;
226
  position: relative;
227
- z-index: 100; /* Base z-index for dropdown */
228
  }
229
  .compact-dropdown:hover {
230
- border-color: #ff8787 !important; /* Lighter shade for hover */
231
  box-shadow: 0 2px 8px rgba(255, 107, 107, 0.4) !important;
232
  }
233
  .compact-dropdown select, .compact-dropdown .gr-dropdown {
234
- background: transparent !important;
 
235
  color: #e0e0e0 !important;
236
  border: none !important;
237
  width: 100% !important;
@@ -242,13 +242,13 @@ button:hover {
242
  -moz-appearance: none !important;
243
  }
244
  .compact-dropdown .gr-dropdown-menu {
245
- background: rgba(46, 26, 71, 0.95) !important; /* Match previous style */
246
- border: 2px solid #ff6b6b !important; /* Match previous style */
247
  border-radius: 8px !important;
248
  color: #e0e0e0 !important;
249
  max-height: 300px !important;
250
  overflow-y: auto !important;
251
- z-index: 300 !important; /* Ensure it stays above other elements */
252
  width: 100% !important;
253
  opacity: 1 !important;
254
  visibility: visible !important;
@@ -258,7 +258,7 @@ button:hover {
258
  pointer-events: auto !important;
259
  }
260
  .compact-dropdown:hover .gr-dropdown-menu {
261
- display: block !important; /* Ensure menu stays open on hover */
262
  }
263
  .compact-dropdown .gr-dropdown-menu option {
264
  padding: 8px !important;
@@ -266,7 +266,7 @@ button:hover {
266
  background: transparent !important;
267
  }
268
  .compact-dropdown .gr-dropdown-menu option:hover {
269
- background: rgba(255, 107, 107, 0.3) !important; /* Match hover effect */
270
  }
271
  #custom-progress {
272
  margin-top: 10px;
@@ -563,7 +563,7 @@ def auto_ensemble_process(audio, model_keys, seg_size=128, overlap=0.1, out_form
563
  progress(0.9, desc="Running ensemble...")
564
  logger.info(f"Running ensemble with args: {ensemble_args}")
565
  try:
566
- result = ensemble.ensemble_files(ensemble_args)
567
  if result is None or not os.path.exists(output_file):
568
  raise RuntimeError(f"Ensemble failed, output file not created: {output_file}")
569
  logger.info(f"Ensemble completed, output: {output_file}")
@@ -614,8 +614,8 @@ def download_audio_wrapper(url, cookie_file):
614
  def create_interface():
615
  with gr.Blocks(title="🎵 SESA Fast Separation 🎵", css=CSS, elem_id="app-container") as app:
616
  gr.Markdown("<h1 class='header-text'>🎵 SESA Fast Separation 🎵</h1>")
617
- gr.Markdown("**Note**: If YouTube downloads fail, upload an audio file directly or use a valid cookies file. [Cookie Instructions](https://github.com/yt-dlp/yt-dlp/wiki/Extractors#exporting-youtube-cookies)")
618
- gr.Markdown("**Warning**: Audio files longer than 15 minutes are automatically split into chunks, which may require more time and resources.")
619
  gr.Markdown("**ZeroGPU Notice**: Use up to 2 models for ensemble to avoid timeouts. For large tasks, upload a local WAV file.")
620
  with gr.Tabs():
621
  with gr.Tab("⚙️ Settings"):
@@ -653,7 +653,7 @@ def create_interface():
653
  with gr.Tab("🎚️ Auto Ensemble"):
654
  with gr.Group(elem_classes="dubbing-theme"):
655
  gr.Markdown("### Ensemble Processing")
656
- gr.Markdown("Note: If weights are not specified, equal weights (1.0) are applied to all models. Max 2 models recommended.")
657
  with gr.Row():
658
  ensemble_audio = gr.Audio(label="🎧 Upload Audio", type="filepath", interactive=True)
659
  url_ensemble = gr.Textbox(label="🔗 Or Paste URL", placeholder="YouTube or audio URL", interactive=True)
 
11
  import numpy as np
12
  import librosa
13
  import soundfile as sf
14
+ from ensemble import ensemble_files # Correct import
15
  import shutil
16
  import gradio_client.utils as client_utils
17
  import matchering as mg
 
22
  import gc
23
  import time
24
 
25
+ # Logging setup
26
  logging.basicConfig(level=logging.INFO)
27
  logger = logging.getLogger(__name__)
28
 
29
+ # Gradio JSON schema patch
30
  original_json_schema_to_python_type = client_utils._json_schema_to_python_type
31
 
32
  def patched_json_schema_to_python_type(schema: Any, defs: Optional[dict] = None) -> str:
 
53
  use_autocast = device == "cuda"
54
  logger.info(f"Using device: {device}")
55
 
 
56
  # ROFORMER_MODELS and OUTPUT_FORMATS
57
  ROFORMER_MODELS = {
58
  "Vocals": {
 
147
 
148
  OUTPUT_FORMATS = ['wav', 'flac', 'mp3', 'ogg', 'opus', 'm4a', 'aiff', 'ac3']
149
 
150
+ # CSS (unchanged)
151
  CSS = """
152
  body {
153
  background: linear-gradient(to bottom, rgba(45, 11, 11, 0.9), rgba(0, 0, 0, 0.8)), url('/content/logo.jpg') no-repeat center center fixed;
 
216
  .compact-dropdown {
217
  padding: 8px 12px !important;
218
  border-radius: 8px !important;
219
+ border: 2px solid #ff6b6b !important;
220
+ background: rgba(46, 26, 71, 0.7) !important;
221
+ color: #e0e0e0 !important;
222
  width: 100%;
223
  font-size: 1rem !important;
224
  transition: border-color 0.3s ease, box-shadow 0.3s ease !important;
225
  position: relative;
226
+ z-index: 100;
227
  }
228
  .compact-dropdown:hover {
229
+ border-color: #ff8787 !important;
230
  box-shadow: 0 2px 8px rgba(255, 107, 107, 0.4) !important;
231
  }
232
  .compact-dropdown select, .compact-dropdown .gr-dropdown {
233
+ background: transparent ! thận
234
+
235
  color: #e0e0e0 !important;
236
  border: none !important;
237
  width: 100% !important;
 
242
  -moz-appearance: none !important;
243
  }
244
  .compact-dropdown .gr-dropdown-menu {
245
+ background: rgba(46, 26, 71, 0.95) !important;
246
+ border: 2px solid #ff6b6b !important;
247
  border-radius: 8px !important;
248
  color: #e0e0e0 !important;
249
  max-height: 300px !important;
250
  overflow-y: auto !important;
251
+ z-index: 300 !important;
252
  width: 100% !important;
253
  opacity: 1 !important;
254
  visibility: visible !important;
 
258
  pointer-events: auto !important;
259
  }
260
  .compact-dropdown:hover .gr-dropdown-menu {
261
+ display: block !important;
262
  }
263
  .compact-dropdown .gr-dropdown-menu option {
264
  padding: 8px !important;
 
266
  background: transparent !important;
267
  }
268
  .compact-dropdown .gr-dropdown-menu option:hover {
269
+ background: rgba(255, 107, 107, 0.3) !important;
270
  }
271
  #custom-progress {
272
  margin-top: 10px;
 
563
  progress(0.9, desc="Running ensemble...")
564
  logger.info(f"Running ensemble with args: {ensemble_args}")
565
  try:
566
+ result = ensemble_files(ensemble_args) # Correct function call
567
  if result is None or not os.path.exists(output_file):
568
  raise RuntimeError(f"Ensemble failed, output file not created: {output_file}")
569
  logger.info(f"Ensemble completed, output: {output_file}")
 
614
  def create_interface():
615
  with gr.Blocks(title="🎵 SESA Fast Separation 🎵", css=CSS, elem_id="app-container") as app:
616
  gr.Markdown("<h1 class='header-text'>🎵 SESA Fast Separation 🎵</h1>")
617
+ gr.Markdown("**Note**: If YouTube downloads fail, upload a valid cookies file or a local WAV file. [Cookie Instructions](https://github.com/yt-dlp/yt-dlp/wiki/Extractors#exporting-youtube-cookies)")
618
+ gr.Markdown("**Warning**: Audio files longer than 15 minutes are split into 5-minute chunks, which may increase processing time.")
619
  gr.Markdown("**ZeroGPU Notice**: Use up to 2 models for ensemble to avoid timeouts. For large tasks, upload a local WAV file.")
620
  with gr.Tabs():
621
  with gr.Tab("⚙️ Settings"):
 
653
  with gr.Tab("🎚️ Auto Ensemble"):
654
  with gr.Group(elem_classes="dubbing-theme"):
655
  gr.Markdown("### Ensemble Processing")
656
+ gr.Markdown("Note: If weights are not specified, equal weights (1.0) are applied. Max 2 models recommended to avoid ZeroGPU timeouts.")
657
  with gr.Row():
658
  ensemble_audio = gr.Audio(label="🎧 Upload Audio", type="filepath", interactive=True)
659
  url_ensemble = gr.Textbox(label="🔗 Or Paste URL", placeholder="YouTube or audio URL", interactive=True)