refactor: re-raise Exception
Browse files- generation_utils.py +5 -11
generation_utils.py
CHANGED
@@ -115,9 +115,7 @@ def load_audio_data(prompt_audio, target_sample_rate=16000):
|
|
115 |
return wav
|
116 |
except Exception as e:
|
117 |
print(f"Error loading audio data: {e}")
|
118 |
-
|
119 |
-
traceback.print_exc()
|
120 |
-
return None
|
121 |
|
122 |
|
123 |
def _load_single_audio(audio_input):
|
@@ -167,7 +165,7 @@ def merge_speaker_audios(wav1, sr1, wav2, sr2, target_sample_rate=16000):
|
|
167 |
return merged_wav
|
168 |
except Exception as e:
|
169 |
print(f"Error merging audio: {e}")
|
170 |
-
|
171 |
|
172 |
|
173 |
def process_inputs(tokenizer, spt, prompt, text, device, audio_data=None, max_channels=8, pad_token=1024):
|
@@ -196,9 +194,7 @@ def process_inputs(tokenizer, spt, prompt, text, device, audio_data=None, max_ch
|
|
196 |
input_ids = np.concatenate([input_ids, audio_token])[:-60]
|
197 |
except Exception as e:
|
198 |
print(f"Error processing audio data: {e}")
|
199 |
-
|
200 |
-
traceback.print_exc()
|
201 |
-
# If error occurs, still return input without audio
|
202 |
|
203 |
return input_ids
|
204 |
|
@@ -434,7 +430,7 @@ def process_batch(batch_items, tokenizer, model, spt, device, system_prompt, sta
|
|
434 |
print(f"Audio generation completed: sample {start_idx + i}")
|
435 |
|
436 |
except Exception as e:
|
437 |
-
print(f"Error processing sample {start_idx + i}: {str(e)}")
|
438 |
import traceback
|
439 |
traceback.print_exc()
|
440 |
audio_results.append(None)
|
@@ -447,6 +443,4 @@ def process_batch(batch_items, tokenizer, model, spt, device, system_prompt, sta
|
|
447 |
|
448 |
except Exception as e:
|
449 |
print(f"Error during batch processing: {str(e)}")
|
450 |
-
|
451 |
-
traceback.print_exc()
|
452 |
-
return [], [None] * len(batch_items)
|
|
|
115 |
return wav
|
116 |
except Exception as e:
|
117 |
print(f"Error loading audio data: {e}")
|
118 |
+
raise
|
|
|
|
|
119 |
|
120 |
|
121 |
def _load_single_audio(audio_input):
|
|
|
165 |
return merged_wav
|
166 |
except Exception as e:
|
167 |
print(f"Error merging audio: {e}")
|
168 |
+
raise
|
169 |
|
170 |
|
171 |
def process_inputs(tokenizer, spt, prompt, text, device, audio_data=None, max_channels=8, pad_token=1024):
|
|
|
194 |
input_ids = np.concatenate([input_ids, audio_token])[:-60]
|
195 |
except Exception as e:
|
196 |
print(f"Error processing audio data: {e}")
|
197 |
+
raise
|
|
|
|
|
198 |
|
199 |
return input_ids
|
200 |
|
|
|
430 |
print(f"Audio generation completed: sample {start_idx + i}")
|
431 |
|
432 |
except Exception as e:
|
433 |
+
print(f"Error processing sample {start_idx + i}: {str(e)}, skipping...")
|
434 |
import traceback
|
435 |
traceback.print_exc()
|
436 |
audio_results.append(None)
|
|
|
443 |
|
444 |
except Exception as e:
|
445 |
print(f"Error during batch processing: {str(e)}")
|
446 |
+
raise
|
|
|
|