§
    \�’jlJ  ã                   ó¾  — d Z ddlZddlZddlmZ ddlmZ ddlmZm	Z	 ddl
mZ ddlmZmZmZmZmZmZ d	d
lmZ d	dlmZ d	dlmZmZmZmZ  ej        e¦  «        Z eg d¢¦  «        Z ej         e¦  «          eee¦  «        Z!de"fd„Z#	 	 	 	 	 	 dde"ej$        z  de"ej$        z  dz  de%de&e"e"f         dz  de%e"z  dz  de"dz  de%fd„Z' G d„ d¦  «        Z(ddgZ)dS )zAutoFeatureExtractor class.é    N)ÚOrderedDicté   )ÚPreTrainedConfig)Úget_class_from_dynamic_moduleÚresolve_trust_remote_code)ÚFeatureExtractionMixin)ÚCONFIG_NAMEÚFEATURE_EXTRACTOR_NAMEÚPROCESSOR_NAMEÚcached_fileÚloggingÚsafe_load_json_fileé   )Ú_LazyAutoMapping)ÚFEATURE_EXTRACTOR_MAPPING_NAMES)ÚCONFIG_MAPPING_NAMESÚ
AutoConfigÚmodel_type_to_module_nameÚ!replace_list_option_in_docstrings)#)Úaudioflamingo3ÚWhisperFeatureExtractor)ÚcsmÚEncodecFeatureExtractor)zdata2vec-audioÚWav2Vec2FeatureExtractor)Úglmasrr   )Úgranite_speech_plusÚGraniteSpeechFeatureExtractor)Úhiggs_audio_v2_tokenizerÚDacFeatureExtractor)Úhubertr   )Úinkling_mm_modelÚInklingFeatureExtractor)Úlasr_ctcÚLasrFeatureExtractor)Úlasr_encoderr$   )Úmimir   )Ú	moonshiner   )Úmoshir   )Úmusicgenr   )Únemotron3_5_asrÚ$NemotronAsrStreamingFeatureExtractor)Únemotron_asr_streaming_encoderr+   )Úparakeet_ctcÚParakeetFeatureExtractor)Úparakeet_encoderr.   )Úparakeet_rnntr.   )Úparakeet_tdtr.   )Úpe_audio_videoÚPeAudioFeatureExtractor)Úqwen2_5_omnir   )Úqwen2_audior   )Úqwen3_omni_moer   )Úseamless_m4t_v2ÚSeamlessM4TFeatureExtractor)Úsewr   )zsew-dr   )Ú	unispeechr   )zunispeech-satr   )Úvibevoice_asrÚ*VibeVoiceAcousticTokenizerFeatureExtractor)Úvoxtralr   )zwav2vec2-bertr   )zwav2vec2-conformerr   )Úwavlmr   )Úxcodecr   Ú
class_namec                 ó°  — t          j        ¦   «         D ]S\  }}| |v rJt          |¦  «        }t          j        d|› �d¦  «        }	 t          || ¦  «        c S # t          $ r Y ŒOw xY wŒTt          j         	                    ¦   «         D ]}t          |dd ¦  «        | k    r|c S Œt          j        d¦  «        }t          || ¦  «        rt          || ¦  «        S d S )Nú.ztransformers.modelsÚ__name__Útransformers)r   Úitemsr   Ú	importlibÚimport_moduleÚgetattrÚAttributeErrorÚFEATURE_EXTRACTOR_MAPPINGÚ_extra_contentÚvaluesÚhasattr)r@   Úmodule_nameÚ
extractorsÚmoduleÚ	extractorÚmain_modules         ú^C:\Projects\DSCons\.venv\Lib\site-packages\transformers\models\auto\feature_extraction_auto.pyÚ!feature_extractor_class_from_namerT   Q   s  € Ý#BÔ#HÑ#JÔ#Jð ð Ñˆ�ZØ˜Ð#Ð#Ý3°KÑ@Ô@ˆKåÔ,Ð->°Ð->Ð->Ð@UÑVÔVˆFðÝ˜v zÑ2Ô2Ð2Ð2Ð2øÝ!ð ð ð Ø�ðøøøð $õ /Ô=×DÒDÑFÔFð ð ˆ	Ý�9˜j¨$Ñ/Ô/°:Ò=Ð=ØÐÐÐð >õ
 Ô)¨.Ñ9Ô9€KÝˆ{˜JÑ'Ô'ð 0Ý�{ JÑ/Ô/Ð/àˆ4s   ÁAÁ
A$Á#A$FÚpretrained_model_name_or_pathÚ	cache_dirÚforce_downloadÚproxiesÚtokenÚrevisionÚlocal_files_onlyc                 ó&  — t          | t          ||||||dd¬¦
  «
        }t          | t          ||||||dd¬¦
  «
        }	|	s|st                               d¦  «         i S d}
