
    Sܶi                     x   d dl Z d dlZd dlZd dlZd dlZd dlmZmZmZ d dl	Z	d dl
m
Z
 ddlmZmZmZ ddlmZmZmZmZ ddlmZmZ ddlmZ dd	lmZ d
ddddddddddddddZdddddddddd d!d!d"d"dZd#ed$ed%ed&eeef         fd'Zd&ee         fd(Z 	 	 	 d.d*ed+eeee	j!        f                  d,ed%ed&ef
d-Z"dS )/    N)ListOptionalUnion)tqdm   )
load_audiolog_mel_spectrogrampad_or_trim)DecodingOptionsDecodingResultdecodedetect_language)ModelDimensionsWhisper)
transcribe)__version__zhttps://openaipublic.azureedge.net/main/whisper/models/d3dd57d32accea0b295c96e26691aa14d8822fac7d9d27d5dc00b4ca2826dd03/tiny.en.ptzhttps://openaipublic.azureedge.net/main/whisper/models/65147644a518d12f04e32d6f3b26facc3f8dd46e5390956a9424a650c0ce22b9/tiny.ptzhttps://openaipublic.azureedge.net/main/whisper/models/25a8566e1d0c1e2231d1c762132cd20e0f96a85d16145c3a00adf5d1ac670ead/base.en.ptzhttps://openaipublic.azureedge.net/main/whisper/models/ed3a0b6b1c0edf879ad9b11b1af5a0e6ab5db9205f891f668f8b0e6c6326e34e/base.ptzhttps://openaipublic.azureedge.net/main/whisper/models/f953ad0fd29cacd07d5a9eda5624af0f6bcf2258be67c92b79389873d91e0872/small.en.ptzhttps://openaipublic.azureedge.net/main/whisper/models/9ecf779972d90ba49c06d968637d720dd632c55bbf19d441fb42bf17a411e794/small.ptzhttps://openaipublic.azureedge.net/main/whisper/models/d7440d1dc186f76616474e0ff0b3b6b879abc9d1a4926b7adfa41db2d497ab4f/medium.en.ptzhttps://openaipublic.azureedge.net/main/whisper/models/345ae4da62f9b3d59415adc60127b97c714f32e89e936602e85993674d08dcb1/medium.ptzhttps://openaipublic.azureedge.net/main/whisper/models/e4b87e7e0bf463eb8e6956e646f1e277e901512310def2c24bf0e11bd3c28e9a/large-v1.ptzhttps://openaipublic.azureedge.net/main/whisper/models/81f7c96c852ee8fc832187b0132e569d6c3065a3252ed18e56effd0b6a73e524/large-v2.ptzhttps://openaipublic.azureedge.net/main/whisper/models/e5b1a55b89c1367dacf97e3e19bfd829a01529dbfdeefa8caeb59b3f1b81dadb/large-v3.ptzhttps://openaipublic.azureedge.net/main/whisper/models/aff26ae408abcba5fbf8813c21e62b0941638c5f6eebfb145be0c9839262a19a/large-v3-turbo.pt)ztiny.entinyzbase.enbasezsmall.ensmallz	medium.enmediumzlarge-v1zlarge-v2zlarge-v3largezlarge-v3-turboturbos%   ABzY8J1N>@0{>%R00Bk>$p{7v037`oCl~+#00s#   ABzY8bu8Lr0{>%RKn9Fp%m@SkK7Kt=7ytkOs%   ABzY8;40c<0{>%RzzG;p*o+Vo09|#PsxSZm00s(   ABzY8KQ!870{>%RzyTQH3`Q^yNP!>##QT-<FaQ7ms4   ABzY8>?_)10{>%RpeA61k&I|OI3I$65C{;;pbCHh0B{qLQ;+}v00s1   ABzY8DmU6=0{>%Rpa?J`kvJ6qF(V^F86#Xh7JUGMK}P<N0000s>   ABzY8usPae0{>%R7<zz_OvQ{)4kMa0BMw6u5rT}kRKX;$NfYBv00*Hl@qhsU00s,   ABzY8B0Jh+0{>%R7}kK1fFL7w6%<-Pf*t^=N)Qr&0RR9s2   ABzY8r9j$a0{>%R7#4sLmoOs{s)o3~84-RPdcFk!JR<kSfC2yjsK   ABzY8zd+h!0{>%R7=D0pU<_bnWW*tkYAhobTNnu$jnkEkXqp)j;w1Tzk)UH3X%SZd&fFZ2fC2yjs9   ABzY8gWO1E0{>%R7(9S+Kn!D~%ngiGaR?*L!iJG9p-nab0JQ=-{D1-g00s(   ABzY8j^C+e0{>%RARaKHP%t(lGR*)0g!tONPyhe`urlroot	in_memoryreturnc           	         t          j        |d           |                     d          d         }t           j                            |t           j                            |                     }t           j                            |          r1t           j                            |          st          | d          t           j                            |          rt          |d          5 }|
                                }d d d            n# 1 swxY w Y   t          j        |                                          |k    r|r|n|S t          j        | d           t           j                            |           5 }t          |d          5 }t'          t)          |                                                    d	                    d
