+
    œ°³j{/  ã                   ó  € ^ RI t^RIHtHtHt ^RIHt ^RIH	t	H
t
Ht ^RIHt ^RIHtHtHt ^RIHt ]! 4       '       d   ^ RIt]P*                  ! ]4      t ! R R	]	R
R7      t]! RR7      ] ! R R]
4      4       4       tR.tR# )é    N)Ú
AudioInputÚ make_audio_chat_template_contentÚ make_list_of_audio_chat_template)ÚBatchFeature)ÚProcessingKwargsÚProcessorMixinÚUnpack)Ú	TextInput)Úauto_docstringÚis_torch_availableÚlogging)Úrequiresc            	       ó>   € ] tR t^"tRRR/RRRRRRR/R	R
RRR//tRtR# )ÚAudioFlamingo3ProcessorKwargsÚtext_kwargsÚpaddingTÚaudio_kwargsÚsampling_ratei€>  Úreturn_attention_maskÚ
max_lengthÚcommon_kwargsÚreturn_tensorsÚptÚpadding_sideÚleft© N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú	_defaultsÚ__static_attributes__r   ó    Ú}/home/luca/screen-checking/.venv/lib/python3.14/site-packages/transformers/models/audioflamingo3/processing_audioflamingo3.pyr   r   "   sC   † àØ�tð
ð 	Ø˜UØ# TØ�|ð
ð
 	Ø˜dØ˜Fð
ð„Ir#   r   F)Útotal)Úbackendsc                   ó   a a€ ] tR t^3t o]tRV 3R llt]RV3R lV 3R lll4       tRV3R lV 3R lllt	R t
V3R lR	 ltV3R
 lR lt]V3R lV 3R ll4       t]V3R lR l4       tRV3R lR lltRR/R ltR tV3R lR ltRtVtV ;t# )ÚAudioFlamingo3Processorc                óz   <€ W@n         VP                  V4      V n        WPn        W`n        \
        SV `  WVR7       R# )aÔ  
audio_token (`Optional[str]`, *optional*, defaults to `"<sound>"`):
    Special token used to represent audio inputs in the chat template.
default_transcription_prompt (`str`, *optional*, defaults to `"Transcribe the input speech."`):
    Default prompt to use for transcription tasks when applying transcription requests.
max_audio_len (`int`, *optional*, defaults to 600):
    Maximum length of audio sequences in seconds. Audio longer than this will be truncated.
)Úchat_templateN)Úaudio_tokenÚconvert_tokens_to_idsÚaudio_token_idÚdefault_transcription_promptÚmax_audio_lenÚsuperÚ__init__)ÚselfÚfeature_extractorÚ	tokenizerr*   r+   r.   r/   Ú	__class__s   &&&&&&&€r$   r1   Ú AudioFlamingo3Processor.__init__8   s=   ø€ ð" 'ÔØ'×=Ñ=¸kÓJˆÔØ,HÔ)Ø*ÔÜ‰ÑÐ*À]ÐÖSr#   Fc          
      ó„   <€ V ^8„  d   QhRS[ S[S[ ,          ,          RS[R,          RS[R,          RS[S[,          RS[/# )é   ÚtextÚaudioNÚoutput_labelsÚkwargsÚreturn)r
   Úlistr   Úboolr	   r   r   )ÚformatÚ__classdict__s   "€r$   Ú__annotate__Ú$AudioFlamingo3Processor.__annotate__P   s\   ø€ ÷ Añ Aá™$™y�/Õ)ðAñ ˜DÕ ðAñ ˜d•{ð	Añ
 Ñ6Õ7ðAñ 
ñAr#   c                óz  <€ RV9   d1   VR,          R8w  d#   \        V P                  P                   R24      hV'       d   RVR&   \        SV `  ! RRVRV/VB pV'       dO   VP                  R4      pVR	,          P                  4       pRWv^ 8g  &   RWwV P                  P                  8H  &   WuR
&   \        VRR7      # )a   
output_labels (bool, *optional*, default=False):
    Whether to return labels for training.

Returns:
    [`BatchFeature`]: A dictionary with tokenized text (`input_ids`, `attention_mask`) and
    audio features (`input_features`, `input_features_mask`).
