+
    ªÏjQ  ã                   ó2  € ^ RI t ^ RIHt ^ RIHtHt ^ RIHtHt ^ RI	t
^ RIt^ RIHu Ht ^RIHt RtRt^ t^t]],          t]! ]]4      t]^,          t]! ]]4      t]! ]]4      t]3R R	 llt]3R
R/R R lllt]! RR7      R R l4       tRR R lltR# )é    N)Ú	lru_cache)ÚCalledProcessErrorÚrun)ÚOptionalÚUnion)Ú	exact_divi€>  i�  c                ó0   € V ^8„  d   QhR\         R\        /# )é   ÚfileÚsr)ÚstrÚint)Úformats   "ÚC/opt/data/home/.local/lib/python3.14/site-packages/whisper/audio.pyÚ__annotate__r      s   € ÷ %Oñ %O”Sð %Oœcñ %Oó    c                óŠ  € RRRRRV RRRR	R
RR\        V4      R.p \        VRRR7      P                  p\        P                  ! T\        P                  4      P                  4       P                  \        P                  4      R,          #   \         d-   p\	        RTP
                  P                  4        24      ThRp?ii ; i)a  
Open an audio file and read as mono waveform, resampling as necessary

Parameters
----------
file: str
    The audio file to open

sr: int
    The sample rate to resample the audio if necessary

Returns
-------
A NumPy array containing the audio waveform, in float32 dtype.
Úffmpegz-nostdinz-threadsÚ0z-iz-fÚs16lez-acÚ1z-acodecÚ	pcm_s16lez-arÚ-T)Úcapture_outputÚcheckzFailed to load audio: Ng      à@)r   r   Ústdoutr   ÚRuntimeErrorÚstderrÚdecodeÚnpÚ
frombufferÚint16ÚflattenÚastypeÚfloat32)r   r   ÚcmdÚoutÚes   &&   r   Ú
load_audior)      s¹   € ð* 	ØØ�CØˆdØˆgØˆsØ�;ØŒs�2‹wØð
€CðPÜ�# d°$Ô7×>Ñ>ˆô �=Š=˜œbŸh™hÓ'×/Ñ/Ó1×8Ñ8¼¿¹ÓDÀwÕNÐNøô ô PÜÐ3°A·H±H·O±OÓ4EÐ3FÐGÓHÈaÐOûðPús   œB ÂCÂ'B=Â=CÚaxisc                ó0   € V ^8„  d   QhR\         R\         /# )r
   Úlengthr*   )r   )r   s   "r   r   r   A   s   € ÷ ñ œsð ¼ñ r   c          	     ó  € \         P                  ! V 4      '       dÏ   V P                  V,          V8”  d3   V P                  V\         P                  ! WP
                  R7      R7      p V P                  V,          V8  dk   R.V P                  ,          p^ WP                  V,          ,
          3W2&   \        P                  ! YRRR1,           UUu. uF  qD F  qUNK  	  K  	  upp4      p V # V P                  V,          V8”  d   V P                  \        V4      VR7      p V P                  V,          V8  dH   R.V P                  ,          p^ WP                  V,          ,
          3W2&   \        P                  ! W4      p V # u uppi )zG
Pad or trim the audio array to N_SAMPLES, as expected by the encoder.
)Údevice)ÚdimÚindexN)Úindicesr*   )r   r   éÿÿÿÿ)ÚtorchÚ	is_tensorÚshapeÚindex_selectÚaranger.   ÚndimÚFÚpadÚtakeÚranger    )Úarrayr,   r*   Ú
pad_widthsÚsizesr:   s   &&$   r   Úpad_or_trimr@   A   s:  € ô ‡‚�u×ÒØ�;‰;�tÕ˜vÔ%Ø×&Ñ&Ø¤§¢¨V¿L¹LÔ Ið 'ó ˆEð �;‰;�tÕ˜vÔ%Ø ˜ E§J¡JÕ.ˆJØ ! 6¯K©K¸Õ,=Õ#=Ð>ˆJÑÜ—E’E˜%¹dÀ¸dÖ3CÔ!UÑ3C¨%ÊuÈ¢#Éu¡#Ñ3CÒ!UÓVˆEð €Lð �;‰;�tÕ˜vÔ%Ø—J‘J¤u¨V£}¸4�JÓ@ˆEà�;‰;�tÕ˜vÔ%Ø ˜ E§J¡JÕ.ˆJØ ! 6¯K©K¸Õ,=Õ#=Ð>ˆJÑÜ—F’F˜5Ó-ˆEà€Lùó "Vs   ÃF )Úmaxsizec                óD   € V ^8„  d   QhR\         R\        P                  /# )r
   Ún_melsÚreturn)r   r3   ÚTensor)r   s   "r   r   r   \   s   € ÷ ?ñ ?¤ð ?¬¯©ñ ?r   c                ó„  € VR9   g   Q RV 24       h\         P                  P                  \         P                  P                  \        4      RR4      p\
        P                  ! VRR7      ;_uu_ 4       p\        P                  ! VRV 2,          4      P                  V 4      uuRRR4       #   + '       g   i     R# ; i)	aD  
