+
    œ°³j±<  ã                   ó¸   € R t ^ RIt^ RIt^ RIt^RIHt ^RIHt ^RI	H
t
 ^RIHtHt ^RIHt ^RIHt ]P$                  ! ]4      t] ! R R	]4      4       tR	.tR# )
z
Processor class for Bark
N)ÚBatchFeature)ÚProcessorMixin©ÚBatchEncoding)Úauto_docstringÚlogging)Úcached_file)ÚAutoTokenizerc                   ó  a a€ ] tR t^"t oR^R^R^/tRV 3R llt]RR l4       tRV3R lV 3R lllt]	V3R lR	 l4       t
RV3R
 lR lltRV3R lR llt]V3R lR l4       tRV3R lR llt]RV3R lR ll4       tRtVtV ;t# )ÚBarkProcessorÚsemantic_promptÚcoarse_promptÚfine_promptc                ó2   <€ \         SV `  V4       W n        R# )aò  
speaker_embeddings (`dict[dict[str]]`, *optional*):
    Optional nested speaker embeddings dictionary. The first level contains voice preset names (e.g
    `"en_speaker_4"`). The second level contains `"semantic_prompt"`, `"coarse_prompt"` and `"fine_prompt"`
    embeddings. The values correspond to the path of the corresponding `np.ndarray`. See
    [here](https://suno-ai.notion.site/8b8e8749ed514b0cbf3f699013548683?v=bc67cff786b04b50b3ceb756fd05f68c) for
    a list of `voice_preset_names`.
N)ÚsuperÚ__init__Úspeaker_embeddings)ÚselfÚ	tokenizerr   Ú	__class__s   &&&€Úi/home/luca/screen-checking/.venv/lib/python3.14/site-packages/transformers/models/bark/processing_bark.pyr   ÚBarkProcessor.__init__*   s   ø€ ô 	‰Ñ˜Ô#à"4Öó    c                ó‚  € VP                  R4      pVeè   \        VVVP                  RR4      VP                  RR4      VP                  RR4      VP                  RR4      VP                  RR4      VVP                  R	R4      RRRR
7      pVf:   \        P	                  R\
        P                  P                  W4       R24       RpM5\        V4      ;_uu_ 4       p\        P                  ! V4      pRRR4       MRpXe   RV9   d   WR&   \        P                  ! V3/ VB pV ! W†R7      #   + '       g   i     L?; i)ac  
Instantiate a Bark processor associated with a pretrained model.

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

        - a string, the *model id* of a pretrained [`BarkProcessor`] hosted inside a model repo on
          huggingface.co.
        - a path to a *directory* containing a processor saved using the [`~BarkProcessor.save_pretrained`]
          method, e.g., `./my_model_directory/`.
    speaker_embeddings_dict_path (`str`, *optional*, defaults to `"speaker_embeddings_path.json"`):
        The name of the `.json` file containing the speaker_embeddings dictionary located in
        `pretrained_model_name_or_path`. If `None`, no speaker_embeddings is loaded.
    **kwargs
        Additional keyword arguments passed along to both
        [`~tokenization_utils_base.PreTrainedTokenizer.from_pretrained`].
ÚtokenNÚ	subfolderÚ	cache_dirÚforce_downloadFÚproxiesÚlocal_files_onlyÚrevision©
r   r   r   r   r   r   r    Ú _raise_exceptions_for_gated_repoÚ%_raise_exceptions_for_missing_entriesÚ'_raise_exceptions_for_connection_errorsÚ`zã` does not exists
                    , no preloaded speaker embeddings will be used - Make sure to provide a correct path to the json
                    dictionary if wanted, otherwise set `speaker_embeddings_dict_path=None`.Úrepo_or_path)r   r   )Úgetr   ÚpopÚloggerÚwarningÚosÚpathÚjoinÚopenÚjsonÚloadr	   Úfrom_pretrained)	ÚclsÚ!pretrained_processor_name_or_pathÚspeaker_embeddings_dict_pathÚkwargsr   Úspeaker_embeddings_pathr   Úspeaker_embeddings_jsonr   s	   &&&,     r   r1   ÚBarkProcessor.from_pretrained7   s;  € ð, —
