+
    QV-jŸ/  ã                   ót   € ^ RI t ^ RIt^ RIt^ RItR R ltRR R lltRR R lltRR R	 lltR
 R lt	R t
R# )é    Nc                óP   € V ^8„  d   QhR\         R\        R\        P                  /# )é   ÚbpayloadÚsampling_rateÚreturn)ÚbytesÚintÚnpÚndarray)Úformats   "Ús/Volumes/fast/ai/experiments/ui-tars-smoke/.venv/lib/python3.14/site-packages/transformers/pipelines/audio_utils.pyÚ__annotate__r   	   s%   € ÷ $ñ $œ%ð $´ð $¼¿
¹
ñ $ó    c                óè  € T pRpRpRRRRVRVRVR	R
RR.p \         P                  ! V\         P                  \         P                  R7      ;_uu_ 4       pVP                  V 4      pRRR4       X^ ,          p	\        P                  ! T	\        P                  4      p
T
P                  ^ ,          ^ 8X  d   \        R4      hT
#   + '       g   i     Lc; i  \         d   p\        R4      ThRp?ii ; i)z7
Helper function to read an audio file through ffmpeg.
Ú1Úf32leÚffmpegú-izpipe:0ú-acú-arú-fú-hide_bannerú	-loglevelÚquietúpipe:1)ÚstdinÚstdoutNzFffmpeg was not found but is required to load audio files from filenamea  Soundfile is either not in the correct format or is malformed. Ensure that the soundfile has a valid audio file extension (e.g. wav, flac or mp3) and is not corrupted. If reading from a remote URL, ensure that the URL is the full address to **download** the audio file.)
Ú
subprocessÚPopenÚPIPEÚcommunicateÚFileNotFoundErrorÚ
ValueErrorr
   Ú
