Normalize decoded Foley audio waveform shape
Browse files- ltx_foley_v2a/nodes.py +14 -2
ltx_foley_v2a/nodes.py
CHANGED
|
@@ -151,9 +151,21 @@ class LTXFoleyAudioVAEDecode:
|
|
| 151 |
if audio_latent.is_nested:
|
| 152 |
audio_latent = audio_latent.unbind()[-1]
|
| 153 |
|
| 154 |
-
audio = audio_vae.decode(audio_latent).
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 155 |
output_sample_rate = _audio_vae_model(audio_vae).output_sample_rate
|
| 156 |
-
return ({"waveform":
|
| 157 |
|
| 158 |
|
| 159 |
NODE_CLASS_MAPPINGS = {
|
|
|
|
| 151 |
if audio_latent.is_nested:
|
| 152 |
audio_latent = audio_latent.unbind()[-1]
|
| 153 |
|
| 154 |
+
audio = audio_vae.decode(audio_latent).to(audio_latent.device)
|
| 155 |
+
if audio.ndim == 2:
|
| 156 |
+
audio = audio.unsqueeze(1)
|
| 157 |
+
elif audio.ndim != 3:
|
| 158 |
+
raise ValueError(f"Expected decoded audio to have 2 or 3 dimensions, got shape {tuple(audio.shape)}")
|
| 159 |
+
|
| 160 |
+
if audio.shape[1] in (1, 2, 6):
|
| 161 |
+
waveform = audio
|
| 162 |
+
elif audio.shape[2] in (1, 2, 6):
|
| 163 |
+
waveform = audio.movedim(-1, 1)
|
| 164 |
+
else:
|
| 165 |
+
raise ValueError(f"Could not infer audio channel dimension from decoded shape {tuple(audio.shape)}")
|
| 166 |
+
|
| 167 |
output_sample_rate = _audio_vae_model(audio_vae).output_sample_rate
|
| 168 |
+
return ({"waveform": waveform, "sample_rate": int(output_sample_rate)},)
|
| 169 |
|
| 170 |
|
| 171 |
NODE_CLASS_MAPPINGS = {
|