load the mel filterbank matrix for projecting STFT into a Mel spectrogram.
Allows decoupling librosa dependency; saved using:

    np.savez_compressed(
        "mel_filters.npz",
        mel_80=librosa.filters.mel(sr=16000, n_fft=400, n_mels=80),
        mel_128=librosa.filters.mel(sr=16000, n_fft=400, n_mels=128),
    )
zUnsupported n_mels: Úassetszmel_filters.npzF)Úallow_pickleÚmel_N>   éP   é€   )
ÚosÚpathÚjoinÚdirnameÚ__file__r    Úloadr3   Ú
from_numpyÚto)r.   rC   Úfilters_pathÚfs   &&  r   Úmel_filtersrV   [   s‰   € ð �YÔÐ?Ð"6°v°hÐ ?Ó?Ðä—7‘7—<‘<¤§¡§¡´Ó 9¸8ÐEVÓW€LÜ	�Š�¨E×	2Õ	2°aÜ×Ò  D¨¨ /Õ 2Ó3×6Ñ6°vÓ>÷ 
3×	2×	2Ó	2ús   Á4/B.Â.B?	c                óè   € V ^8„  d   QhR\         \        \        P                  \        P
                  3,          R\        R\        R\        \         \        \        P                  3,          ,          /# )r
   ÚaudiorC   Úpaddingr.   )	r   r   r    Úndarrayr3   rE   r   r   r.   )r   s   "r   r   r   n   sW   € ÷ /ñ /Ü””b—j‘j¤%§,¡,Ð.Õ/ð/äð/ô ð/ô ”Uœ3¤§¡Ð,Õ-Õ.ñ	/r   c                ó  € \         P                  ! V 4      '       g8   \        V \        4      '       d   \	        V 4      p \         P
                  ! V 4      p Ve   V P                  V4      p V^ 8”  d   \        P                  ! V ^ V34      p \         P                  ! \        4      P                  V P                  4      p\         P                  ! V \        \        VRR7      pVRRR	13,          P                  4       ^,          p\        V P                  V4      pWv,          p\         P                   ! VRR7      P#                  4       p	\         P$                  ! W™P'                  4       R,
          4      p	V	R,           R,          p	V	# )
a=  
Compute the log-Mel spectrogram of

Parameters
----------
audio: Union[str, np.ndarray, torch.Tensor], shape = (*)
    The path to audio or either a NumPy array or Tensor containing the audio waveform in 16 kHz

n_mels: int
    The number of Mel-frequency filters, only 80 and 128 are supported

padding: int
    Number of zero samples to pad to the right

device: Optional[Union[str, torch.device]]
    If given, the audio tensor is moved to this device before STFT

Returns
-------
torch.Tensor, shape = (n_mels, n_frames)
    A Tensor that contains the Mel spectrogram
NT)ÚwindowÚreturn_complex.g»½×Ùß|Û=)Úming       @g      @r2   )r3   r4   Ú
isinstancer   r)   rR   rS   r9   r:   Úhann_windowÚN_FFTr.   ÚstftÚ
HOP_LENGTHÚabsrV   ÚclampÚlog10ÚmaximumÚmax)
rX   rC   rY   r.   r\   rb   Ú
magnitudesÚfiltersÚmel_specÚlog_specs
   &&&&      r   Úlog_mel_spectrogramrm   n   s  € ô8 �?Š?˜5×!Ò!Ü�eœS×!Ò!Ü˜uÓ%ˆEÜ× Ò  Ó'ˆàÒØ—‘˜Ó ˆØ�„{Ü—’�e˜a ˜\Ó*ˆÜ×ÒœuÓ%×(Ñ(¨¯©Ó6€FÜ�:Š:�eœU¤J°vÈdÔS€DØ�c˜3˜B˜3�h•×#Ñ#Ó%¨Õ*€Jä˜%Ÿ,™,¨Ó/€GØÕ#€Hä�{Š{˜8¨Ô/×5Ñ5Ó7€HÜ�}Š}˜X§|¡|£~¸Õ';Ó<€HØ˜3• #Õ%€HØ€Or   r2   )rJ   r   N)rL   Ú	functoolsr   Ú
subprocessr   r   Útypingr   r   Únumpyr    r3   Útorch.nn.functionalÚnnÚ
functionalr9   Úutilsr   ÚSAMPLE_RATEra   rc   ÚCHUNK_LENGTHÚ	N_SAMPLESÚN_FRAMESÚN_SAMPLES_PER_TOKENÚFRAMES_PER_SECONDÚTOKENS_PER_SECONDr)   r@   rV   rm   © r   r   Ú<module>r~      s¶   ðÛ 	Ý ß .ß "ã Û ß Ð å ð €Ø€Ø€
Ø€Ø˜;Õ&€	Ù�Y 
Ó+€à  1•nÐ Ù˜k¨:Ó6Ð Ù˜kÐ+>Ó?Ð ð %0÷ %OðP &/ñ ¸r÷ ð ñ4 �4Ôô?ó ð?÷$/ñ /r   