|�t          |¦  «        }d|v r|d         }
|	�|
€t          |	¦  «        }
|
pi S )a  
    Loads the feature extractor configuration from a pretrained model feature extractor configuration.

    Args:
        pretrained_model_name_or_path (`str` or `os.PathLike`):
            This can be either:

            - a string, the *model id* of a pretrained model configuration hosted inside a model repo on
              huggingface.co.
            - a path to a *directory* containing a configuration file saved using the
              [`~FeatureExtractionMixin.save_pretrained`] method, e.g., `./my_model_directory/`.

        cache_dir (`str` or `os.PathLike`, *optional*):
            Path to a directory in which a downloaded pretrained model configuration should be cached if the standard
            cache should not be used.
        force_download (`bool`, *optional*, defaults to `False`):
            Whether or not to force to (re-)download the configuration files and override the cached versions if they
            exist.
        proxies (`dict[str, str]`, *optional*):
            A dictionary of proxy servers to use by protocol or endpoint, e.g., `{'http': 'foo.bar:3128',
            'http://hostname': 'foo.bar:4012'}.` The proxies are used on each request.
        token (`str` or *bool*, *optional*):
            The token to use as HTTP bearer authorization for remote files. If `True`, will use the token generated
            when running `hf auth login` (stored in `~/.huggingface`).
        revision (`str`, *optional*, defaults to `"main"`):
            The specific model version to use. It can be a branch name, a tag name, or a commit id, since we use a
            git-based system for storing models and other artifacts on huggingface.co, so `revision` can be any
            identifier allowed by git.
        local_files_only (`bool`, *optional*, defaults to `False`):
            If `True`, will only try to load the feature extractor configuration from local files.

    <Tip>

    Passing `token=True` is required when you want to use a private model.

    </Tip>

    Returns:
        `Dict`: The configuration of the feature extractor.

    Examples:

    ```python
    # Download configuration from huggingface.co and cache.
    feature_extractor_config = get_feature_extractor_config("facebook/wav2vec2-base-960h")
    # This model does not have a feature extractor config so the result will be an empty dict.
    feature_extractor_config = get_feature_extractor_config("FacebookAI/xlm-roberta-base")

    # Save a pretrained feature extractor locally and you can reload its config
    from transformers import AutoFeatureExtractor

    feature_extractor = AutoFeatureExtractor.from_pretrained("facebook/wav2vec2-base-960h")
    feature_extractor.save_pretrained("feature-extractor-test")
    feature_extractor_config = get_feature_extractor_config("feature-extractor-test")
    ```F)	ÚfilenamerV   rW   rX   rY   rZ   r[   Ú _raise_exceptions_for_gated_repoÚ%_raise_exceptions_for_missing_entriesz:Could not locate the feature extractor configuration file.NÚfeature_extractor)r   r   r
   ÚloggerÚinfor   )rU   rV   rW   rX   rY   rZ   r[   ÚkwargsÚresolved_processor_fileÚresolved_feature_extractor_fileÚfeature_extractor_dictÚprocessor_dicts               rS   Úget_feature_extractor_configrh   i   sð   € õD *Ø%ÝØØ%ØØØØ)Ø).Ø.3ðñ ô Ðõ '2Ø%Ý'ØØ%ØØØØ)Ø).Ø.3ð'ñ 'ô 'Ð#ð +ð Ð3Jð Ý�ŠÐPÑQÔQÐQØˆ	ð
 "ÐØÐ*Ý,Ð-DÑEÔEˆØ .Ð0Ð0Ø%3Ð4GÔ%HÐ"à&Ð2Ð7MÐ7UÝ!4Ð5TÑ!UÔ!UÐØ!Ð' RÐ'ó    c                   óh   — e Zd ZdZd„ Ze ee¦  «        d„ ¦   «         ¦   «         Ze	dd„¦   «         Z
