Coco-18 commited on
Commit
41a5193
·
verified ·
1 Parent(s): 1d7248d

Update evaluate.py

Browse files
Files changed (1) hide show
  1. evaluate.py +18 -0
evaluate.py CHANGED
@@ -748,6 +748,9 @@ def handle_evaluation_request(request, reference_dir, output_dir, sample_rate):
748
  additional_files = remaining_files[:5] # Process max 5 more
749
 
750
  # Process remaining files
 
 
 
751
  # Clean up temp files
752
  try:
753
  if temp_dir and os.path.exists(temp_dir):
@@ -814,6 +817,21 @@ def handle_evaluation_request(request, reference_dir, output_dir, sample_rate):
814
  resume_preprocessing()
815
  return response
816
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
817
  def handle_upload_reference(request, reference_dir, sample_rate):
818
  """Handle upload of reference audio files and preprocess immediately"""
819
  global REFERENCE_CACHE
 
748
  additional_files = remaining_files[:5] # Process max 5 more
749
 
750
  # Process remaining files
751
+ additional_results = list(executor.map(process_reference_file, additional_files))
752
+ all_results.extend(additional_results)
753
+
754
  # Clean up temp files
755
  try:
756
  if temp_dir and os.path.exists(temp_dir):
 
817
  resume_preprocessing()
818
  return response
819
 
820
+ except Exception as e:
821
+ logger.error(f"[{request_id}] ❌ Unhandled exception in evaluation endpoint: {str(e)}")
822
+ logger.debug(f"[{request_id}] Stack trace: {traceback.format_exc()}")
823
+
824
+ # Clean up on error
825
+ try:
826
+ if temp_dir and os.path.exists(temp_dir):
827
+ shutil.rmtree(temp_dir)
828
+ except:
829
+ pass
830
+
831
+ # Make sure to resume preprocessing even if there's an error
832
+ resume_preprocessing()
833
+ return jsonify({"error": f"Internal server error: {str(e)}"}), 500
834
+
835
  def handle_upload_reference(request, reference_dir, sample_rate):
836
  """Handle upload of reference audio files and preprocess immediately"""
837
  global REFERENCE_CACHE