ó
    ‰Ž¡jŸ/  ã                   ó"  • S SK r S SKrS SKrS SKrS\S\S\R                  4S jr   SS\S\	S\
S\
S-  S	\\
   S-  4
S
 jjr     SS\S\	S\S-  S\\	\	4   \	-  S-  S\
S\
S-  S	\\
   S-  4S jjrSS\S\\\4   S\4S jjrS\4S jrS rg)é    NÚbpayloadÚsampling_rateÚreturnc                 óº  • U nSnSnSSSSUSUSUS	S
SS/n [         R                  " U[         R                  [         R                  S9 nUR                  U 5      nSSS5        WS   n	[        R                  " U	[        R                  5      n
U
R                  S   S:X  a  [        S5      eU
$ ! , (       d  f       NX= f! [         a  n[        S5      UeSnAff = f)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 filenamer   a  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Ú
ValueErrorÚnpÚ
frombufferÚfloat32Úshape)r   r   ÚarÚacÚformat_for_conversionÚffmpeg_commandÚffmpeg_processÚoutput_streamÚerrorÚ	out_bytesÚaudios              Ú°C:\Users\johnn\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.13_qbz5n2kfra8p0\LocalCache\local-packages\Python313\site-packages\transformers/pipelines/audio_utils.pyÚffmpeg_readr(   	   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   ˜2B? Á
B.ÁB? Â.
B<Â8B? Â<B? Â?
CÃ	CÃCÚchunk_length_sr    Úffmpeg_input_deviceÚffmpeg_additional_argsc              #   ó¾  #   • U  nSnUS:X  a  SnOUS:X  a  SnO[        SU S35      e[        R                  " 5       nUS:X  a  S	n	U=(       d    S
n
O/US:X  a  Sn	U=(       d    Sn
OUS:X  a  Sn	U=(       d
    [        5       n
Uc  / OUnSSW	SW
SUSUSUSSSSSS/nUR	                  U5        [        [        X-  5      5      U-  n[        X¼5      nU Sh  v•N   g N7f)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   Ús16leé   r   é   ú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ÚextendÚintÚroundÚ_ffmpeg_stream)r   r)   r    r*   r+   r   r   Úsize_of_sampler;   Úformat_Úinput_r!   Ú	chunk_lenÚiterators                 r'   Úffmpeg_microphonerF   0   s   é € ðD ˆ?€BØ	€BØ Ó'Ø‰Ø	 'Ó	)Ø‰äÐ-Ð.CÐ-DÐDdÐeÓfÐfä�_Š_Ó€Fà�ÓØˆØ$×1¨	‰Ø	�8Ó	Ø ˆØ$×2¨
‰Ø	�9Ó	ØˆØ$×>Ô(<Ó(>ˆà#9Ñ#A™RÐG]Ðð 	ØØØØØØ
ØØ
ØØØØØØØØð#€Nð( ×ÑÐ0Ô1ä”E˜-Ñ8Ó9Ó:¸^ÑK€IÜ˜nÓ8€HØ×Óùs   ‚CCÃCÃCÚstream_chunk_sÚstride_length_sc              #   ó  #   • Ub  UnOUn[        U UUUUc  / OUS9nUS:X  a  [        R                  n	Sn
O(US:X  a  [        R                  n	Sn
O[	        SU S35      eUc  US	-  n[        [        X-  5      5      U
-  n[        U[
        [        45      (       a  X3/n[        [        XS
   -  5      5      U
-  n[        [        XS   -  5      5      U
-  n[        R                  R                  5       n[        R                  " US9n[        X‹XÍ4SS9 Hn  n[        R                  " US   U	S9US'   US   S
   U
-  US   S   U
-  4US'   U US'   Xï-  n[        R                  R                  5       USU-  -   :”  a  Mj  Uv •  Mp     g7f)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    r*   r+   r-   r.   r   r/   r0   r1   é   r   é   )ÚsecondsT)ÚstrideÚstreamÚraw)ÚdtyperM   r   é
   )rF   r   Úint16r   r   r>   r?   Ú
isinstanceÚfloatÚdatetimeÚnowÚ	timedeltaÚchunk_bytes_iterr   )r   r)   rG   rH   r    r*   r+   Úchunk_sÚ
microphonerP   rA   rD   Ústride_leftÚstride_rightÚ
audio_timeÚdeltaÚitems                    r'   Úffmpeg_microphone_liver`   „   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   ‚FFrD   rM   rN   c              #   óš  #   • SnUu  pVXV-   U:¼  a  [        SU SU SU 35      eSnU  Hw  nXH-  nU(       a   [        U5      U:  a  US4nUSU USS.v •  M.  [        U5      U:¼  d  M?  Xv4nUSU US	.n	U(       a  S
U	S'   U	v •  UnXAU-
  U-
  S n[        U5      U:¼  a  M8  My     [        U5      U:”  a  XGS4S	.n	U(       a  S
U	S'   U	v •  gg7f)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.
ó    z5Stride needs to be strictly smaller than chunk_len: (z, z) vs r   NT)rO   rM   Úpartial)rO   rM   Frc   )r   Úlen)
rE   rD   rM   rN   Úaccr[   r\   Ú_stride_leftrO   r_   s
             r'   rX   rX   ã   s  é € ð
 €CØ &Ñ€KØÑ! YÓ.ÜØCÀKÀ=ÐPRÐS_ÐR`Ð`eÐfoÐepÐqó
ð 	
ð €LÛˆØ‰
ˆÞ”c˜#“h Ó*Ø" AÐ&ˆFØ˜j˜y˜/°VÈÑMÔMä�c“(˜iÕ'à&Ð5�Ø" : I˜¸&ÑA�ÞØ&+�D˜‘OØ’
Ø*�Ø kÑ1°LÑ@ÐBÐC�ô �c“(˜i×'ñ ô  ˆ3ƒx�+ÓØ°QÐ&7Ñ8ˆÞØ#ˆD�‰OØ‹
ð	 ùs   ‚A"CÁ(6CÂ +CÚbuflenc              #   ó  #   • Sn [         R                  " U [         R                  US9 n UR                  R	                  U5      nUS:X  a  OUv •  M(  SSS5        g! , (       d  f       g= f! [
         a  n[        S5      UeSnAff = f7f)zB
Internal function to create the generator of data through ffmpeg
i   )r   Úbufsizerb   NzHffmpeg was not found but is required to stream audio files from filename)r   r   r   r   Úreadr   r   )r!   rg   ri   r"   rO   r$   s         r'   r@   r@     s†   é € ð €GðpÜ×Ò˜n´Z·_±_ÈgÒVÐZhØØ$×+Ñ+×0Ñ0°Ó8�Ø˜#“:ØØ’	ñ	 ÷ W×VÖVûô ó pÜÐcÓdÐjoÐoûðpüsK   ‚B†$A. ª*AÁA. ÁBÁ
A+Á'A. Á*BÁ+A. Á.
B	Á8BÂB	Â	Bc                  ó`  • / SQn  [         R                  " U S[         R                  SS9nUR                  R	                  5        Vs/ s H  nSU;   d  M  UPM     nnU(       a*  US   R                  S5      S   n[        S	U 35        S
U 3$  gs  snf ! [         a    [        S5         gf = f)z+
Retrieve the microphone name in Windows .
)r	   z-list_devicesÚtruer   r8   r
   Ú Tzutf-8)ÚtextÚstderrÚencodingz(audio)r   Ú"rK   zUsing microphone: zaudio=zOffmpeg was not found. Please install it or make sure it is in your system PATH.r4   )r   Úrunr   ro   Ú
splitlinesÚsplitÚprintr   )ÚcommandÚffmpeg_devicesÚlineÚmicrophone_linesÚmicrophone_names        r'   r<   r<     sÃ   € ò K€Gð	aÜ#Ÿš¨°dÄ:Ç?Á?Ð]dÑeˆØ-;×-BÑ-B×-MÑ-MÔ-OÓeÒ-O TÐS\Ð`dÑSdŸDÑ-OÐÐeæØ.¨qÑ1×7Ñ7¸Ó<¸QÑ?ˆOÜÐ& Ð&7Ð8Ô9Ø˜OÐ,Ð-Ð-ð ð ùò føô ó aÜÐ_Õ`àðaús*   †AB Á
BÁBÁ2B ÂB ÂB-Â,B-)r   NN)NNr   NN)F)rU   r:   r   Únumpyr   Úbytesr>   Úndarrayr(   rT   ÚstrÚlistrF   Útupler`   ÚboolrX   r@   r<   © rb   r'   Ú<module>rƒ      s>  ðã Û Û ã ð$˜%ð $°ð $¸¿
¹
ô $ðT ")Ø&*Ø/3ñQØðQàðQð ðQð ˜t™ð	Qð
 ! ™I¨Ñ,õQðn "&Ø:>Ø!(Ø&*Ø/3ñ\Øð\àð\ð ˜$‘Jð\ð ˜5 %˜<Ñ(¨5Ñ0°4Ñ7ð	\ð
 ð\ð ˜t™ð\ð ! ™I¨Ñ,õ\ñ~ ¨#ð  °u¸SÀ#¸X±ð  ÐPTõ  ðFp¨3ô pó rb   