‘
˜7Ó#ˆØ'Ò3Ü&1Ø1Ø,Ø Ÿ*™* [°$Ó7Ø Ÿ*™* [°$Ó7Ø%Ÿz™zÐ*:¸EÓBØŸ
™
 9¨dÓ3Ø!'§¡Ð,>ÀÓ!FØØŸ™ J°Ó5Ø16Ø6;Ø8=ô'Ð#ð 'Ò.Ü—‘Øœ"Ÿ'™'Ÿ,™,Ð'HÓgÐhð i]ð `ôð
 &*Ñ"äÐ1×2Ô2Ð6MÜ)-¯ªÐ3JÓ)KÐ&÷ 3Ð2ð "&ÐàÒ)ØÐ!3Ô3Ø5V >Ñ2Ü!×1Ò1Ð2SÑ^ÐW]Ñ^ˆ	á˜YÔNÐN÷ 3×2ús   ÃD.Ä.D>	c                ó    <€ V ^8„  d   QhRS[ /# )é   Úpush_to_hub©Úbool)ÚformatÚ__classdict__s   "€r   Ú__annotate__ÚBarkProcessor.__annotate__q   s   ø€ ÷ 3Gñ 3Gñ
 ñ3Gr   c           	     óD  <€ V P                   Eel   \        P                  ! \        P                  P	                  WR4      RR7       / pWR&   \        P                  P	                  W4      pV P
                   F°  pV P                  V4      p	/ p
V P                   V,           F  p\        P                  P	                  Wx RV 24      pV P                  W|V4       \        P                  ! WÉV,          RR7       \        P                  P	                  W8 RV R	24      W«&   K�  	  W¦V&   K²  	  \        \        P                  P	                  W4      R
4      ;_uu_ 4       p\        P                  ! Wm4       RRR4       \        SV `8  ! W3/ VB  R#   + '       g   i     L#; i)aì  
Saves the attributes of this processor (tokenizer...) in the specified directory so that it can be reloaded
using the [`~BarkProcessor.from_pretrained`] method.

Args:
    save_directory (`str` or `os.PathLike`):
        Directory where the tokenizer files and the speaker embeddings will be saved (directory will be created
        if it does not exist).
    speaker_embeddings_dict_path (`str`, *optional*, defaults to `"speaker_embeddings_path.json"`):
        The name of the `.json` file that will contains the speaker_embeddings nested path dictionary, if it
        exists, and that will be located in `pretrained_model_name_or_path/speaker_embeddings_directory`.
    speaker_embeddings_directory (`str`, *optional*, defaults to `"speaker_embeddings/"`):
        The name of the folder in which the speaker_embeddings arrays will be saved.
    push_to_hub (`bool`, *optional*, defaults to `False`):
        Whether or not to push your model to the Hugging Face model hub after saving it. You can specify the
        repository you want to push to with `repo_id` (will default to the name of `save_directory` in your
        namespace).
    kwargs:
        Additional key word arguments passed along to the [`~utils.PushToHubMixin.push_to_hub`] method.
NÚv2T)Úexist_okr&   Ú_F)Úallow_picklez.npyÚw)r   r+   Úmakedirsr,   r-   Úavailable_voice_presetsÚ_load_voice_presetÚ_reject_path_traversalÚnpÚsaver.   r/   Údumpr   Úsave_pretrained)r   Úsave_directoryr4   Úspeaker_embeddings_directoryr;   r5   Úembeddings_dictÚembeddings_subdirÚ
prompt_keyÚvoice_presetÚtmp_dictÚkeyÚtarget_filepathÚfpr   s   &&&&&,        €r   rO   ÚBarkProcessor.save_pretrainedq   sT  ø€ ð8 ×"Ñ"Ó.Ü�KŠKœŸ™Ÿ™ ^ÐSWÓXÐcgÕhà ˆOà.<˜NÑ+ä "§¡§¡¨^Ó ZÐØ"×:Ô:�
Ø#×6Ñ6°zÓB�à�Ø×2Ñ2°:×>Ð>�CÜ&(§g¡g§l¡lÐ3DÈÐTUÐVYÐUZÐF[Ó&\�OØ×/Ñ/Ð0AÐT^Ô_Ü—G’G˜O¸#Õ->ÈUÕSÜ$&§G¡G§L¡LÐ1MÐQ]Ð]^Ð_bÐ^cÐcgÐOhÓ$i�H“Mñ	 ?ð /7 
Ó+ñ ;ô ”b—g‘g—l‘l >ÓPÐRU×VÔVÐZ\Ü—	’	˜/Ô.÷ Wô 	‰Ò ÑF¸vÔF÷ W×Vús   ÅFÆF	c                ó,   <€ V ^8„  d   QhRS[ RS[ RS[ /# )r:   Úbase_dirÚtarget_pathÚoffending_value©Ústr)r>   r?   s   "€r   r@   rA   §   s(   ø€ ÷ Pñ P©ð P¹3ð PÑQTñ Pr   c                ó  € \         P                  P                  V 4      p\         P                  P                  V4      p \         P                  P                  W4.4      V8H  pV'       g   \	        RV: 24      hR#   \         d    R p L(i ; i)FzInvalid voice preset path: N)r+   r,   ÚabspathÚ
commonpathÚ
ValueError)r\   r]   r^   ÚbaseÚtargetÚ	containeds   &&&   r   rK   Ú$BarkProcessor._reject_path_traversal¦   s|   € ô �w‰w�‰˜xÓ(ˆÜ—‘—‘ Ó-ˆð	ÜŸ™×*Ñ*¨D¨>Ó:¸dÑBˆI÷ ÜÐ:¸?Ñ:MÐNÓOÐOñ øô ô 	àŠIð	ús   Á #A< Á<BÂBc                ó.   <€ V ^8„  d   QhRS[ R,          /# ©r:   rU   Nr_   )r>   r?   s   "€r   r@   rA   ¹   s   ø€ ÷ &!ñ &!©s°T­zñ &!r   c                óP  € V P                   V,          p/ pVP                  R 4      pV P                   P                  RR4      pR EF\  pWs9  d   \        RV RV R24      hV P                  V\        P
                  P                  WcV,          4      W7,          4       \        V P                   P                  RR4      W7,          VP                  RR4      VP                  RR4      VP                  R	R
4      VP                  RR4      VP                  RR
4      VVP                  RR4      R
R
R
R7      pVfQ   \        R\        P
                  P                  V P                   P                  RR4      W7,          4       RV R24      h\        P                  ! V4      WG&   EK_  	  V# )r   r&   Ú/ú#Voice preset unrecognized, missing z% as a key in self.speaker_embeddings[z].r   Nr   r   Fr   r   r    r!   r%   z{` does not exists
                    , no preloaded voice preset will be used - Make sure to provide correct paths to the z 
                    embeddings.©r   r   r   )r   r'   rd   rK   r+   r,   r-   r   r(   rL   r0   )	r   rU   r5   Úvoice_preset_pathsÚvoice_preset_dictr   r&   rW   r,   s	   &&,      r   rJ   Ú BarkProcessor._load_voice_preset¹   s¡  € Ø!×4Ñ4°\ÕBÐàÐØ—
