# Copyright 2026 The emotion2vec Authors, The FunASR Authors, TICTAP-11 and b-re-w. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """Configuration class for emotion2vec.""" from huggingface_hub.dataclasses import strict from transformers import Data2VecAudioConfig __all__ = ["Emotion2vecConfig"] @strict class Emotion2vecConfig(Data2VecAudioConfig): r""" This is the configuration class to store the configuration of an [`Emotion2vecModel`]. emotion2vec is the data2vec 2.0 audio encoder, so the configuration is [`~transformers.Data2VecAudioConfig`], whose defaults are already the sizes of `emotion2vec_base` (`config.yaml` of `iic/emotion2vec_base_finetuned`, revision `v2.0.4`): seven convolutions without bias, a five layer positional convolution of width 19 in 16 groups, and twelve post norm transformer layers of width 768 with 12 heads. The four layers fairseq calls the prenet (`prenet_depth`) and the eight after them have the same form and run one after the other, so they are one stack of `num_hidden_layers`. It takes every argument of [`~transformers.Data2VecAudioConfig`], with the fine-tuning values of `activation_dropout` (0.0) and `layerdrop` (0.05) as defaults, and: Args: num_extra_tokens (`int`, *optional*, defaults to 10): Learned tokens put in front of the frames before the transformer and dropped from its output. alibi_scale (`float`, *optional*, defaults to 1.0): Initial value of the learned per head scale of the ALiBi attention bias. normalize_input (`bool`, *optional*, defaults to `True`): Whether the model layer normalizes each waveform over its samples ($\epsilon=10^{-5}$, no affine), as `Emotion2vec.inference` of FunASR does when `normalize` is set. num_prenet_layers (`int`, *optional*, defaults to 4): How many of the `num_hidden_layers` layers the original checkpoint stores inside its audio encoder. Read only by the weight conversion. """ model_type = "emotion2vec" activation_dropout: float | int = 0.0 layerdrop: float | int = 0.05 num_extra_tokens: int = 10 alibi_scale: float = 1.0 normalize_input: bool = True num_prenet_layers: int = 4