r   r   z% only supports `return_tensors='pt'`.TÚreturn_mm_token_type_idsr:   r9   Úmm_token_type_idsÚ	input_idsÚlabels)ÚdataÚtensor_typer   iœÿÿÿ)
Ú
ValueErrorr5   r   r0   Ú__call__ÚpopÚcloner4   Úpad_token_idr   )	r2   r9   r:   r;   r<   Úmodel_inputsrF   rH   r5   s	   &&&&,   €r$   rL   Ú AudioFlamingo3Processor.__call__O   sÃ   ø€ ð" ˜vÔ%¨&Ð1AÕ*BÀdÔ*JÜ §¡× 7Ñ 7Ð8Ð8]Ð^Ó_Ð_çØ15ˆFÐ-Ñ.Ü‘wÒ'ÑI¨eÐI¸$ÐIÀ&ÑIˆçØ ,× 0Ñ 0Ð1DÓ EÐØ! +Õ.×4Ñ4Ó6ˆFØ-1ˆF¨Ñ)Ñ*Ø<@ˆF˜TŸ^™^×8Ñ8Ñ8Ñ9Ø%+˜Ñ"Ü ¸4Ô@Ð@r#   c                óx   <€ V ^8„  d   QhRS[ R,          RS[S[S[,          ,          R,          RS[S[,          /# )r8   r:   Nr9   r<   )r   r
   r>   r	   r   )r@   rA   s   "€r$   rB   rC   o   sG   ø€ ÷ 	dñ 	dá˜DÕ ð	dñ ™$™y�/Õ)¨DÕ0ð	dñ Ñ)Õ*ñ		dr#   c                óÂ   <€ \         SV `  ! RR VRV/VB  VeF   Ve@   \        V4      \        V4      8w  d%   \        R\        V4       R\        V4       R24      hR# R# R# )r:   r9   NzGot z
 text but z audios; they must match 1:1.r   )r0   Úvalidate_inputsÚlenrK   )r2   r:   r9   r<   r5   s   &&&,€r$   rT   Ú'AudioFlamingo3Processor.validate_inputso   sh   ø€ ô 	‰ÒÑA eÐA°$ÐA¸&ÒAàÒ Ò 1´c¸$³iÄ3ÀuÃ:Ô6MÜ˜t¤C¨£I ;¨j¼¸U»¸ÐDaÐbÓcÐcñ 7NÑ 1Ñr#   c                ób   € V^,
          ^,          ^,           pV^,
          ^,          ^,           pV# )é   r   )r2   Úaudio_lengthsÚconv_output_lengthsÚaudio_tokens_lengthss   &&  r$   Ú_get_audio_token_lengthÚ/AudioFlamingo3Processor._get_audio_token_lengthz   s2   € Ø,¨qÕ0°QÕ6¸Õ:ÐØ 3°aÕ 7¸AÕ=ÀÕAÐØ#Ð#r#   c                ó    <€ V ^8„  d   QhRS[ /# )r8   r:   )r   )r@   rA   s   "€r$   rB   rC      s   ø€ ÷ (0ñ (0¡Jñ (0r#   c           
     ó°  € \        VR ,          V P                  P                  ,          4      p\        V P                  V P                  P                  ,          4      p. p. pV Fò  p\        VP                  ^ ,          4      p\        ^Wƒ,           ^,
          V,          4      p	W”8”  dD   \        P                  RW‚R ,          ,          R RV P                   RV P                   R24       Tp	VP                  V	4       \        W‰V,          4      p