‘
˜7Ó#ˆØ×.Ñ.×2Ñ2°>À3ÓGˆÜFˆCØÔ,Ü Ø9¸#¸Ð>cÐdpÐcqÐqsÐtóð ð ×'Ñ'ØœbŸg™gŸl™l¨<ÈCÕ9PÓQÐSeÕSjôô Ø×'Ñ'×+Ñ+¨N¸CÓ@Ø"Õ'Ø Ÿ*™* [°$Ó7Ø Ÿ*™* [°$Ó7Ø%Ÿz™zÐ*:¸EÓBØŸ
™
 9¨dÓ3Ø!'§¡Ð,>ÀÓ!FØØŸ™ J°Ó5Ø16Ø6;Ø8=ôˆDð Š|Ü Øœ"Ÿ'™'Ÿ,™, t×'>Ñ'>×'BÑ'BÀ>ÐSVÓ'WÐYkÕYpÓqÐrð sjØjvÐiwð x ð#óð ô &(§W¢W¨T£]ÐÔ"ñ= Gð@ !Ð r   c                ó.   <€ V ^8„  d   QhRS[ R,          /# rj   )Údict)r>   r?   s   "€r   r@   rA   á   s   ø€ ÷ 	jñ 	j¹¸t½ñ 	jr   c           	     óœ  € R FÅ  pW!9  d   \        RV R24      h\        W,          \        P                  4      '       g,   \	        V R\        V P                  V,          4       R24      h\        W,          P                  4      V P                  V,          8w  g   Kœ  \        V R\        V P                  V,          4       R24      h	  R# )r   rm   z
 as a key.z voice preset must be a z
