+
    œ°³jL"  ã                   ó6  € ^ RI t ^RIHtHt ^RIHt ^RIHtHtH	t	 ^RI
HtHt ^RIHtHtHtHt ^RIHtHt ]P*                  ! ]4      t]! 4       '       d   ^ RIt]! 4       '       d   ^ RIt ! R R	]R
R7      t]! RR7      ] ! R R]4      4       4       tR.tR# )é    N)Ú
AudioInputÚmake_list_of_audio)ÚBatchFeature)ÚProcessingKwargsÚProcessorMixinÚUnpack)ÚPreTokenizedInputÚ	TextInput)Úauto_docstringÚis_soundfile_availableÚis_torch_availableÚlogging)ÚrequiresÚrequires_backendsc                   ó"   € ] tR t^$tRRR//tRtR# )ÚVibeVoiceProcessorKwargsÚaudio_kwargsÚsampling_rateiÀ]  © N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú	_defaultsÚ__static_attributes__r   ó    Ús/home/luca/screen-checking/.venv/lib/python3.14/site-packages/transformers/models/vibevoice/processing_vibevoice.pyr   r   $   s   † àØ˜Uð
ð„Ir   r   F)Útotal)Úbackendsc                   óš   a a€ ] tR t^,t o]tRV 3R lltV3R lR ltV3R lR lt]	RV3R lV 3R lll4       t
RV3R lR	 lltR
tVtV ;t# )ÚVibeVoiceProcessorc                óŒ  <€ W@n         \        VRR4      '       d   VP                  MVP                  V4      V n        WPn        \        VRR4      '       d   VP
                  MVP                  V4      V n        W`n        \        VRR4      '       d   VP                  MVP                  V4      V n        \        SV `%  WVR7       R# )a‰  
audio_bos_token (`str`, *optional*, defaults to `"<|vision_start|>"`):
    The token used to indicate the beginning of audio generation.
audio_eos_token (`str`, *optional*, defaults to `"<|vision_end|>"`):
    The token used to indicate the end of audio generation.
audio_token (`str`, *optional*, defaults to `"<|vision_pad|>"`):
    The token used to indicate to continue generating audio.
