"""ECAPA-TDNN Speaker Encoder configuration. Standalone configuration for the ECAPA-TDNN speaker encoder extracted from Qwen3-TTS. Compatible with the HuggingFace transformers AutoModel API. """ from transformers import PretrainedConfig class EcapaTdnnSpeakerEncoderConfig(PretrainedConfig): r""" Configuration class for the ECAPA-TDNN speaker encoder. This model produces fixed-dimensional speaker embeddings (x-vectors) from log-mel spectrograms. The architecture follows the ECAPA-TDNN paper: "Emphasized Channel Attention, Propagation and Aggregation in TDNN Based Speaker Verification" (https://arxiv.org/abs/2005.07143). Args: mel_dim (`int`, *optional*, defaults to 128): Number of mel-frequency bins in the input spectrogram. enc_dim (`int`, *optional*, defaults to 1024): Dimension of the output speaker embedding. enc_channels (`list[int]`, *optional*, defaults to `[512, 512, 512, 512, 1536]`): Output channels for each encoder layer. The first is the initial TDNN layer, the middle ones are SE-Res2Net blocks, and the last is the multi-layer feature aggregation layer. enc_kernel_sizes (`list[int]`, *optional*, defaults to `[5, 3, 3, 3, 1]`): Kernel sizes for each encoder layer. enc_dilations (`list[int]`, *optional*, defaults to `[1, 2, 3, 4, 1]`): Dilation rates for each encoder layer. enc_attention_channels (`int`, *optional*, defaults to 128): Number of attention channels in the attentive statistics pooling layer. enc_res2net_scale (`int`, *optional*, defaults to 8): Scale factor for the Res2Net blocks. enc_se_channels (`int`, *optional*, defaults to 128): Number of channels in the squeeze-excitation bottleneck. sample_rate (`int`, *optional*, defaults to 24000): Expected audio sample rate in Hz. """ model_type = "ecapa_tdnn_speaker_encoder" def __init__( self, mel_dim=128, enc_dim=1024, enc_channels=None, enc_kernel_sizes=None, enc_dilations=None, enc_attention_channels=128, enc_res2net_scale=8, enc_se_channels=128, sample_rate=24000, **kwargs, ): super().__init__(**kwargs) self.mel_dim = mel_dim self.enc_dim = enc_dim self.enc_channels = enc_channels if enc_channels is not None else [512, 512, 512, 512, 1536] self.enc_kernel_sizes = enc_kernel_sizes if enc_kernel_sizes is not None else [5, 3, 3, 3, 1] self.enc_dilations = enc_dilations if enc_dilations is not None else [1, 2, 3, 4, 1] self.enc_attention_channels = enc_attention_channels self.enc_res2net_scale = enc_res2net_scale self.enc_se_channels = enc_se_channels self.sample_rate = sample_rate