D ndarray.Nrn   )	rd   Ú
isinstancerL   ÚndarrayÚ	TypeErrorr`   Úpreset_shapeÚlenÚshape)r   rU   rW   s   && r   Ú_validate_voice_preset_dictÚ)BarkProcessor._validate_voice_preset_dictá   sµ   € ÛFˆCØÔ&Ü Ð#FÀsÀeÈ:Ð!VÓWÐWä˜lÕ/´·±×<Ò<Ü 3 %Ð'?ÄÀD×DUÑDUÐVYÕDZÓ@[Ð?\Ð\fÐ gÓhÐhä�<Õ$×*Ñ*Ó+¨t×/@Ñ/@ÀÕ/EÖEÜ  C 5Ð(@ÄÀT×EVÑEVÐWZÕE[ÓA\Ð@]Ð]gÐ!hÓiÐió Gr   c                ó    <€ V ^8„  d   QhRS[ /# ©r:   Úreturn)Úlist)r>   r?   s   "€r   r@   rA   í   s   ø€ ÷ ñ ©ñ r   c                óœ   € V P                   f   . # \        V P                   P                  4       4      pRV9   d   VP                  R4       V# )ze
Returns a list of available voice presets.

Returns:
    `list[str]`: A list of voice preset names.
r&   )r   r€   ÚkeysÚremove)r   Úvoice_presetss   & r   rI   Ú%BarkProcessor.available_voice_presetsì   sJ   € ð ×"Ñ"Ò*ØˆIä˜T×4Ñ4×9Ñ9Ó;Ó<ˆØ˜]Ô*Ø× Ñ  Ô0ØÐr   c                ó    <€ V ^8„  d   QhRS[ /# )r:   Úremove_unavailabler<   )r>   r?   s   "€r   r@   rA   ü   s   ø€ ÷ >ñ >¹Tñ >r   c                óv  € . pV P                   e†   V P                   F&  p V P                  V4      pT P                  T4       K(  	  V'       d&   \        P                  R\        V4       RV R24       V'       d   V F  pV P                   V K  	  R # R # R #   \         d    TP	                  T4        Kš  i ; i)NzThe following z' speaker embeddings are not available: zU If you would like to use them, please check the paths or try downloading them again.)	r   rI   rJ   rd   Úappendr{   r)   r*   ry   )r   r‡   Úunavailable_keysrU   rp   s   &&   r   Ú_verify_speaker_embeddingsÚ(BarkProcessor._verify_speaker_embeddingsü   sÉ   € àÐØ×"Ñ"Ò.Ø $× <Ô <�ðØ(,×(?Ñ(?ÀÓ(MÐ%ð
 ×0Ñ0Ð1BÖCñ !=÷  Ü—‘Ø$¤SÐ)9Ó%:Ð$;Ð;bÐcsÐbtð ukð kô÷
 "Û$4�LØ×/Ñ/°Ò=ó %5ñ "ñ! /øô "ô à$×+Ñ+¨LÔ9Úðús   ¡BÂB8Â7B8c                ó    <€ V ^8„  d   QhRS[ /# r~   r   )r>   r?   s   "€r   r@   rA     s   ø€ ÷ 7ñ 7ñ 
ñ7r   c                óò  € Ve©   \        V\        4      '       g“   \        V\        4      '       d1   V P                  e#   W P                  9   d   V P	                  V4      pML\        V\        4      '       d!   VP                  R4      '       g
   VR,           p\        P                  ! V4      pVe    V P                  ! V3/ VB  \        W#R7      pV P                  ! V3RVRRRVRVRVRV/VB p	Ve   W)R	&   V	# )
a©  
voice_preset (`str`, `dict[np.ndarray]`):
    The voice preset, i.e the speaker embeddings. It can either be a valid voice_preset name, e.g
    `"en_speaker_1"`, or directly a dictionary of `np.ndarray` embeddings for each submodel of `Bark`. Or
    it can be a valid file name of a local `.npz` single voice preset containing the keys
    `"semantic_prompt"`, `"coarse_prompt"` and `"fine_prompt"`.

Returns:
    [`BatchEncoding`]: A [`BatchEncoding`] object containing the output of the `tokenizer`.
    If a voice preset is provided, the returned object will include a `"history_prompt"` key
    containing a [`BatchFeature`], i.e the voice preset with the right tensors type.
z.npz)ÚdataÚtensor_typeÚreturn_tensorsÚpaddingÚ
max_lengthÚreturn_attention_maskÚreturn_token_type_idsÚadd_special_tokensÚhistory_prompt)ru   rs   r`   r   rJ   ÚendswithrL   r0   r{   r   r   )
r   ÚtextrU   r‘   r“   r–   r”   r•   r5   Úencoded_texts
   &&&&&&&&, r   Ú__call__ÚBarkProcessor.__call__  s  € ð0 Ò#¬J°|ÄT×,JÒ,Jä˜<¬×-Ò-Ø×+Ñ+Ò7Ø ×$;Ñ$;Ô;à#×6Ñ6°|ÓD‘ô ˜l¬C×0Ò0¸×9NÑ9NÈv×9VÒ9VØ#/°&Õ#8�Lä!Ÿwšw |Ó4�àÒ#Ø×,Ò,¨\ÑD¸VÒDÜ'¨\ÔVˆLà—~’~Øñ	