dS )ÚAutoFeatureExtractora+  
    This is a generic feature extractor class that will be instantiated as one of the feature extractor classes of the
    library when created with the [`AutoFeatureExtractor.from_pretrained`] class method.

    This class cannot be instantiated directly using `__init__()` (throws an error).
    c                 ó    — t          d¦  «        ‚)Nz‹AutoFeatureExtractor is designed to be instantiated using the `AutoFeatureExtractor.from_pretrained(pretrained_model_name_or_path)` method.)ÚOSError)Úselfs    rS   Ú__init__zAutoFeatureExtractor.__init__ß   s   € Ýðfñ
ô 
ð 	
ri   c                 óÞ  — |                      dd¦  «        }|                      dd¦  «        }d|d<   t          j        |fi |¤Ž\  }}|                     dd¦  «        }d}d|                     di ¦  «        v r|d         d         }|€b|€`t	          |t
          ¦  «        st          j        |fd|i|¤Ž}t          |dd¦  «        }t          |d¦  «        rd|j
        v r|j
        d         }|�t          |¦  «        }|du}	|dupt          |¦  «        t          v }
|
o4|pt          t          |¦  «                 j                             d	¦  «         }|	r5d
|v r|                     d
¦  «        d         }nd}t#          |||
|	|¦  «        }|	rJ|rH|sFt%          ||fi |¤Ž}|                      dd¦  «        }|                     ¦   «           |j        |fi |¤ŽS |� |j        |fi |¤ŽS t          |¦  «        t          v r(t          t          |¦  «                 } |j        |fi |¤ŽS t)          d|› dt*          › dt,          › dt,          › dd                     d„ t0          D ¦   «         ¦  «        › �
¦  «        ‚)aÂ  
        Instantiate one of the feature extractor classes of the library from a pretrained model vocabulary.

        The feature extractor class to instantiate is selected based on the `model_type` property of the config object
        (either passed as an argument or loaded from `pretrained_model_name_or_path` if possible), or when it's
        missing, by falling back to using pattern matching on `pretrained_model_name_or_path`:

        List options

        Params:
            pretrained_model_name_or_path (`str` or `os.PathLike`):
                This can be either:

                - a string, the *model id* of a pretrained feature_extractor hosted inside a model repo on
                  huggingface.co.
                - a path to a *directory* containing a feature extractor file saved using the
                  [`~feature_extraction_utils.FeatureExtractionMixin.save_pretrained`] method, e.g.,
                  `./my_model_directory/`.
                - a path to a saved feature extractor JSON *file*, e.g.,
                  `./my_model_directory/preprocessor_config.json`.
            cache_dir (`str` or `os.PathLike`, *optional*):
                Path to a directory in which a downloaded pretrained model feature extractor should be cached if the
                standard cache should not be used.
            force_download (`bool`, *optional*, defaults to `False`):
                Whether or not to force to (re-)download the feature extractor files and override the cached versions
                if they exist.
            proxies (`dict[str, str]`, *optional*):
                A dictionary of proxy servers to use by protocol or endpoint, e.g., `{'http': 'foo.bar:3128',
                'http://hostname': 'foo.bar:4012'}.` The proxies are used on each request.
            token (`str` or *bool*, *optional*):
                The token to use as HTTP bearer authorization for remote files. If `True`, will use the token generated
                when running `hf auth login` (stored in `~/.huggingface`).
            revision (`str`, *optional*, defaults to `"main"`):
                The specific model version to use. It can be a branch name, a tag name, or a commit id, since we use a
                git-based system for storing models and other artifacts on huggingface.co, so `revision` can be any
                identifier allowed by git.
            return_unused_kwargs (`bool`, *optional*, defaults to `False`):
                If `False`, then this function returns just the final feature extractor object. If `True`, then this
                functions returns a `Tuple(feature_extractor, unused_kwargs)` where *unused_kwargs* is a dictionary
                consisting of the key/value pairs whose keys are not feature extractor attributes: i.e., the part of
                `kwargs` which has not been used to update `feature_extractor` and is otherwise ignored.
            trust_remote_code (`bool`, *optional*, defaults to `False`):
                Whether or not to allow for custom models defined on the Hub in their own modeling files. This option
                should only be set to `True` for repositories you trust and in which you have read the code, as it will
                execute code present on the Hub on your local machine.
            kwargs (`dict[str, Any]`, *optional*):
                The values in kwargs of any keys which are feature extractor attributes will be used to override the
                loaded values. Behavior concerning key/value pairs whose keys are *not* feature extractor attributes is
                controlled by the `return_unused_kwargs` keyword parameter.

        <Tip>

        Passing `token=True` is required when you want to use a private model.

        </Tip>

        Examples:

        ```python
        >>> from transformers import AutoFeatureExtractor

        >>> # Download feature extractor from huggingface.co and cache.
        >>> feature_extractor = AutoFeatureExtractor.from_pretrained("facebook/wav2vec2-base-960h")

        >>> # If feature extractor files are in a directory (e.g. feature extractor was saved using *save_pretrained('./test/saved_model/')*)
        >>> # feature_extractor = AutoFeatureExtractor.from_pretrained("./test/saved_model/")
        ```ÚconfigNÚtrust_remote_codeTÚ
_from_autoÚfeature_extractor_typerk   Úauto_mapztransformers.z--r   Úcode_revisionz"Unrecognized feature extractor in z4. Should have a `feature_extractor_type` key in its z of z3, or one of the following `model_type` keys in its z: z, c              3   ó   K  — | ]}|V — Œd S )N© )Ú.0Úcs     rS   ú	<genexpr>z7AutoFeatureExtractor.from_pretrained.<locals>.<genexpr>b  s"   è è € Ð@lÐ@lÀqÀÐ@lÐ@lÐ@lÐ@lÐ@lÐ@lri   )Úpopr   Úget_feature_extractor_dictÚgetÚ
isinstancer   r   Úfrom_pretrainedrH   rM   ru   rT   ÚtyperJ   Ú
__module__Ú
startswithÚsplitr   r   Úregister_for_auto_classÚ
ValueErrorr
   r	   Újoinr   )ÚclsrU   rc   rq   rr   Úconfig_dictÚ_Úfeature_extractor_classÚfeature_extractor_auto_mapÚhas_remote_codeÚhas_local_codeÚexplicit_local_codeÚupstream_repos                rS   r€   z$AutoFeatureExtractor.from_pretrainedå   sR  € ðL —’˜H dÑ+Ô+ˆØ"ŸJšJÐ':¸DÑAÔAÐØ#ˆˆ|Ñå/ÔJÐKhÐsÐsÐlrÐsÐs‰ˆ�QØ"-§/¢/Ð2JÈDÑ"QÔ"QÐØ%)Ð"Ø! [§_¢_°ZÀÑ%DÔ%DÐDÐDØ)4°ZÔ)@ÐAWÔ)XÐ&ð #Ð*Ð/IÐ/QÝ˜fÕ&6Ñ7Ô7ð Ý#Ô3Ø1ðð ØEVðØZ`ðð �õ '.¨fÐ6NÐPTÑ&UÔ&UÐ#Ý�v˜zÑ*Ô*ð UÐ/EÈÌÐ/XÐ/XØ-3¬_Ð=SÔ-TÐ*à"Ð.Ý&GÐH_Ñ&`Ô&`Ð#à4¸DÐ@ˆØ0¸Ð<ÐiÅÀVÁÄÕPiÐ@iˆØ,ð 1Ø#ÐNÕ'@ÅÀfÁÄÔ'NÜ