\        V	4       F8  pW³,          p\        V^,           V,          V
4      pVP                  W|V 4       K:  	  Kô  	  V P                  P                  V4      pV P                  ! V3/ VB pVP                  R4      VR&   \        P                  ! \        P                  ! VR,          P!                  R
4      V4       Uu. uF  qÿP!                  4       NK  	  up4      pV P#                  V4      VR&   . p\        \%        V4      4       F'  pV P'                  VVR	7      pVP                  V4       K)  	  VV3# u upi )r   zAudio duration (z.1fzs) exceeds zs; truncating to first zs.Úattention_maskÚinput_features_maskÚnum_audio_tokens)Ú	audio_idxéÿÿÿÿ)Úintr3   Úchunk_lengthr/   ÚshapeÚmaxÚloggerÚwarningÚappendÚminÚrangeÚfetch_audiorM   ÚtorchÚstackÚsplitÚsumr\   rU   Úreplace_audio_token)r2   r:   r<   Úwindow_sizeÚmax_windowsÚper_sample_windowsÚflat_chunksÚaudio_elÚ	n_samplesÚn_winÚtime_capÚiÚstartÚendÚaudio_inputsÚsrY   Úaudio_replacementsÚidxÚreplacement_texts   &&,                 r$   Ú_process_audioÚ&AudioFlamingo3Processor._process_audio   s<  € ä˜& Õ1°D×4JÑ4J×4WÑ4WÕWÓXˆÜ˜$×,Ñ,°×0FÑ0F×0SÑ0SÕSÓTˆà(*ÐØ(*ˆÛˆHÜ˜HŸN™N¨1Õ-Ó.ˆIÜ˜˜IÕ3°aÕ7¸KÕGÓHˆEØÔ"Ü—‘Ø& y¸/Õ3JÕ'JÈ3Ð&OÈ{Ð[_×[mÑ[mÐZnð  oFð  GK÷  GYñ  GYð  FZð  Z\ð  ]ôð $�Ø×%Ñ% eÔ,ä˜9¨kÕ&9Ó:ˆHÜ˜5–\�Ø��Ü˜1˜q�5 KÕ/°Ó:�Ø×"Ñ" 8°#Ð#6Ö7ó "ñ ð  ×&Ñ&×2Ñ2°5Ó9ˆØ×-Ò-¨kÑD¸VÑDˆØ.:×.>Ñ.>Ð?OÓ.PˆÐ*Ñ+ô
 ŸšÜ#Ÿkšk¨,Ð7LÕ*M×*QÑ*QÐRTÓ*UÐWiÔjÓkÑj˜�U‰UŽWÑjÑkó
ˆð ,0×+GÑ+GÈÓ+VˆÐ'Ñ(àÐÜœ˜U›Ö$ˆCØ#×7Ñ7¸ÐPSÐ7ÓTÐØ×%Ñ%Ð&6Ö7ñ %ð Ð/Ð/Ð/ùò ls   ÇIc                ó,   <€ V ^8„  d   QhRS[ RS[RS[/# )r8   r   rc   r=   )Údictre   Ústr)r@   rA   s   "€r$   rB   rC   ©   s#   ø€ ÷ 3ñ 3±ð 3Áð 3ÑSVñ 3r#   c                óH   € VR ,          V,          pV P                   V,          # )rb   )r+   )r2   r   rc   r<   rb   s   &&&, r$   rs   Ú+AudioFlamingo3Processor.replace_audio_token©   s%   € Ø'Ð(:Õ;¸IÕFÐØ×ÑÐ"2Õ2Ð2r#   c                ó0   <€ V ^8„  d   QhRS[ S[,          /# ©r8   r=   ©r>   rˆ   )r@   rA   s   "€r$   rB   rC   ®   s   ø€ ÷ Cñ C¡4©¥9ñ Cr#   c                ó(   <€ \         SV `  R .,           # )ra   )r0   Úmodel_input_names)r2   r5   s   &€r$   r�   Ú)AudioFlamingo3Processor.model_input_names­   s   ø€ ä‰wÑ(Ð,AÐ+BÕBÐBr#   c                ó0   <€ V ^8„  d   QhRS[ S[,          /# rŒ   r�   )r@   rA   s   "€r$   rB   rC   ²   s   ø€ ÷ $ñ $¡D©¥Iñ $r#   c                ó   € R.# )zNInput names returned always by subprocessors but not used in model's `forward`rb   r   )r2   s   &r$   Úunused_input_namesÚ*AudioFlamingo3Processor.unused_input_names±   s   € ð #Ð#Ð#r#   c                ó    <€ V ^8„  d   QhRS[ S[S[ ,          ,          S[,          RS[ S[S[ ,          ,          R,          RS[S[,          RS[/# )r8   r:   ÚpromptNr<   r=   )rˆ   r>   r   r	   r   r   )r@   rA   s   "€r$   rB   rC   ¶   sY   ø€ ÷ G
ñ G
á‘T™#•Y�¡Õ+ðG
ñ ‘d™3•i• $Õ&ðG
ñ Ñ6Õ7ð	G
ñ
 
ñG
r#   c                óª  € \        \        V4      4      pV Uu. uFQ  p\        V\        P                  4      '       d-   VP                  4       P                  4       P                  4       MTNKS  	  pp\        V4      pV^ 8X  d   \        R4      hVf   V P                  .V,          pM×\        V\        4      '       d   V.V,          pM¶\        V\         \        ,          4      '       d‹   \        V4      V8w  d   \        R\        V4       RV R24      h. pV FV  pVf   VP                  V P                  4       K$  \        V\        4      '       d   VP                  V4       KM  \        R4      h	  M\        R4      h\        Wt4       U	U
u. uF  w  ršRRR	R
RRV	/\!        V
4      ./.NK  	  pp	p
V P"                  ! V3RRRRRR/VB # u upi u up
p	i )a©  
Prepare inputs for automatic speech recognition without manually writing the default transcription prompt.

