# 🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨 # This file was automatically generated from src/transformers/models/vibevoice_asr/modular_vibevoice_asr.py. # Do NOT edit this file manually as any edits will be overwritten by the generation of # the file from the modular. If any change should be done, please apply the change to the # modular_vibevoice_asr.py file directly. One of our CI enforces this. # 🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨 # Copyright 2026 Microsoft and the HuggingFace Inc. team. 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. import math from huggingface_hub.dataclasses import strict from ...configuration_utils import PreTrainedConfig from ...utils import auto_docstring from ..auto import CONFIG_MAPPING, AutoConfig @auto_docstring(checkpoint="microsoft/VibeVoice-ASR-HF") @strict class VibeVoiceAsrConfig(PreTrainedConfig): r""" acoustic_tokenizer_encoder_config (`Union[VibeVoiceAcousticTokenizerConfig, dict]`, *optional*): The config object or dictionary of the acoustic tokenizer. This tokenizer extracts acoustic features from audio. semantic_tokenizer_encoder_config (`Union[VibeVoiceAcousticTokenizerConfig, dict]`, *optional*): The config object or dictionary of the semantic tokenizer. This tokenizer extracts semantic features from audio. audio_bos_token_id (`int`, *optional*, defaults to 151646): The audio begin-of-sequence token index. audio_eos_token_id (`int`, *optional*, defaults to 151647): The audio end-of-sequence token index. acoustic_tokenizer_chunk_size (`int`, *optional*, defaults to 1440000): The chunk size (in number of samples) to use when tokenizer audio inputs. Default corresponds to 60 seconds at 24kHz. Example: ```python >>> from transformers import VibeVoiceAsrForConditionalGeneration, VibeVoiceAsrConfig, VibeVoiceAcousticTokenizerEncoderConfig, Qwen2Config >>> # Initializing VibeVoice acoustic and semantic encoder configs >>> acoustic_config = VibeVoiceAcousticTokenizerEncoderConfig() >>> semantic_config = VibeVoiceAcousticTokenizerEncoderConfig(hidden_size=128) >>> # Initializing a Qwen2 config >>> text_config = Qwen2Config() >>> # Initializing a VibeVoice ASR configuration >>> configuration = VibeVoiceAsrConfig(acoustic_config, semantic_config, text_config) >>> # Initializing a model from the vibevoice_asr style configuration >>> model = VibeVoiceAsrForConditionalGeneration(configuration) >>> # Accessing the model configuration >>> configuration = model.config ```""" model_type = "vibevoice_asr" sub_configs = { "acoustic_tokenizer_encoder_config": AutoConfig, "semantic_tokenizer_encoder_config": AutoConfig, "text_config": AutoConfig, } acoustic_tokenizer_encoder_config: dict | PreTrainedConfig | None = None semantic_tokenizer_encoder_config: dict | PreTrainedConfig | None = None text_config: dict | PreTrainedConfig | None = None audio_token_id: int = 151648 audio_bos_token_id: int = 151646 audio_eos_token_id: int = 151647 acoustic_tokenizer_chunk_size: int = 1440000 def __post_init__(self, **kwargs): if isinstance(self.acoustic_tokenizer_encoder_config, dict): self.acoustic_tokenizer_encoder_config["model_type"] = self.acoustic_tokenizer_encoder_config.get( "model_type", "vibevoice_acoustic_tokenizer_encoder" ) self.acoustic_tokenizer_encoder_config = CONFIG_MAPPING[ self.acoustic_tokenizer_encoder_config["model_type"] ](**self.acoustic_tokenizer_encoder_config) elif self.acoustic_tokenizer_encoder_config is None: self.acoustic_tokenizer_encoder_config = CONFIG_MAPPING["vibevoice_acoustic_tokenizer_encoder"]() if isinstance(self.semantic_tokenizer_encoder_config, dict): self.semantic_tokenizer_encoder_config["model_type"] = self.semantic_tokenizer_encoder_config.get( "model_type", "vibevoice_acoustic_tokenizer_encoder" ) self.semantic_tokenizer_encoder_config = CONFIG_MAPPING[ self.semantic_tokenizer_encoder_config["model_type"] ](**self.semantic_tokenizer_encoder_config) elif self.semantic_tokenizer_encoder_config is None: self.semantic_tokenizer_encoder_config = CONFIG_MAPPING["vibevoice_acoustic_tokenizer_encoder"]( hidden_size=128 ) if isinstance(self.text_config, dict): self.text_config["model_type"] = self.text_config.get("model_type", "qwen2") self.text_config = CONFIG_MAPPING[self.text_config["model_type"]](**self.text_config) elif self.text_config is None: self.text_config = CONFIG_MAPPING["qwen2"]() super().__post_init__(**kwargs) def validate_architecture(self): """Part of `@strict`-powered validation. Validates the architecture of the config.""" hop_length = self.acoustic_tokenizer_encoder_config.hop_length if self.acoustic_tokenizer_chunk_size % hop_length != 0: raise ValueError( f"`acoustic_tokenizer_chunk_size` must be a multiple of hop length " f"({hop_length}), got {self.acoustic_tokenizer_chunk_size}." ) @property def max_position_embeddings(self) -> int: return math.ceil(self.acoustic_tokenizer_chunk_size / self.acoustic_tokenizer_encoder_config.hop_length) @max_position_embeddings.setter def max_position_embeddings(self, value: int): if value <= 0: raise ValueError(f"Attempted to set `max_position_embeddings` to {value}; you need a positive value!") hop_length = self.acoustic_tokenizer_encoder_config.hop_length self.acoustic_tokenizer_chunk_size = int(value) * hop_length __all__ = ["VibeVoiceAsrConfig"]