ddd          5 }		 |
                    d          }
|
sn8|                    |
           |	                    t3          |
                     P	 d d d            n# 1 swxY w Y   d d d            n# 1 swxY w Y   d d d            n# 1 swxY w Y   t          |d          
                                }t          j        |                                          |k    rt          d          |r|n|S )NT)exist_ok/z! exists and is not a regular filerbzH exists, but the SHA256 checksum does not match; re-downloading the filewbzContent-LengthP   iBi   )totalncolsunit
unit_scaleunit_divisori    zeModel has been downloaded but the SHA256 checksum does not not match. Please retry loading the model.)osmakedirssplitpathjoinbasenameexistsisfileRuntimeErroropenreadhashlibsha256	hexdigestwarningswarnurllibrequesturlopenr   intinfogetwriteupdatelen)r   r   r   expected_sha256download_targetfmodel_bytessourceoutputloopbuffers              S/root/projects/openclaw-proxy/venv/lib/python3.11/site-packages/whisper/__init__.py	_downloadrL   6   s   Kt$$$$iinnR(Ogll4)9)9#)>)>??O	w~~o&& Rrw~~o/N/N RoPPPQQQ	w~~o&& /4(( 	#A&&((K	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	#>+&&0022oEE"+@;;@M"lll   
			$	$ )_d0K0K )vfkkmm''(899::
 
 
 	) )T** V$$$CKK((() 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	)) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) )  --2244K~k"",,../AAs
 
 	
 $8;;8sn   .DDD I%AIAH7+I7H;;I>H;?II%I	I%I	I%%I),I)c                  N    t          t                                                    S )z%Returns the names of available models)list_MODELSkeys     rK   available_modelsrS   b   s    rR   Fnamedevicedownload_rootc                    |"t           j                                        rdnd}|pt          j                            t          j                            d          d          }t          j                            t          j        d|          d          }| t          v r*t          t          |          ||          }t          |          }nit          j                            |           r)|r"t          | d                                          n| }d}n!t          d	|  d
t                                 |rt!          j        |          nt          |d          5 }t           j        dk    rddini }t          j        |fd|i|}	ddd           n# 1 swxY w Y   ~t)          di |	d         }
t+          |
          }|                    |	d                    ||                    |           |                    |          S )ae  
    Load a Whisper ASR model

    Parameters
    ----------
    name : str
        one of the official model names listed by `whisper.available_models()`, or
        path to a model checkpoint containing the model dimensions and the model state_dict.
    device : Union[str, torch.device]
        the PyTorch device to put the model into
    download_root: str
        path to download the model files; by default, it uses "~/.cache/whisper"
    in_memory: bool
        whether to preload the model weights into host memory

    Returns
    -------
    model : Whisper
        The Whisper ASR model instance
    Ncudacpu~z.cacheXDG_CACHE_HOMEwhisperr!   zModel z not found; available models = z1.13weights_onlyTmap_locationdimsmodel_state_dictrQ   )torchrX   is_availabler*   r-   r.   
expandusergetenvrO   rL   _ALIGNMENT_HEADSr1   r3   r4   r2   rS   ioBytesIOr   loadr   r   load_state_dictset_alignment_headsto)rT   rU   rV   r   defaultcheckpoint_filealignment_headsfpkwargs
checkpointr_   models               rK   
load_modelrs   g   s9   6 ~ :2244?%',,rw11#66AARY/?%I%I9UUw#GDM=)LL*40			 
5>H$tT**//111DNTNN:J:L:LNN
 
 	

 (1Q
?###d?D6Q6QC	+0+<+F+F.$''BZBBB6BB
	C C C C C C C C C C C C C C C
 	00Z/00DDMME	*%78999"!!/22288Fs   +FFF)NNF)#r5   rf   r*   r:   r8   typingr   r   r   ra   r   audior   r	   r
   decodingr   r   r   r   rr   r   r   r   versionr   rO   re   strboolbytesrL   rS   rU   rs   rQ   rR   rK   <module>r{      sH    				 				   ( ( ( ( ( ( ( ( ( (        ? ? ? ? ? ? ? ? ? ? N N N N N N N N N N N N + + + + + + + + " " " " " "             T N T N V P X R V V V S b Y ( 8277GAR=E^LIA8  $)93 )9c )9d )9uUCZ7H )9 )9 )9 )9X $s)         26	: :
:U3,-.: : 	:
 : : : : : :rR   