Úaudio_bos_token_idNÚaudio_eos_token_idÚaudio_token_id)Úchat_template)
Úaudio_bos_tokenÚgetattrr#   Úconvert_tokens_to_idsÚaudio_eos_tokenr$   Úaudio_tokenr%   ÚsuperÚ__init__)ÚselfÚfeature_extractorÚ	tokenizerr&   r'   r*   r+   Ú	__class__s   &&&&&&&€r   r-   ÚVibeVoiceProcessor.__init__1   sÉ   ø€ ð"  /Ôô �yÐ"6¸×=Ò=ð ×(Ò(à×0Ñ0°ÓAð 	Ôð
  /Ôô �yÐ"6¸×=Ò=ð ×(Ò(à×0Ñ0°ÓAð 	Ôð
 'Ôô �yÐ"2°D×9Ò9ð ×$Ò$à×0Ñ0°Ó=ð 	Ôô
 	‰ÑÐ*À]ÐÖSr   c                ó    <€ V ^8„  d   QhRS[ /# )é   Úaudio)r   )ÚformatÚ__classdict__s   "€r   Ú__annotate__ÚVibeVoiceProcessor.__annotate__V   s   ø€ ÷ 3ñ 3¡Jñ 3r   c                ó¢  € V P                   ! V3/ VB pVP                  R 4      ;'       g    V P                   P                  p\        P                  ! VR,          P                  RR7      V,          4      P                  4       P                  4       V n        \        \        V4      4       Uu. uF  qPP                  W54      NK  	  ppW63# u upi )Úpad_to_multiple_ofÚpadding_mask)Údiméÿÿÿÿ)r/   Úgetr;   ÚtorchÚceilÚsumÚintÚtolistÚ_num_audio_tokensÚrangeÚlenÚreplace_audio_token)r.   r5   ÚkwargsÚprocessed_audior;   ÚidxÚaudio_replacementss   &&,    r   Ú_process_audioÚ!VibeVoiceProcessor._process_audioV   sº   € Ø×0Ò0°ÑA¸&ÑAˆØ#ŸZ™ZÐ(<Ó=×jÐjÀ×AWÑAW×AjÑAjÐä�JŠJ� ~Õ6×:Ñ:¸rÐ:ÓBÐEWÕWÓX×\Ñ\Ó^×eÑeÓgð 	Ôô Y^Ô^aÐbgÓ^hÔXiÓjÑXiÐQT×6Ñ6°ÖLÑXiÐÐjØÐ2Ð2ùò ks   Â.Cc                ó,   <€ V ^8„  d   QhRS[ RS[RS[/# )r4   Úaudio_inputsÚ	audio_idxÚreturn)ÚdictrC   Ústr)r6   r7   s   "€r   r8   r9   _   s'   ø€ ÷ Dñ D±ð DÁð DÉñ Dr   c                óJ   € V P                   V P                  V,          ,          # ©N)r+   rE   )r.   rP   rQ   s   &&&r   rH   Ú&VibeVoiceProcessor.replace_audio_token_   s   € Ø×Ñ $×"8Ñ"8¸Õ"CÕCÐCr   c          
      ó´   <€ V ^8„  d   QhRS[ S[,          S[S[ ,          ,          S[S[,          ,          RS[R,          RS[R,          RS[S[,          RS[/# )r4   Útextr5   NÚoutput_labelsrI   rR   )r
   r	   Úlistr   Úboolr   r   r   )r6   r7   s   "€r   r8   r9   c   sf   ø€ ÷ 9ñ 9áÑ+Õ+©d±9­oÕ=ÁÑEVÕ@WÕWð9ñ ˜DÕ ð9ñ ˜d•{ð	9ñ
 Ñ1Õ2ð9ñ 
ñ9r   c                óÊ  <€ RV9   d1   VR,          R8w  d#   \        V P                  P                   R24      h\        SV `  ! RRVRV/VB pV'       d�   VR,          P                  4       pRV9   d   RWeR,          ^ 8H  &   RWfV P                  8H  &   WeR&   \        P                  ! VR,          \        P                  R	7      pVe   R
WuR,          V P                  8H  &   WuR&   V# )ad  
Main method to process text inputs with optional voice samples.

This method processes text inputs (typically prepared by apply_chat_template) and optional voice samples for
voice cloning. It expands audio diffusion tokens based on the actual audio length.

Args:
    text (`str`, `List[str]`):
        The input text(s) to process, typically prepared by apply_chat_template with audio token placeholders.
    audio (`List[Union[str, np.ndarray]]`, *optional*):
        Audio samples for speaker voice cloning. Should match the number of audio token placeholders in text.
    output_labels (bool, *optional*, default=False):
        Whether to return labels for training.
    **kwargs:
        Additional keyword arguments passed to the tokenizer and feature extractor.

Returns:
    [`BatchFeature`]: A [`BatchFeature`] with the following fields:
    - **input_ids** -- List of token ids to be fed to the model.
    - **attention_mask** -- List of indices specifying which tokens should be attended to by the model (when
      `return_attention_mask=True`).
    - **input_values** -- List of audio values to be fed to the model. Returned when `audio` is not `None`.
    - **padding_mask** -- List of indices specifying which audio frames should be attended to by the model.
      Returned when `audio` is not `None`.
    - **labels** -- Labels for language model training. Padding and audio diffusion tokens are masked with
      -100 (audio diffusion token embeddings are replaced by audio features, so their token identity is not a
      meaningful target). Audio bos/eos and text eos tokens are kept as targets so the LM learns when to start
      and stop generating audio. Returned when `output_labels=True`.
    - **acoustic_loss_mask** -- Boolean mask for positions where diffusion loss is computed. True at audio
      diffusion token positions. Returned when `output_labels=True`.
Úreturn_tensorsÚptz% only supports `return_tensors='pt'`.rY   r5   Ú	input_idsÚattention_maskÚlabels)ÚdtypeTÚacoustic_loss_maskr   iœÿÿÿ)
Ú
ValueErrorr1   r   r,   Ú__call__Úcloner%   r@   Ú
zeros_liker\   )	r.   rY   r5   rZ   rI   Údatarb   rd   r1   s	   &&&&,   €r   rf   ÚVibeVoiceProcessor.__call__b   së   ø€ ðN ˜vÔ%¨&Ð1AÕ*BÀdÔ*JÜ §¡× 7Ñ 7Ð8Ð8]Ð^Ó_Ð_ä‰wÒÑA TÐA°ÐA¸&ÑAˆßØ˜+Õ&×,Ñ,Ó.ˆFà 4Ô'Ø6:�Ð,Õ-°Ñ2Ñ3ð 59ˆF˜T×0Ñ0Ñ0Ñ1Ø#�‰Nä!&×!1Ò!1°$°{Õ2CÌ5Ï:É:Ô!VÐØÒ ØOSÐ"¨Õ#4¸×8KÑ8KÑ#KÑLØ);Ð%Ñ&àˆr   c                óJ   <€ V ^8„  d   QhRS[ RS[R,          RS[S[,          /# )r4   r5   Úoutput_pathNrR   )r   rT   r[   )r6   r7   s   "€r   r8   r9   ž   s1   ø€ ÷ %ñ %áð%ñ ˜4•Zð%ñ 
‰c�ñ	%r   c                ó°  € \        V R.4       \        V4      p\        V4       FO  w  r4VP                  4       P	                  4       P                  4       P                  4       P                  4       W&   KQ  	  \        V4      ^8X  d<   Vf   Rp\        P                  ! W!^ ,          V P                  P                  4       V.# Vf   Rp\        P                  ! VRR7       . p\        V4       Fe  w  rg\        P                  P!                  VRV R24      p\        P                  ! W‡V P                  P                  4       VP#                  V4       Kg  	  V# )a	  
Save audio data to WAV file(s).
TODO eventually move to AudioProcessor base class.

Args:
    audio: Audio output from the model to be saved
    output_path: Output file path or directory for multiple files

Returns:
    List[str]: Paths to the saved audio files.
Ú	soundfilezvibevoice_output.wavÚvibevoice_outputsT)Úexist_okÚaudio_z.wav)r   r   Ú	enumerateÚdetachÚcpuÚfloatÚnumpyÚsqueezerG   ÚsfÚwriter/   r   ÚosÚmakedirsÚpathÚjoinÚappend)	r.   r5   rl   rK   ÚitemÚsaved_pathsÚiÚaudio_arrayÚ	file_paths	   &&&      r   Ú
save_audioÚVibeVoiceProcessor.save_audiož   s  € ô" 	˜$  Ô.ä" 5Ó)ˆÜ" 5Ö)‰IˆCØŸ™›×*Ñ*Ó,×2Ñ2Ó4×:Ñ:Ó<×DÑDÓFˆE‹Jñ *ô ˆu‹:˜Œ?ØÒ"Ø4�Ü�HŠH�[¨¥(¨D×,BÑ,B×,PÑ,PÔQØ�=Ð àÒ"Ø1�Ü�KŠK˜¨dÕ3ØˆKÜ"+¨EÖ"2‘�ÜŸG™GŸL™L¨¸¸q¸cÀÐ6FÓG�	Ü—’˜°×1GÑ1G×1UÑ1UÔVØ×"Ñ" 9Ö-ñ #3ð Ðr   )rE   r'   r#   r*   r$   r+   r%   )Nz<|vision_start|>z<|vision_end|>z<|vision_pad|>)NFrV   )r   r   r   r   r   Úvalid_processor_kwargsr-   rM   rH   r   rf   r„   r   Ú__classdictcell__Ú__classcell__)r1   r7   s   @@r   r!   r!   ,   sS   ù‡ € ð 6Ð÷#T÷J3ð 3÷Dð Dð ÷9ô 9ó ð9÷v%÷ %ò %r   r!   )r@   )rz   Úaudio_utilsr   r   Úfeature_extraction_utilsr   Úprocessing_utilsr   r   r   Útokenization_utils_baser	   r
   Úutilsr   r   r   r   Úutils.import_utilsr   r   Ú
get_loggerr   Úloggerr@   rn   rx   r   r!   Ú__all__r   r   r   Ú<module>r’      s“   ðó 
ç 9Ý 4ß HÑ Hß Cß XÓ Xß =ð 
×	Ò	˜HÓ	%€ñ ×ÒÛá×ÒÛôÐ/°uõ ñ 
�:ÔØôU˜ó Uó ó ðUðp  Ð
 ‚r   