Coco-18 commited on
Commit
91e93fa
Β·
verified Β·
1 Parent(s): d7f9642

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -1
app.py CHANGED
@@ -742,11 +742,24 @@ def upload_reference_audio():
742
  logger.debug(f"Stack trace: {traceback.format_exc()}")
743
  return jsonify({"error": f"Internal server error: {str(e)}"}), 500
744
 
745
- # Ensure directory exists
746
  def init_reference_audio():
747
  try:
748
  os.makedirs(REFERENCE_AUDIO_DIR, exist_ok=True)
749
  logger.info(f"πŸ“ Created reference audio directory: {REFERENCE_AUDIO_DIR}")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
750
  except Exception as e:
751
  logger.error(f"❌ Failed to set up reference audio directory: {str(e)}")
752
 
 
742
  logger.debug(f"Stack trace: {traceback.format_exc()}")
743
  return jsonify({"error": f"Internal server error: {str(e)}"}), 500
744
 
 
745
  def init_reference_audio():
746
  try:
747
  os.makedirs(REFERENCE_AUDIO_DIR, exist_ok=True)
748
  logger.info(f"πŸ“ Created reference audio directory: {REFERENCE_AUDIO_DIR}")
749
+
750
+ # Copy reference files from repository to runtime directory
751
+ if os.path.exists(REPO_REFERENCE_DIR):
752
+ for pattern_dir in os.listdir(REPO_REFERENCE_DIR):
753
+ src_dir = os.path.join(REPO_REFERENCE_DIR, pattern_dir)
754
+ if os.path.isdir(src_dir):
755
+ dst_dir = os.path.join(REFERENCE_AUDIO_DIR, pattern_dir)
756
+ os.makedirs(dst_dir, exist_ok=True)
757
+
758
+ # Copy all wav files
759
+ for wav_file in glob.glob(os.path.join(src_dir, "*.wav")):
760
+ shutil.copy(wav_file, dst_dir)
761
+
762
+ logger.info(f"πŸ“ Copied reference files from repository")
763
  except Exception as e:
764
  logger.error(f"❌ Failed to set up reference audio directory: {str(e)}")
765