ChuxiJ commited on
Commit
140aee6
·
1 Parent(s): c9570f3

feat: save audio add soundfile fallback

Browse files
Files changed (1) hide show
  1. acestep/audio_utils.py +9 -2
acestep/audio_utils.py CHANGED
@@ -118,8 +118,15 @@ class AudioSaver:
118
  return str(output_path)
119
 
120
  except Exception as e:
121
- logger.error(f"[AudioSaver] Failed to save audio: {e}")
122
- raise
 
 
 
 
 
 
 
123
 
124
  def convert_audio(
125
  self,
 
118
  return str(output_path)
119
 
120
  except Exception as e:
121
+ try:
122
+ import soundfile as sf
123
+ audio_np = audio_tensor.transpose(0, 1).numpy() # -> [samples, channels]
124
+ sf.write(str(output_path), audio_np, sample_rate, format=format.upper())
125
+ logger.debug(f"[AudioSaver] Fallback soundfile Saved audio to {output_path} ({format}, {sample_rate}Hz)")
126
+ return str(output_path)
127
+ except Exception as e:
128
+ logger.error(f"[AudioSaver] Failed to save audio: {e}")
129
+ raise
130
 
131
  def convert_audio(
132
  self,