fix: fall back to soundfile for torchaudio.save when torchcodec unavailable
Same torchcodec/FFmpeg issue as the load path, now on the eval sample save. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -508,7 +508,11 @@ class SelvaLoraTrainer:
|
|||||||
dataset, seq_cfg, device, dtype)
|
dataset, seq_cfg, device, dtype)
|
||||||
if wav is not None:
|
if wav is not None:
|
||||||
wav_path = output_dir / f"sample_step{step:05d}.wav"
|
wav_path = output_dir / f"sample_step{step:05d}.wav"
|
||||||
|
try:
|
||||||
torchaudio.save(str(wav_path), wav, sr)
|
torchaudio.save(str(wav_path), wav, sr)
|
||||||
|
except RuntimeError:
|
||||||
|
import soundfile as sf
|
||||||
|
sf.write(str(wav_path), wav.squeeze(0).numpy(), sr)
|
||||||
print(f"[LoRA Trainer] Sample saved: {wav_path}", flush=True)
|
print(f"[LoRA Trainer] Sample saved: {wav_path}", flush=True)
|
||||||
|
|
||||||
pbar_train.update(1)
|
pbar_train.update(1)
|
||||||
|
|||||||
Reference in New Issue
Block a user