à)ð	
ð !ð	
ð "ð		
ð
 #8ð	
ð #8ð	
ð  2ð	
ð ñ	
ˆð Ò#Ø-9Ð)Ñ*àÐr   )r   )N)úspeaker_embeddings_path.json)r�   r   F)T)NNÚpté   FTF)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__rx   r   Úclassmethodr1   rO   ÚstaticmethodrK   rJ   r{   ÚpropertyrI   r‹   r   r›   Ú__static_attributes__Ú__classdictcell__Ú__classcell__)r   r?   s   @@r   r   r   "   s¯   ù‡ € ð 	˜1Ø˜Ø�qð€L÷5ð ó7Oó ð7O÷r3Gõ 3Gðj ÷Pó ðP÷$&!ò &!÷P	jò 	jð ÷ó ð÷>ò >ð. ÷7ñ 7ó ÷7ð 7r   r   )Ú__doc__r/   r+   ÚnumpyrL   Úfeature_extraction_utilsr   Úprocessing_utilsr   Útokenization_utils_baser   Úutilsr   r   Ú	utils.hubr   Úautor	   Ú
get_loggerr    r)   r   Ú__all__© r   r   Ú<module>rµ      sb   ðñó Û 	ã å 4Ý .Ý 4ß ,Ý $Ý  ð 
×	Ò	˜HÓ	%€ð ôh�Nó hó ðhðV	 Ð
‚r   