—Z’Z Ñ0Ô0ð21Ðð ð 	ØÐ1Ð1Ð1Ø :× @Ò @ÀÑ FÔ FÀqÔ I��à $�Ý 9Ø!Ð#@À.ÐRaÐcpñ!ô !Ðð ð 	dÐ0ð 	dÐ9Lð 	dÝ&CØ*Ð,Ið'ð 'ØMSð'ð 'Ð#ð —
’
˜?¨DÑ1Ô1ˆAØ#×;Ò;Ñ=Ô=Ð=Ø:Ð*Ô:Ð;XÐcÐcÐ\bÐcÐcÐcØ$Ð0Ø:Ð*Ô:Ð;XÐcÐcÐ\bÐcÐcÐcå�&‰\Œ\Õ6Ð6Ð6Ý&?ÅÀVÁÄÔ&MÐ#Ø:Ð*Ô:Ð;XÐcÐcÐ\bÐcÐcÐcåðoÐ1Nð oð oÝ3Iðoð oÝOZðoð oå(3ðoð oà7;·y²yÐ@lÐ@lÕLkÐ@lÑ@lÔ@lÑ7lÔ7lðoð oñ
ô 
ð 	
ri   Fc                 ó@   — t                                | ||¬¦  «         dS )a0  
        Register a new feature extractor for this class.

        Args:
            config_class ([`PreTrainedConfig`]):
                The configuration corresponding to the model to register.
            feature_extractor_class ([`FeatureExtractorMixin`]): The feature extractor to register.
        )Úexist_okN)rJ   Úregister)Úconfig_classr‹   r’   s      rS   r“   zAutoFeatureExtractor.registere  s'   € õ 	"×*Ò*¨<Ð9PÐ[cÐ*ÑdÔdÐdÐdÐdri   N)F)rC   r‚   Ú__qualname__Ú__doc__ro   Úclassmethodr   r   r€   Ústaticmethodr“   rx   ri   rS   rk   rk   ×   sŠ   € € € € € ðð ð