frombufferÚfloat32Úshape)r   r   ÚarÚacÚformat_for_conversionÚffmpeg_commandÚffmpeg_processÚoutput_streamÚerrorÚ	out_bytesÚaudios   &&         r   Úffmpeg_readr0   	   sô   € ð ˆ?€BØ	€BØ#ÐàØØØØ
ØØ
ØØØØØØð€Nð nÜ×Ò˜n´J·O±OÌJÏOÉO×\Õ\Ð`nØ*×6Ñ6°xÓ@ˆM÷ ]ð ˜aÕ €IÜ�MŠM˜)¤R§Z¡ZÓ0€EØ‡{�{�1…~˜ÔÜð[ó
ð 	
ð
 €L÷ ]×\ûäô nÜÐaÓbÐhmÐmûðnús5   ˜=C ÁCÁ'C ÃC	ÃC ÃC ÃC1Ã C,Ã,C1c                ó†   € V ^8„  d   QhR\         R\        R\        R\        R,          R\        \        ,          R,          /# )r   r   Úchunk_length_sr)   Úffmpeg_input_deviceNÚffmpeg_additional_args)r	   ÚfloatÚstrÚlist)r   s   "r   r   r   0   sN   € ÷ Qñ QÜðQäðQô ðQô ˜t�ð	Qô
 !¤�I¨Õ,ñQr   c              #  óâ  "  € T  pRpVR8X  d   ^pMVR8X  d   ^pM\        RV R24      h\        P                  ! 4       pVR8X  d   Rp	T;'       g    Rp
M3VR	8X  d   R
p	T;'       g    Rp
MVR8X  d   Rp	T;'       g    \        4       p
Vf   . MTpRRX	RX
RVRVRVRRRRRR.pVP	                  V4       \        \        W,          4      4      V,          p\        W¼4      pT Rj  x€L
  R#  L5i)a=  
Helper function to read audio from a microphone using ffmpeg. The default input device will be used unless another
input device is specified using the `ffmpeg_input_device` argument. Uses 'alsa' on Linux, 'avfoundation' on MacOS and
'dshow' on Windows.

Arguments:
    sampling_rate (`int`):
        The sampling_rate to use when reading the data from the microphone. Try using the model's sampling_rate to
        avoid resampling later.
    chunk_length_s (`float` or `int`):
        The length of the maximum chunk of audio to be sent returned.
    format_for_conversion (`str`, defaults to `f32le`):
        The name of the format of the audio samples to be returned by ffmpeg. The standard is `f32le`, `s16le`
        could also be used.
    ffmpeg_input_device (`str`, *optional*):
        The identifier of the input device to be used by ffmpeg (i.e. ffmpeg's '-i' argument). If unset,
        the default input device will be used. See `https://www.ffmpeg.org/ffmpeg-devices.html#Input-Devices`
        for how to specify and list input devices.
    ffmpeg_additional_args (`list[str]`, *optional*):
        Additional arguments to pass to ffmpeg, can include arguments like -nostdin for running as a background
        process. For example, to pass -nostdin to the ffmpeg process, pass in ["-nostdin"]. If passing in flags
        with multiple arguments, use the following convention (eg ["flag", "arg1", "arg2]).

Returns:
    A generator yielding audio chunks of `chunk_length_s` seconds as `bytes` objects of length
    `int(round(sampling_rate * chunk_length_s)) * size_of_sample`.
r   Ús16ler   úUnhandled format `ú `. Please use `s16le` or `f32le`ÚLinuxÚalsaÚdefaultÚDarwinÚavfoundationz:defaultÚWindowsÚdshowNr   r   r   r   r   z-fflagsÚnobufferr   r   r   r   )r#   ÚplatformÚsystemÚ_get_microphone_nameÚextendr	   ÚroundÚ_ffmpeg_stream)r   r2   r)   r3   r4   r'   r(   Úsize_of_samplerE   Úformat_Úinput_r*   Ú	chunk_lenÚiterators   &&&&&         r   Úffmpeg_microphonerO   0   s)  é € ðD ˆ?€BØ	€BØ Ô'Ø‰Ø	 'Ô	)Ø‰äÐ-Ð.CÐ-DÐDdÐeÓfÐfä�_Š_Ó€Fà�ÔØˆØ$×1Ð1¨	‰Ø	�8Ô	Ø ˆØ$×2Ð2¨
‰Ø	�9Ô	ØˆØ$×>Ð>Ô(<Ó(>ˆà#9Ò#A™RÐG]Ðð 	ØØØØØØ
ØØ
ØØØØØØØØð#€Nð( ×ÑÐ0Ô1ä”E˜-Õ8Ó9Ó:¸^ÕK€IÜ˜nÓ8€HØ×Ôùs%   ‚AC/ÁC/Á(C/Á>A(C/Ã&C-Ã'C/c                óò   € V ^8„  d   QhR\         R\        R\         R,          R\        \        \        3,          \        ,          R,          R\        R\        R,          R\        \        ,          R,          /# )	r   r   r2   Ústream_chunk_sNÚstride_length_sr)   r3   r4   )r	   r5   Útupler6   r7   )r   s   "r   r   r   „   s{   € ÷ \ñ \Üð\äð\ô ˜$•Jð\ô œ5¤%˜<Õ(¬5Õ0°4Õ7ð	\ô
 ð\ô ˜t�ð\ô !¤�I¨Õ,ñ\r   c              #  óÐ  "  € Ve   TpMTp\        T TTTVf   . MTR7      pVR8X  d   \        P                  p	^p
M)VR8X  d   \        P                  p	^p
M\	        RV R24      hVf
   V^,          p\        \        W,          4      4      V
,          p\        V\
        \        34      '       d   W3.p\        \        W^ ,          ,          4      4      V
,          p\        \        W^,          ,          4      4      V
,          p\        P                  P                  4       p\        P                  ! VR7      p\        W‹WÍ3RR	7       Fš  p\        P                  ! VR
,          V	R7      VR
&   VR,          ^ ,          V
,          VR,          ^,          V
,          3VR&   V VR&   Wï,          p\        P                  P                  4       V^
V,          ,           8”  d   K–  Vx € Kœ  	  R# 5i)aý	  
Helper function to read audio from a microphone using ffmpeg. This will output `partial` overlapping chunks starting
from `stream_chunk_s` (if it is defined) until `chunk_length_s` is reached. It will make use of striding to avoid
errors on the "sides" of the various chunks. The default input device will be used unless another input device is
specified using the `ffmpeg_input_device` argument. Uses 'alsa' on Linux, 'avfoundation' on MacOS and 'dshow' on Windows.

Arguments:
    sampling_rate (`int`):
        The sampling_rate to use when reading the data from the microphone. Try using the model's sampling_rate to
        avoid resampling later.
    chunk_length_s (`float` or `int`):
        The length of the maximum chunk of audio to be sent returned. This includes the eventual striding.
    stream_chunk_s (`float` or `int`):
        The length of the minimal temporary audio to be returned.
    stride_length_s (`float` or `int` or `(float, float)`, *optional*):
        The length of the striding to be used. Stride is used to provide context to a model on the (left, right) of
        an audio sample but without using that part to actually make the prediction. Setting this does not change
        the length of the chunk.
    format_for_conversion (`str`, *optional*, defaults to `f32le`):
        The name of the format of the audio samples to be returned by ffmpeg. The standard is `f32le`, `s16le`
        could also be used.
    ffmpeg_input_device (`str`, *optional*):
        The identifier of the input device to be used by ffmpeg (i.e. ffmpeg's '-i' argument). If unset,
        the default input device will be used. See `https://www.ffmpeg.org/ffmpeg-devices.html#Input-Devices`
        for how to specify and list input devices.
    ffmpeg_additional_args (`list[str]`, *optional*):
        Additional arguments to pass to ffmpeg, can include arguments like -nostdin for running as a background
        process. For example, to pass -nostdin to the ffmpeg process, pass in ["-nostdin"]. If passing in flags
        with multiple arguments, use the following convention (eg ["flag", "arg1", "arg2]).

Return:
    A generator yielding dictionaries of the following form

    `{"sampling_rate": int, "raw": np.ndarray, "partial" bool}` With optionally a `"stride" (int, int)` key if
    `stride_length_s` is defined.

    `stride` and `raw` are all expressed in `samples`, and `partial` is a boolean saying if the current yield item
    is a whole chunk, or a partial temporary result to be later replaced by another larger chunk.
N)r)   r3   r4   r9   r   r:   r;   )ÚsecondsT)ÚstrideÚstreamÚraw)ÚdtyperV   r   )rO   r
   Úint16r%   r#   r	   rH   Ú
