Nekochu commited on
Commit
1549b91
·
1 Parent(s): 2d3c27c

replace per-file cap with total audio cap (30 min max)

Browse files
Files changed (1) hide show
  1. app.py +15 -3
app.py CHANGED
@@ -24,7 +24,7 @@ logger = logging.getLogger(__name__)
24
  # Configurable limits (edit here, not buried in code)
25
  # ---------------------------------------------------------------------------
26
 
27
- MAX_AUDIO_DURATION = 240 # seconds, cap per audio file for training
28
  MAX_TRAINING_TIME = 28800 # 8 hours hard training timeout (seconds)
29
  MAX_AUDIO_FILES = 50 # max number of training audio files per run
30
 
@@ -483,13 +483,25 @@ def gradio_main():
483
  adapter_out = os.path.join(ADAPTER_DIR, lora_name)
484
  os.makedirs(adapter_out, exist_ok=True)
485
 
486
- # Copy uploaded audio files
487
  _log(f"[INFO] Preparing {len(audio_files)} audio files...")
488
  yield _log_text(), gr.update(visible=False), gr.update(visible=True), gr.update()
489
 
 
490
  for f in audio_files:
491
  src = f.name if hasattr(f, "name") else str(f)
492
  shutil.copy2(src, os.path.join(audio_dir, os.path.basename(src)))
 
 
 
 
 
 
 
 
 
 
 
493
 
494
  _log(f"[INFO] LoRA: '{lora_name}' | Files: {len(audio_files)} | "
495
  f"Epochs: {epochs} | LR: {lr} | Rank: {rank}")
@@ -517,7 +529,7 @@ def gradio_main():
517
  checkpoint_dir=ACE_CHECKPOINT_DIR,
518
  device="cpu",
519
  variant="turbo",
520
- max_duration=float(MAX_AUDIO_DURATION),
521
  progress_callback=preprocess_progress,
522
  cancel_check=lambda: False,
523
  )
 
24
  # Configurable limits (edit here, not buried in code)
25
  # ---------------------------------------------------------------------------
26
 
27
+ MAX_TOTAL_AUDIO = 1800 # seconds total across all uploaded files (30 min)
28
  MAX_TRAINING_TIME = 28800 # 8 hours hard training timeout (seconds)
29
  MAX_AUDIO_FILES = 50 # max number of training audio files per run
30
 
 
483
  adapter_out = os.path.join(ADAPTER_DIR, lora_name)
484
  os.makedirs(adapter_out, exist_ok=True)
485
 
486
+ # Copy uploaded audio files + check total duration
487
  _log(f"[INFO] Preparing {len(audio_files)} audio files...")
488
  yield _log_text(), gr.update(visible=False), gr.update(visible=True), gr.update()
489
 
490
+ total_dur = 0.0
491
  for f in audio_files:
492
  src = f.name if hasattr(f, "name") else str(f)
493
  shutil.copy2(src, os.path.join(audio_dir, os.path.basename(src)))
494
+ try:
495
+ import librosa
496
+ total_dur += librosa.get_duration(path=src)
497
+ except Exception:
498
+ pass
499
+
500
+ if total_dur > MAX_TOTAL_AUDIO:
501
+ _log(f"[FAIL] Total audio {total_dur:.0f}s exceeds {MAX_TOTAL_AUDIO}s limit ({MAX_TOTAL_AUDIO/60:.0f} min)")
502
+ yield _log_text(), gr.update(visible=True), gr.update(visible=False), gr.update()
503
+ return
504
+ _log(f"[INFO] Total audio: {total_dur:.0f}s ({total_dur/60:.1f} min)")
505
 
506
  _log(f"[INFO] LoRA: '{lora_name}' | Files: {len(audio_files)} | "
507
  f"Epochs: {epochs} | LR: {lr} | Rank: {rank}")
 
529
  checkpoint_dir=ACE_CHECKPOINT_DIR,
530
  device="cpu",
531
  variant="turbo",
532
+ max_duration=float(MAX_TOTAL_AUDIO),
533
  progress_callback=preprocess_progress,
534
  cancel_check=lambda: False,
535
  )