Args:
    audio (`str`, `list[str]`, `np.ndarray`, `torch.Tensor`, `list[np.ndarray]`, `list[torch.Tensor]`):
        Audio to transcribe. Strings are interpreted as local paths or URLs and will be loaded automatically by
        the chat template loader; NumPy arrays and PyTorch tensors are forwarded directly.
    prompt (`str` or `list[str]`, *optional*):
        Custom prompt(s) to include in the user turn. A list must be the same length as the batch. When `None`,
        each sample uses `"Transcribe the input speech."`.
    **kwargs:
        Additional keyword arguments forwarded to [`~AudioFlamingo3Processor.apply_chat_template`] (for example
        `text_kwargs`, `audio_kwargs`, ...).

Returns:
    [`BatchFeature`]: Processor outputs ready to be passed to [`AudioFlamingo3ForConditionalGeneration.generate`].

z)`audio` must contain at least one sample.z	Received z prompt(s) for z$ audio sample(s); counts must match.z'Each prompt must be a string or `None`.z<`prompt` must be a string, a sequence of strings, or `None`.ÚroleÚuserÚcontentÚtyper9   ÚtokenizeTÚadd_generation_promptÚreturn_dict)r>   r   Ú
isinstancero   ÚTensorÚdetachÚcpuÚnumpyrU   rK   r.   rˆ   Útuplerk   Ú	TypeErrorÚzipr   Úapply_chat_template)r2   r:   r–   r<   Úaudio_itemsÚelÚ
batch_sizeÚpromptsÚitemÚprompt_textÚ
audio_itemÚconversationss   &&&,        r$   Úapply_transcription_requestÚ3AudioFlamingo3Processor.apply_transcription_request¶   sä  € ô2 /3Ô3SÐTYÓ3ZÓ.[ˆÙcnÓoÑcnÐ]_´J¸rÄ5Ç<Á<×4PÒ4P�r—y‘y“{—‘Ó(×.Ñ.Ô0ÐVXÒXÑcnˆÐoä˜Ó%ˆ
Ø˜Œ?ÜÐHÓIÐIàŠ>Ø×8Ñ8Ð9¸JÕF‰GÜ˜¤×$Ò$Ø�h Õ+‰GÜ˜¤¤u¥×-Ò-Ü�6‹{˜jÔ(Ü Ø¤ F£˜}¨O¸J¸<ÐGkÐlóð ð ˆGÛ�Ø’<Ø—N‘N 4×#DÑ#DÖEÜ ¤c×*Ò*Ø—N‘N 4Ö(ä#Ð$MÓNÐNò ô ÐZÓ[Ð[ô ,/¨wÔ+Dô
ñ ,EÑ'�ð ˜FØØ ¨°Ð=Ü8¸ÓDð ðóñ ,Eð 	ñ 
ð ×'Ò'Øñ
àð
ð #'ð
ð ð	
ð
 ñ
ð 	
ùòO pùó4
s   ™AG
Æ!GÚstrip_prefixc               ó–   € V P                   P                  ! V/ VB pV'       d    V Uu. uF  qPP                  V4      NK  	  ppV# u upi )aB  
Forward arguments to [`~PreTrainedTokenizer.decode`] and optionally remove the assistant framing the model
was trained to produce.

AF3 transcription requests respond with sentences such as `"The spoken content of the audio is "..."."`.
Setting `strip_prefix=True` trims the fixed prefix for just the transcription text.
)r4   ÚdecodeÚ"_strip_assistant_prefix_and_quotes)r2   r²   Úargsr<   Údecodedr9   s   &$*,  r$   r´   ÚAudioFlamingo3Processor.decodeÿ   sJ   € ð —.‘.×'Ò'¨Ð8°Ñ8ˆßÙQXÓYÑQXÈ×>Ñ>¸tÖDÑQXˆGÐYØˆùò Zs   ©Ac                ó&   € V P                   ! V/ VB # )z)BC as previous examples used batch_decode)r´   )r2   r¶   r<   s   &*,r$   Úbatch_decodeÚ$AudioFlamingo3Processor.batch_decode  s   € à�{Š{˜DÐ+ FÑ+Ð+r#   c                ó&   <€ V ^8„  d   QhRS[ RS[ /# )r8   r9   r=   )rˆ   )r@   rA   s   "€r$   rB   rC     s   ø€ ÷ ñ ±sð ¹sñ r#   c                ó‚  € VP                  4       pR F8  pVP                  V4      '       g   K  V\        V4      R P                  4       p M	  VP                  R4      '       d   VRR P                  4       p\        V4      ^8¼  d7   V^ ,          VR,          8X  d"   V^ ,          R9   d   V^R P                  4       pV# )zY
Remove the assistant prefix and surrounding quotes from a decoded transcription string.
NÚ.)z"The spoken content of the audio isz!The transcription of the audio isz!The content of the input audio isrd   >   Ú"Ú')ÚstripÚ
startswithrU   Úendswith)r2   r9   ÚstrippedÚprefixs   &&  r$   rµ   Ú:AudioFlamingo3Processor._strip_assistant_prefix_and_quotes  s±   € ð
 —:‘:“<ˆó