ð 
ð 
ð Ø&Ð&Ð'FÑGÔGð|
ð |
ñ HÔGñ „[ð|
ð| ð	eð 	eð 	eñ „\ð	eð 	eð 	eri   rk   rJ   )NFNNNF)*r–   rF   ÚosÚcollectionsr   Úconfiguration_utilsr   Údynamic_module_utilsr   r   Úfeature_extraction_utilsr   Úutilsr	   r
   r   r   r   r   Úauto_factoryr   Úauto_mappingsr   Úconfiguration_autor   r   r   r   Ú
get_loggerrC   ra   Ú'MISSING_FEATURE_EXTRACTOR_MAPPING_NAMESÚupdaterJ   ÚstrrT   ÚPathLikeÚboolÚdictrh   rk   Ú__all__rx   ri   rS   ú<module>rª      sr  ðð "Ð !à Ð Ð Ð Ø 	€	€	€	Ø #Ð #Ð #Ð #Ð #Ð #ð 4Ð 3Ð 3Ð 3Ð 3Ð 3Ø \Ð \Ð \Ð \Ð \Ð \Ð \Ð \Ø >Ð >Ð >Ð >Ð >Ð >Ø sÐ sÐ sÐ sÐ sÐ sÐ sÐ sÐ sÐ sÐ sÐ sÐ sÐ sÐ sÐ sØ *Ð *Ð *Ð *Ð *Ð *Ø :Ð :Ð :Ð :Ð :Ð :ðð ð ð ð ð ð ð ð ð ð ð ð 
ˆÔ	˜HÑ	%Ô	%€à*5¨+ð$ð $ð $ñ&+ô &+Ð 'ðP 'Ð Ô &Ð'NÑ OÔ OÐ OØ,Ð,Ð-AÐCbÑcÔcÐ ð°#ð ð ð ð ð4 +/Ø Ø%)Ø#ØØ"ðk(ð k(Ø#&¨¬Ñ#4ðk(à�R”[Ñ  4Ñ'ðk(ð ðk(ð �#�s�(Œ^˜dÑ"ð	k(ð
 �#‰:˜Ñðk(ð �D‰jðk(ð ðk(ð k(ð k(ð k(ð\Xeð Xeð Xeð Xeð Xeñ Xeô Xeð Xeðv 'Ð(>Ð
?€€€ri   