isinstancer5   ÚdatetimeÚnowÚ	timedeltaÚchunk_bytes_iterr$   )r   r2   rQ   rR   r)   r3   r4   Úchunk_sÚ
microphonerY   rJ   rM   Ústride_leftÚstride_rightÚ
audio_timeÚdeltaÚitems   &&&&&&&          r   Úffmpeg_microphone_liverg   „   s´  é € ð` Ò!Ø ‰à ˆä"ØØØ3Ø/Ø%;Ò%C™rÐI_ô€Jð  Ô'Ü—‘ˆØ‰Ø	 'Ô	)Ü—
‘
ˆØ‰äÐ-Ð.CÐ-DÐDdÐeÓfÐfàÒØ(¨1Õ,ˆÜ”E˜-Õ8Ó9Ó:¸^ÕK€IÜ�/¤C¬ <×0Ò0Ø*Ð<ˆä”e˜M¸AÕ,>Õ>Ó?Ó@À>ÕQ€KÜ”u˜]¸QÕ-?Õ?Ó@ÓAÀNÕR€LÜ×"Ñ"×&Ñ&Ó(€JÜ×Ò wÔ/€EÜ  ÀÐ?ZÐcg×hˆä—m’m D¨¥K°uÔ=ˆˆU‰à��N˜1Õ Õ/Ø��N˜1Õ Õ/ð
ˆˆX‰ð !.ˆˆ_ÑØÕˆ
Ü×Ñ× Ñ Ó" Z°"°uµ*Õ%<Ô<áØŒ
ó iùs   ‚G$G&c                ó^   € V ^8„  d   QhR\         R\        \         \         3,          R\        /# )r   rM   rV   rW   )r	   rS   Úbool)r   s   "r   r   r   ã   s*   € ÷  ñ  ¬#ð  ´u¼SÄ#¸Xµð  ÔPTñ  r   c              #  ó´  "  € RpVw  rVWV,           V8¼  d   \        RV RV RV 24      h^ pV  Fy  pWH,          pV'       d$   \        V4      V8  d   V^ 3pRVRV RVRR	/x € K6  \        V4      V8¼  g   KH  Wv3pRVRV RV/p	V'       d   R
V	R&   V	x € TpWAV,
          V,
          R pKE  	  \        V4      V8”  d   RVRV^ 3/p	V'       d   R
V	R&   V	x € R# R# 5i)zÞ
Reads raw bytes from an iterator and does chunks of length `chunk_len`. Optionally adds `stride` to each chunks to
get overlaps. `stream` is used to return partial results even if a full `chunk_len` is not yet available.
r   z5Stride needs to be strictly smaller than chunk_len: (z, z) vs rX   NrV   ÚpartialTF)r#   Úlen)
rN   rM   rV   rW   Úaccrb   rc   Ú_stride_leftrX   rf   s
   &&&&      r   r_   r_   ã   s  é € ð
 €CØ &Ñ€KØÕ! YÔ.ÜØCÀKÀ=ÐPRÐS_ÐR`Ð`eÐfoÐepÐqó
ð 	
ð €LÛˆØ�
ˆß”c˜#“h Ô*Ø" AÐ&ˆFØ˜#˜j˜y˜/¨8°V¸YÈÐMÔMä�c“(˜iÖ'à&Ð5�Ø˜s : I˜°¸&ÐA�ßØ&+�D˜‘OØ’
Ø*�Ø kÕ1°LÕ@ÐBÐC’ñ ô  ˆ3ƒx�+ÔØ�s˜H |°QÐ&7Ð8ˆßØ#ˆD�‰OØŒ
ñ	 ùs   ‚A/CÁ6ACÃCc                ó$   € V ^8„  d   QhR\         /# )r   Úbuflen)r	   )r   s   "r   r   r     s   € ÷ pñ p¬3ñ pr   c              #  ó>  "  € Rp \         P                  ! V \         P                  VR7      ;_uu_ 4       p VP                  P	                  V4      pVR8X  d   MVx € K*  RRR4       R#   + '       g   i     R# ; i  \
         d   p\        R4      ThRp?ii ; i5i)zB
Internal function to create the generator of data through ffmpeg
)r   Úbufsizer   NzHffmpeg was not found but is required to stream audio files from filenamei   )r   r   r    r   Úreadr"   r#   )r*   rp   rr   r+   rX   r-   s   &&    r   rI   rI     s‡   é € ð €GðpÜ×Ò˜n´Z·_±_Èg×VÕVÐZhØØ$×+Ñ+×0Ñ0°Ó8�Ø˜#”:ØØ”	÷ W×V×VÒVûô ô pÜÐcÓdÐjoÐoûðpüsK   ‚B†/A> µ+A*Á A> Á(BÁ*A;	Á5A> Á9BÁ;A> Á>BÂ	BÂBÂBc                 ó~  € . R
Op  \         P                  ! V R\         P                  RR7      pVP                  P	                  4        Uu. uF  pRV9   g   K  VNK  	  ppV'       d3   V^ ,          P                  R4      ^,          p\        RV 24       RV 2#  R	# u upi   \         d    \        R4        R	# i ; i)z+
Retrieve the microphone name in Windows .
Tzutf-8)ÚtextÚstderrÚencodingz(audio)Ú"zUsing microphone: zaudio=zOffmpeg was not found. Please install it or make sure it is in your system PATH.r>   )r   z-list_devicesÚtruer   rB   r   Ú )r   Úrunr    rv   Ú
splitlinesÚsplitÚprintr"   )ÚcommandÚffmpeg_devicesÚlineÚmicrophone_linesÚmicrophone_names        r   rF   rF     sÅ   € ò K€Gð	aÜ#Ÿš¨°dÄ:Ç?Á?Ð]dÔeˆØ-;×-BÑ-B×-MÑ-MÔ-OÓeÑ-O TÐS\Ð`dÑSdŸD˜DÑ-OÐÐeçØ.¨qÕ1×7Ñ7¸Ó<¸QÕ?ˆOÜÐ& Ð&7Ð8Ô9Ø˜OÐ,Ð-Ð-ð ñ ùò føô ô aÜÐ_Õ`áðaús*   †AB" Á
	BÁBÁ;B" ÂB" Â"B<Â;B<)r   NN)NNr   NN)F)r\   rD   r   Únumpyr
   r0   rO   rg   r_   rI   rF   © r   r   Ú<module>r†      s6   ðã Û Û ã õ$÷NQ÷h\÷~ õFpô r   