ˆFð
 ×"Ñ" 6×*Ô*Ø#¤C¨£K MÐ2×8Ñ8Ó:�Ùñ
ð ×Ñ˜S×!Ò!Ø  �}×*Ñ*Ó,ˆHäˆx‹=˜AÔ (¨1¥+°¸"µÔ"=À(È1Å+ÐQ[ÔB[Ø  "�~×+Ñ+Ó-ˆHàˆr#   )r+   r-   r.   r/   )Nz<sound>zTranscribe the input speech.iX  )NF)NN)N)r   r   r   r    r   Úvalid_processor_kwargsr1   r   rL   rT   r\   r„   rs   Úpropertyr�   r“   r°   r´   rº   rµ   r"   Ú__classdictcell__Ú__classcell__)r5   rA   s   @@r$   r(   r(   3   s²   ù‡ € ð ;Ð÷Tð. ÷Aô Aó ðA÷>	dõ 	dò$÷
(0ð (0÷T3ð 3ð ÷Cò Có ðCð ÷$ó ð$÷G
ò G
ðR¨ô ò,÷÷ ð r#   r(   )ro   )r£   ÚnpÚaudio_utilsr   r   r   Úfeature_extraction_utilsr   Úprocessing_utilsr   r   r	   Útokenization_utils_baser
   Úutilsr   r   r   Úutils.import_utilsr   ro   Ú
get_loggerr   ri   r   r(   Ú__all__r   r#   r$   Ú<module>rÔ      sŠ   ðó" ç iÑ iÝ 4ß HÑ HÝ 0ß @Ñ @Ý *ñ ×ÒÛð 
×	Ò	˜HÓ	%€ôÐ$4¸Eõ ñ" 
�:ÔØôq˜nó qó ó ðqðh %Ð
%‚r#   