Merge pull request #49 from dotsimulate/fix/save-path-handling

Fix: Correct save_path handling in ACEStepPipeline
This commit is contained in:
sean
2025-05-08 11:38:53 +08:00
committed by GitHub
+13 -9
View File
@@ -1329,8 +1329,8 @@ class ACEStepPipeline:
pred_wavs = [pred_wav.cpu().float() for pred_wav in pred_wavs] pred_wavs = [pred_wav.cpu().float() for pred_wav in pred_wavs]
for i in tqdm(range(bs)): for i in tqdm(range(bs)):
output_audio_path = self.save_wav_file( output_audio_path = self.save_wav_file(
pred_wavs[i], i, sample_rate=sample_rate pred_wavs[i], i, save_path=save_path, sample_rate=sample_rate, format=format
) )
output_audio_paths.append(output_audio_path) output_audio_paths.append(output_audio_path)
return output_audio_paths return output_audio_paths
@@ -1341,15 +1341,19 @@ class ACEStepPipeline:
logger.warning("save_path is None, using default path ./outputs/") logger.warning("save_path is None, using default path ./outputs/")
base_path = f"./outputs" base_path = f"./outputs"
ensure_directory_exists(base_path) ensure_directory_exists(base_path)
output_path_wav = (
f"{base_path}/output_{time.strftime('%Y%m%d%H%M%S')}_{idx}.wav"
)
else: else:
base_path = save_path ensure_directory_exists(os.path.dirname(save_path))
ensure_directory_exists(base_path) if os.path.isdir(save_path):
logger.info(f"Provided save_path '{save_path}' is a directory. Appending timestamped filename.")
output_path_wav = ( output_path_wav = os.path.join(save_path, f"output_{time.strftime('%Y%m%d%H%M%S')}_{idx}.wav")
f"{base_path}/output_{time.strftime('%Y%m%d%H%M%S')}_{idx}.wav" else:
) output_path_wav = save_path
target_wav = target_wav.float() target_wav = target_wav.float()
print(target_wav) logger.info(f"Saving audio to {output_path_wav}")
torchaudio.save( torchaudio.save(
output_path_wav, target_wav, sample_rate=sample_rate, format=format output_path_wav, target_wav, sample_rate=sample_rate, format=format
) )