ltx2_audio_vae ¶
Native LTX-2 Audio VAE and Vocoder implementation for FastVideo.
Classes¶
fastvideo.models.audio.ltx2_audio_vae.AttentionType ¶
fastvideo.models.audio.ltx2_audio_vae.AttnBlock ¶
Bases: Module
Vanilla self-attention block for 2D features.
Source code in fastvideo/models/audio/ltx2_audio_vae.py
fastvideo.models.audio.ltx2_audio_vae.AudioDecoder ¶
AudioDecoder(*, ch: int, out_ch: int, ch_mult: Tuple[int, ...] = (1, 2, 4, 8), num_res_blocks: int, attn_resolutions: Set[int], resolution: int, z_channels: int, norm_type: NormType = GROUP, causality_axis: CausalityAxis = WIDTH, dropout: float = 0.0, mid_block_add_attention: bool = True, sample_rate: int = 16000, mel_hop_length: int = 160, is_causal: bool = True, mel_bins: int | None = None)
Bases: Module
Symmetric decoder that reconstructs audio spectrograms from latent features.
Source code in fastvideo/models/audio/ltx2_audio_vae.py
1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 | |
Methods:¶
fastvideo.models.audio.ltx2_audio_vae.AudioDecoder.forward ¶
Decode latent features back to audio spectrograms. Args: sample: Encoded latent representation of shape (batch, channels, frames, mel_bins) Returns: Reconstructed audio spectrogram of shape (batch, channels, time, frequency)
Source code in fastvideo/models/audio/ltx2_audio_vae.py
fastvideo.models.audio.ltx2_audio_vae.AudioDecoderConfigurator ¶
Factory for AudioDecoder from checkpoint config.
fastvideo.models.audio.ltx2_audio_vae.AudioEncoder ¶
AudioEncoder(*, ch: int, ch_mult: Tuple[int, ...] = (1, 2, 4, 8), num_res_blocks: int, attn_resolutions: Set[int], dropout: float = 0.0, resamp_with_conv: bool = True, in_channels: int, resolution: int, z_channels: int, double_z: bool = True, attn_type: AttentionType = VANILLA, mid_block_add_attention: bool = True, norm_type: NormType = GROUP, causality_axis: CausalityAxis = WIDTH, sample_rate: int = 16000, mel_hop_length: int = 160, n_fft: int = 1024, is_causal: bool = True, mel_bins: int = 64, **_ignore_kwargs)
Bases: Module
Encoder that compresses audio spectrograms into latent representations.
Source code in fastvideo/models/audio/ltx2_audio_vae.py
980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 | |
Methods:¶
fastvideo.models.audio.ltx2_audio_vae.AudioEncoder.forward ¶
Encode audio spectrogram into latent representations. Args: spectrogram: Input spectrogram of shape (batch, channels, time, frequency) Returns: Encoded latent representation of shape (batch, channels, frames, mel_bins)
Source code in fastvideo/models/audio/ltx2_audio_vae.py
fastvideo.models.audio.ltx2_audio_vae.AudioEncoderConfigurator ¶
Factory for AudioEncoder from checkpoint config.
fastvideo.models.audio.ltx2_audio_vae.AudioLatentShape ¶
fastvideo.models.audio.ltx2_audio_vae.AudioPatchifier ¶
AudioPatchifier(patch_size: int = 1, sample_rate: int = 16000, hop_length: int = 160, audio_latent_downsample_factor: int = 4, is_causal: bool = True)
Simple patchifier for audio latents.
Source code in fastvideo/models/audio/ltx2_audio_vae.py
Methods:¶
fastvideo.models.audio.ltx2_audio_vae.AudioPatchifier.patchify ¶
Flatten audio latent tensor along time: (B, C, T, F) -> (B, T, C*F).
fastvideo.models.audio.ltx2_audio_vae.AudioPatchifier.unpatchify ¶
unpatchify(audio_latents: Tensor, output_shape: AudioLatentShape) -> Tensor
Restore (B, C, T, F) from flattened patches: (B, T, C*F) -> (B, C, T, F).
Source code in fastvideo/models/audio/ltx2_audio_vae.py
fastvideo.models.audio.ltx2_audio_vae.CausalConv2d ¶
CausalConv2d(in_channels: int, out_channels: int, kernel_size: int | Tuple[int, int], stride: int = 1, dilation: int | Tuple[int, int] = 1, groups: int = 1, bias: bool = True, causality_axis: CausalityAxis = HEIGHT)
Bases: Module
A causal 2D convolution. Ensures output at time t only depends on inputs at time t and earlier.
Source code in fastvideo/models/audio/ltx2_audio_vae.py
fastvideo.models.audio.ltx2_audio_vae.CausalityAxis ¶
fastvideo.models.audio.ltx2_audio_vae.Downsample ¶
Downsample(in_channels: int, with_conv: bool, causality_axis: CausalityAxis = WIDTH)
Bases: Module
Downsampling layer with strided convolution or average pooling.
Source code in fastvideo/models/audio/ltx2_audio_vae.py
fastvideo.models.audio.ltx2_audio_vae.LTX2AudioDecoder ¶
fastvideo.models.audio.ltx2_audio_vae.LTX2AudioEncoder ¶
fastvideo.models.audio.ltx2_audio_vae.LTX2Vocoder ¶
fastvideo.models.audio.ltx2_audio_vae.NormType ¶
fastvideo.models.audio.ltx2_audio_vae.PerChannelStatistics ¶
PerChannelStatistics(latent_channels: int = 128)
Bases: Module
Per-channel statistics for normalizing and denormalizing the latent representation.
Source code in fastvideo/models/audio/ltx2_audio_vae.py
fastvideo.models.audio.ltx2_audio_vae.PixelNorm ¶
fastvideo.models.audio.ltx2_audio_vae.ResBlock1 ¶
Bases: Module
1D ResBlock for vocoder with dilated convolutions.
Source code in fastvideo/models/audio/ltx2_audio_vae.py
fastvideo.models.audio.ltx2_audio_vae.ResBlock2 ¶
Bases: Module
1D ResBlock for vocoder (simpler version).
Source code in fastvideo/models/audio/ltx2_audio_vae.py
fastvideo.models.audio.ltx2_audio_vae.ResnetBlock ¶
ResnetBlock(*, in_channels: int, out_channels: int | None = None, conv_shortcut: bool = False, dropout: float = 0.0, temb_channels: int = 512, norm_type: NormType = GROUP, causality_axis: CausalityAxis = HEIGHT)
Bases: Module
2D ResNet block for audio VAE.
Source code in fastvideo/models/audio/ltx2_audio_vae.py
fastvideo.models.audio.ltx2_audio_vae.Upsample ¶
Upsample(in_channels: int, with_conv: bool, causality_axis: CausalityAxis = HEIGHT)
Bases: Module
Upsampling layer with nearest-neighbor interpolation and optional convolution.
Source code in fastvideo/models/audio/ltx2_audio_vae.py
fastvideo.models.audio.ltx2_audio_vae.Vocoder ¶
Vocoder(resblock_kernel_sizes: List[int] | None = None, upsample_rates: List[int] | None = None, upsample_kernel_sizes: List[int] | None = None, resblock_dilation_sizes: List[List[int]] | None = None, upsample_initial_channel: int = 1024, stereo: bool = True, resblock: str = '1', output_sample_rate: int = 24000, activation: str = 'snake', use_tanh_at_final: bool = True, apply_final_activation: bool = True, use_bias_at_final: bool = True)
Bases: Module
Vocoder model for synthesizing audio from Mel spectrograms.
Source code in fastvideo/models/audio/ltx2_audio_vae.py
1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 | |
Methods:¶
fastvideo.models.audio.ltx2_audio_vae.Vocoder.forward ¶
Forward pass of the vocoder. Args: x: Input Mel spectrogram tensor of shape (batch, channels, time, mel_bins) Returns: Audio waveform tensor of shape (batch, out_channels, audio_length)
Source code in fastvideo/models/audio/ltx2_audio_vae.py
fastvideo.models.audio.ltx2_audio_vae.VocoderConfigurator ¶
Factory for Vocoder from checkpoint config.
Functions:¶
fastvideo.models.audio.ltx2_audio_vae.build_downsampling_path ¶
build_downsampling_path(*, ch: int, ch_mult: Tuple[int, ...], num_resolutions: int, num_res_blocks: int, resolution: int, temb_channels: int, dropout: float, norm_type: NormType, causality_axis: CausalityAxis, attn_type: AttentionType, attn_resolutions: Set[int], resamp_with_conv: bool) -> Tuple[ModuleList, int]
Build the downsampling path with residual blocks, attention, and downsampling layers.
Source code in fastvideo/models/audio/ltx2_audio_vae.py
fastvideo.models.audio.ltx2_audio_vae.build_mid_block ¶
build_mid_block(channels: int, temb_channels: int, dropout: float, norm_type: NormType, causality_axis: CausalityAxis, attn_type: AttentionType, add_attention: bool) -> Module
Build the middle block with two ResNet blocks and optional attention.
Source code in fastvideo/models/audio/ltx2_audio_vae.py
fastvideo.models.audio.ltx2_audio_vae.build_normalization_layer ¶
build_normalization_layer(in_channels: int, *, num_groups: int = 32, normtype: NormType = GROUP) -> Module
Create a normalization layer based on the normalization type.
Source code in fastvideo/models/audio/ltx2_audio_vae.py
fastvideo.models.audio.ltx2_audio_vae.build_upsampling_path ¶
build_upsampling_path(*, ch: int, ch_mult: Tuple[int, ...], num_resolutions: int, num_res_blocks: int, resolution: int, temb_channels: int, dropout: float, norm_type: NormType, causality_axis: CausalityAxis, attn_type: AttentionType, attn_resolutions: Set[int], resamp_with_conv: bool, initial_block_channels: int) -> Tuple[ModuleList, int]
Build the upsampling path with residual blocks, attention, and upsampling layers.
Source code in fastvideo/models/audio/ltx2_audio_vae.py
fastvideo.models.audio.ltx2_audio_vae.decode_audio ¶
decode_audio(latent: Tensor, audio_decoder: AudioDecoder, vocoder: Vocoder) -> Tensor
Decode an audio latent representation using the provided audio decoder and vocoder.
Source code in fastvideo/models/audio/ltx2_audio_vae.py
fastvideo.models.audio.ltx2_audio_vae.make_attn ¶
make_attn(in_channels: int, attn_type: AttentionType = VANILLA, norm_type: NormType = GROUP) -> Module
Factory function for attention blocks.
Source code in fastvideo/models/audio/ltx2_audio_vae.py
fastvideo.models.audio.ltx2_audio_vae.make_conv2d ¶
make_conv2d(in_channels: int, out_channels: int, kernel_size: int | Tuple[int, int], stride: int = 1, padding: Tuple[int, int, int, int] | None = None, dilation: int = 1, groups: int = 1, bias: bool = True, causality_axis: CausalityAxis | None = None) -> Module
Create a 2D convolution layer that can be either causal or non-causal.
Source code in fastvideo/models/audio/ltx2_audio_vae.py
fastvideo.models.audio.ltx2_audio_vae.run_mid_block ¶
Run features through the middle block.