§
    |@Äjžv  ã                    ó  — 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mZm	Z	 d dl
Zd dlZd dlZddlmZmZmZ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mZmZ ddlm Z m!Z!m"Z"m#Z#m$Z$m%Z%m&Z&m'Z' erdd	l(m)Z) dd
ddddddddddddœddde	e*ej+        ej,        f         dee-         de	e.ee.df         f         dee.         dee.         dee.         de-dee*         de-d e-d!e*d"e*d#e	e*ee.         f         d$ee.         fd%„Z/d&„ Z0e1d'k    r e0¦   «          dS dS )(é    N)ÚTYPE_CHECKINGÚListÚOptionalÚTupleÚUnioné   )ÚFRAMES_PER_SECONDÚ
HOP_LENGTHÚN_FRAMESÚ	N_SAMPLESÚSAMPLE_RATEÚlog_mel_spectrogramÚpad_or_trim)ÚDecodingOptionsÚDecodingResult)Úadd_word_timestamps)Ú	LANGUAGESÚTO_LANGUAGE_CODEÚget_tokenizer)Ú	exact_divÚformat_timestampÚget_endÚ
get_writerÚ	make_safeÚoptional_floatÚoptional_intÚstr2bool)ÚWhisper)ç        çš™™™™™É?gš™™™™™Ù?ç333333ã?gš™™™™™é?ç      ð?ç333333@ç      ð¿r!   TFõ   "'â€œÂ¿([{-õ   "'.ã€‚,ï¼Œ!ï¼�?ï¼Ÿ:ï¼šâ€�)]}ã€�Ú0)ÚverboseÚtemperatureÚcompression_ratio_thresholdÚlogprob_thresholdÚno_speech_thresholdÚcondition_on_previous_textÚinitial_promptÚcarry_initial_promptÚword_timestampsÚprepend_punctuationsÚappend_punctuationsÚclip_timestampsÚhallucination_silence_thresholdÚmodelr   Úaudior(   r)   .r*   r+   r,   r-   r.   r/   r0   r1   r2   r3   r4   c                óD  ‡ ‡‡‡‡‡‡S‡T‡U‡V— ‰                      dd¦  «        rt          j        nt          j        }‰ j        t          j        d¦  «        k    rbt          j                             ¦   «         rt          j        d¦  «         |t          j        k    r t          j        d¦  «         t          j        }|t          j        k    rd‰d<   t          |‰ j
        j        t          ¬¦  «        }|j        d         t          z
  }t          |t           z  t"          z  ¦  «        }‰                      d	d
¦  «        €Æ‰ j        sd‰d	<   n¹|rt'          d¦  «         t)          |t          ¦  «                             ‰ j        ¦  «                             |¦  «        }‰                      |¦  «        \  }}t/          ||j         ¬¦  «        ‰d	<   |�5t'          dt0          ‰d	                                       ¦   «         › �¦  «         ‰d	         }‰                      dd¦  «        }t5          ‰ j        ‰ j        ||¬¦  «        ŠUt9          |t:          ¦  «        r#d„ |r|                     d¦  «        ng D ¦   «         }d„ |D ¦   «         }t?          |¦  «        dk    r|                      d¦  «         t?          |¦  «        dz  dk    r|                      |¦  «         tC          tE          |d
d
d…         |dd
d…         ¦  «        ¦  «        }dŠS|
r|dk    rt          j        d¦  «         dt          j#        dtH          fˆˆˆˆ ˆˆfd„}d}||         d         ŠTtK          t          ‰ j
        j&        ¦  «        }|t           z  t"          z  }g }g } d}!‰ j
        j'        dz  dz
  }"|�R‰U (                    d| )                    ¦   «         z   ¦  «        }#| *                    |#¦  «         |"t?          |#¦  «        z  }"ng }#dt          d t          d!t          j#        d"tH          fˆTˆUfd#„}$tW          j+        |d$|du¬%¦  «        5 }%d&}&|t?          |¦  «        k     �r�||         \  }'}(‰T|'k     r|'ŠT‰T|(k    r'|dz  }|t?          |¦  «        k     r||         d         ŠTŒTt          ‰Tt           z  t"          z  ¦  «        })t          ‰Tt          z   t           z  t"          z  ¦  «        }*tY          t          |‰Tz
  |(‰Tz
  ¦  «        }+|d
d
…‰T‰T|+z   …f         }|+t           z  t"          z  },t)          |t          ¦  «                             ‰ j        ¦  «                             |¦  «        }|	r9t/          t?          |#¦  «        |!¦  «        }-||-d
…         |" d
…         }.|#|.z   ‰d'<   n||!d
…         ‰d'<    ||¦  «        }/t          j-        |/j.        ¦  «        }0‰�#|/j/        ‰k    }1‰�|/j0        ‰k    rd}1|1r‰T|+z  ŠT�Œª‰T}2g }3d(tb          dt          fd)„ŠVdtd          tb                   dtf          fˆSˆVfd*„}4d+th          tb                   dtd          tb                   fd,„}5|0 5                    ‰Uj6        ¦  «        }6|6d-d
…          7                    ¦   «         ddgk    }7t          j8        |6d
d…         |6dd
…         z  ¦  «        d         }8|8 9                    d¦  «         t?          |8¦  «        dk    ró|8 7                    ¦   «         }9|7r"|9                      t?          |0¦  «        ¦  «         d}:|9D ]€};|0|:|;…         }<|<d          :                    ¦   «         ‰Uj6        z
  }=|<d          :                    ¦   «         ‰Uj6        z
  }>|3                       |$|)|=|z  z   |)|>|z  z   |<|/¬.¦  «        ¦  «         |;}:Œ�|7r‰T|+z  ŠTnã|0|:dz
            :                    ¦   «         ‰Uj6        z
  }?‰T|?|z  z  ŠTnµ|,}@|0|6 ;                    ¦   «          <                    ¦   «                  }At?          |A¦  «        dk    rJ|Ad          :                    ¦   «         ‰Uj6        k    r'|Ad          :                    ¦   «         ‰Uj6        z
  }?|?|z  }@|3                       |$|)|)|@z   |0|/¬.¦  «        ¦  «         ‰T|+z  ŠT|
�rût{          |3‰ ‰U||+|||&¬/¦  «         |7s.t}          |3¦  «        }B|B�|B|)k    rt          |Bt€          z  ¦  «        ŠT|��ž|}C|7s?t}          |3¦  «        }B|B�.|B|)k    r(|*|Bz
  }D|D|Ck    rt          |Bt€          z  ¦  «        ŠTn|2|+z   ŠT |5|3¦  «        }E|E�8 |4|E¦  «        r-|Ed         |)z
  }F|F|Ck    r|2t          |Ft€          z  ¦  «        z   ŠT�Œ|&}Gtƒ          t?          |3¦  «        ¦  «        D ]÷}H|3|H         }I|Id0         sŒ |4|I¦  «        rÑ |5|3|Hdz   d
…         ¦  «        }J|J�|Jd0         d         d         }Kn|)|,z   }K|Id         |Gz
  |Ck    p|Id         |Ck     p|Id         |)z
  d1k     }L|K|Id          z
  |Ck    p |4|J¦  «        p|*|Id          z
  d1k     }M|LrJ|MrHt          t/          |)dz   |Id         ¦  «        t€          z  ¦  «        ŠT||Id          z
  |Ck     r|ŠTg |3|Hd
…<    n	|Id          }GŒøt}          |3¦  «        }B|B�|B}&|r^|3D ][}I|Id         |Id          |Id2         }P}O}Nd3t…          |N¦  «        › d4t…          |O¦  «        › d5|P› �}Qt'          t‡          |Q¦  «        ¦  «         Œ\t‰          |3¦  «        D ]D\  }R}I|Id         |Id          k    s|Id2          )                    ¦   «         d6k    rd6|Id2<   g |Id!<   g |Id0<   ŒE|  *                    d7„ t‰          |3t?          | ¦  «        ¬8¦  «        D ¦   «         ¦  «         | *                    d9„ |3D ¦   «         ¦  «         |r|/jE        d:k    rt?          |¦  «        }!|% F                    tY          |‰T¦  «        |2z
  ¦  «         |t?          |¦  «        k     �°�d
d
d
¦  «         n# 1 swxY w Y   tc          ‰U G                    |t?          |#¦  «        d
…         ¦  «        | |¬;¦  «        S )<a‚  
    Transcribe an audio file using Whisper

    Parameters
    ----------
    model: Whisper
        The Whisper model instance

    audio: Union[str, np.ndarray, torch.Tensor]
        The path to the audio file to open, or the audio waveform

    verbose: bool
        Whether to display the text being decoded to the console. If True, displays all the details,
        If False, displays minimal details. If None, does not display anything

    temperature: Union[float, Tuple[float, ...]]
        Temperature for sampling. It can be a tuple of temperatures, which will be successively used
        upon failures according to either `compression_ratio_threshold` or `logprob_threshold`.

    compression_ratio_threshold: float
        If the gzip compression ratio is above this value, treat as failed

    logprob_threshold: float
        If the average log probability over sampled tokens is below this value, treat as failed

    no_speech_threshold: float
        If the no_speech probability is higher than this value AND the average log probability
        over sampled tokens is below `logprob_threshold`, consider the segment as silent

    condition_on_previous_text: bool
        if True, the previous output of the model is provided as a prompt for the next window;
        disabling may make the text inconsistent across windows, but the model becomes less prone to
        getting stuck in a failure loop, such as repetition looping or timestamps going out of sync.

    word_timestamps: bool
        Extract word-level timestamps using the cross-attention pattern and dynamic time warping,
        and include the timestamps for each word in each segment.

    prepend_punctuations: str
        If word_timestamps is True, merge these punctuation symbols with the next word

    append_punctuations: str
        If word_timestamps is True, merge these punctuation symbols with the previous word

    initial_prompt: Optional[str]
        Optional text to provide as a prompt for the first window. This can be used to provide, or
        "prompt-engineer" a context for transcription, e.g. custom vocabularies or proper nouns
        to make it more likely to predict those word correctly.

    carry_initial_prompt: bool
        If carry_initial_prompt is True, `initial_prompt` is prepended to the prompt of each internal
        `decode()` call. If there is not enough context space at the start of the prompt, it is
        left-sliced to make space.

    decode_options: dict
        Keyword arguments to construct `DecodingOptions` instances

    clip_timestamps: Union[str, List[float]]
        Comma-separated list start,end,start,end,... timestamps (in seconds) of clips to process.
        The last end timestamp defaults to the end of the file.

    hallucination_silence_threshold: Optional[float]
        When word_timestamps is True, skip silent periods longer than this threshold (in seconds)
        when a possible hallucination is detected

    Returns
    -------
    A dictionary containing the resulting text ("text") and segment-level details ("segments"), and
    the spoken language ("language"), which is detected when `decode_options["language"]` is None.
    Úfp16TÚcpuz2Performing inference on CPU when CUDA is availablez0FP16 is not supported on CPU; using FP32 insteadF)ÚpaddingéÿÿÿÿÚlanguageNÚenz]Detecting language using up to the first 30 seconds. Use `--language` to specify the language)ÚkeyzDetected language: ÚtaskÚ
transcribe)Únum_languagesr<   r?   c                 ó,   — g | ]}t          |¦  «        ‘ŒS © )Úfloat©Ú.0Útss     úCC:\Projects\Historical\venv\Lib\site-packages\whisper/transcribe.pyú
<listcomp>ztranscribe.<locals>.<listcomp>©   s+   € ð 
ð 
ð 
Ø�E�"‰IŒIð
ð 
ð 
ó    ú,c                 ó<   — g | ]}t          |t          z  ¦  «        ‘ŒS rC   )Úroundr	   rE   s     rH   rI   ztranscribe.<locals>.<listcomp>¬   s&   € ÐVÐVÐVÀ�e BÕ):Ñ$:Ñ;Ô;ÐVÐVÐVrJ   r   é   r   u*   "'â€œÂ¿([{-"'.ã€‚,ï¼Œ!ï¼�?ï¼Ÿ:ï¼šâ€�)]}ã€�Ú	translatez:Word-level timestamps on translations may not be reliable.ÚsegmentÚreturnc                 ó¾  •— t          ‰t          t          f¦  «        r‰gn‰}d }|D ]µ}i ‰¥}|dk    r-|                     dd ¦  «         |                     dd ¦  «         n|                     dd ¦  «         t	          di |¤d|i¤Ž}‰
                     | |¦  «        }d}‰�|j        ‰k    rd}‰	�|j        ‰	k     rd}‰�|j        ‰k    r‰	�|j        ‰	k     rd}|s nŒ¶|S )	Nr   Ú	beam_sizeÚpatienceÚbest_ofr)   FTrC   )	Ú
isinstanceÚintrD   Úpopr   ÚdecodeÚcompression_ratioÚavg_logprobÚno_speech_prob)rP   ÚtemperaturesÚdecode_resultÚtÚkwargsÚoptionsÚneeds_fallbackr*   Údecode_optionsr+   r5   r,   r)   s          €€€€€€rH   Údecode_with_fallbackz(transcribe.<locals>.decode_with_fallback¸   sA  ø€ å'¨µc½5°\ÑBÔBÐSˆ[ˆMˆMÈð 	ð ˆàð  	ð  	ˆAØ'˜Ð'ˆFØ�1Šuˆuà—
’
˜;¨Ñ-Ô-Ð-Ø—
’
˜: tÑ,Ô,Ð,Ð,ð —
’
˜9 dÑ+Ô+Ð+å%Ð>Ð>¨Ð>Ð>¸AÐ>Ð>Ð>ˆGØ!ŸLšL¨°'Ñ:Ô:ˆMà"ˆNà+Ð7Ø!Ô3Ð6QÒQÐQà!%�à!Ð-Ø!Ô-Ð0AÒAÐAà!%�à#Ð/Ø!Ô0Ð3FÒFÐFØ%Ð1Ø!Ô-Ð0AÒAÐAà!&�Ø!ð Ø�ðð ÐrJ   ú ÚstartÚendÚtokensÚresultc           
      ó®   •— |                      ¦   «         }ˆfd„|D ¦   «         }‰| |‰                     |¦  «        ||j        |j        |j        |j        dœ	S )Nc                 ó*   •— g | ]}|‰j         k     ¯|‘ŒS rC   )Úeot)rF   ÚtokenÚ	tokenizers     €rH   rI   z3transcribe.<locals>.new_segment.<locals>.<listcomp>ú   s%   ø€ ÐJÐJÐJ °E¸I¼MÒ4IÐ4I�uÐ4IÐ4IÐ4IrJ   )	Úseekrf   rg   Útextrh   r)   r[   rZ   r\   )ÚtolistrY   r)   r[   rZ   r\   )rf   rg   rh   ri   Útext_tokensro   rn   s        €€rH   Únew_segmentztranscribe.<locals>.new_segmentö   so   ø€ ð —’‘”ˆØJÐJÐJÐJ¨&ÐJÑJÔJˆàØØØ×$Ò$ [Ñ1Ô1ØØ!Ô-Ø!Ô-Ø!'Ô!9Ø$Ô3ð

ð 

ð 
	
rJ   Úframes)ÚtotalÚunitÚdisabler   ÚpromptÚwordc                 ó¬   — |                       dd¦  «        }| d         | d         z
  }d}|dk     r|dz  }|dk     r|d|z
  dz  z  }|d	k    r||d	z
  z  }|S )
NÚprobabilityr   rg   rf   g333333Ã?r"   g /Ý$Á?é   ç       @)Úget)ry   r{   ÚdurationÚscores       rH   Úword_anomaly_scorez&transcribe.<locals>.word_anomaly_score<  s{   € Ø"Ÿhšh }°cÑ:Ô:�Ø œ;¨¨g¬Ñ6�Ø�Ø Ò%Ð%Ø˜S‘L�EØ˜eÒ#Ð#Ø˜e hÑ.°"Ñ4Ñ4�EØ˜c’>�>Ø˜X¨™^Ñ+�EØ�rJ   c                 óÆ   •— | �| d         sdS ˆfd„| d         D ¦   «         }|d d…         }t          ˆfd„|D ¦   «         ¦  «        }|dk    p|dz   t          |¦  «        k    S )NÚwordsFc                 ó(   •— g | ]}|d          ‰v¯|‘ŒS )ry   rC   )rF   ÚwÚpunctuations     €rH   rI   z:transcribe.<locals>.is_segment_anomaly.<locals>.<listcomp>K  s'   ø€ ÐUÐUÐU˜q¸¸&¼	ÈÐ8TÐ8T˜Ð8TÐ8TÐ8TrJ   é   c              3   ó.   •K  — | ]} ‰|¦  «        V — Œd S )NrC   )rF   r…   r�   s     €rH   ú	<genexpr>z9transcribe.<locals>.is_segment_anomaly.<locals>.<genexpr>M  s/   øè è € ÐAÐA°aÐ.Ð.¨qÑ1Ô1ÐAÐAÐAÐAÐAÐArJ   é   g{®Gáz„?)ÚsumÚlen)rP   rƒ   r€   r†   r�   s      €€rH   Úis_segment_anomalyz&transcribe.<locals>.is_segment_anomalyH  s�   ø€ Ø�?¨'°'Ô*:�?Ø ˜5ØUÐUÐUÐU G¨GÔ$4ÐUÑUÔU�Ø˜b˜q˜bœ	�ÝÐAÐAÐAÐA¸5ÐAÑAÔAÑAÔA�Ø ’zÐ? U¨T¡\µS¸±Z´ZÒ%?Ð?rJ   Úsegmentsc                 ó6   — t          d„ | D ¦   «         d ¦  «        S )Nc              3   ó*   K  — | ]}|d          ¯
|V — ŒdS )rƒ   NrC   )rF   Úss     rH   r‰   z9transcribe.<locals>.next_words_segment.<locals>.<genexpr>Q  s+   è è € Ð?Ð? 1°A°g´JÐ?˜QÐ?Ð?Ð?Ð?Ð?Ð?rJ   )Únext)rŽ   s    rH   Únext_words_segmentz&transcribe.<locals>.next_words_segmentP  s!   € ÝÐ?Ð?¨Ð?Ñ?Ô?ÀÑFÔFÐFrJ   éþÿÿÿ)rf   rg   rh   ri   )rŽ   r5   rn   ÚmelÚ
num_framesr1   r2   Úlast_speech_timestamprƒ   r}   rp   ú[z --> z] Ú c                 ó    — g | ]\  }}d |i|¥‘ŒS )ÚidrC   )rF   ÚirP   s      rH   rI   ztranscribe.<locals>.<listcomp>ì  s6   € ð ð ð á"˜˜7ð ˜1Ð( Ð(ðð ð rJ   )rf   c                 ó(   — g | ]}|d          D ]}|‘ŒŒS )rh   rC   )rF   rP   rm   s      rH   rI   ztranscribe.<locals>.<listcomp>ô  s*   € ÐVÐVÐV˜7ÀGÈHÔDUÐVÐV¸5�ÐVÐVÐVÐVrJ   g      à?)rp   rŽ   r<   )Hr~   ÚtorchÚfloat16Úfloat32ÚdeviceÚcudaÚis_availableÚwarningsÚwarnr   ÚdimsÚn_melsr   Úshaper   rD   r
   r   Úis_multilingualÚprintr   ÚtoÚdetect_languageÚmaxr   Útitler   rA   rV   ÚstrÚsplitrŒ   ÚappendÚlistÚzipÚTensorr   r   Ún_audio_ctxÚ
n_text_ctxÚencodeÚstripÚextendÚtqdmÚminÚtensorrh   r\   r[   Údictr   Úboolr   ÚgeÚtimestamp_beginrq   ÚwhereÚadd_ÚitemÚnonzeroÚflattenr   r   rM   r	   Úranger   r   Ú	enumerater)   ÚupdaterY   )Wr5   r6   r(   r)   r*   r+   r,   r-   r.   r/   r0   r1   r2   r3   r4   rc   Údtyper•   Úcontent_framesÚcontent_durationÚmel_segmentÚ_Úprobsr<   r?   Úseek_pointsÚ
seek_clipsrd   Úclip_idxÚinput_strideÚtime_precisionÚ
all_tokensÚall_segmentsÚprompt_reset_sinceÚremaining_prompt_lengthÚinitial_prompt_tokensrs   Úpbarr—   Úseek_clip_startÚseek_clip_endÚtime_offsetÚwindow_end_timeÚsegment_sizeÚsegment_durationÚnignoredÚremaining_promptri   rh   Úshould_skipÚprevious_seekÚcurrent_segmentsr�   r“   Útimestamp_tokensÚsingle_timestamp_endingÚconsecutiveÚslicesÚ
last_sliceÚcurrent_sliceÚsliced_tokensÚstart_timestamp_posÚend_timestamp_posÚlast_timestamp_posr   Ú
timestampsÚlast_word_endÚ	thresholdÚremaining_durationÚfirst_segmentÚgapÚhal_last_endÚsirP   Únext_segmentÚhal_next_startÚsilence_beforeÚsilence_afterrf   rg   rp   Úlinerœ   r†   ro   rn   r�   sW   `  ````        `                                                                   @@@@rH   r@   r@   &   s   øøøøøøøøøø€ ðr ,×/Ò/°¸Ñ=Ô=ÐP�EŒMˆMÅ5Ä=€EØ„|•u”| EÑ*Ô*Ò*Ð*ÝŒ:×"Ò"Ñ$Ô$ð 	PÝŒMÐNÑOÔOÐOØ•E”MÒ!Ð!ÝŒMÐLÑMÔMÐMÝ”MˆEà•”ÒÐØ!&ˆ�vÑõ ˜e U¤ZÔ%6Å	Ð
JÑ
JÔ
J€CØ”Y˜r”]¥XÑ-€NÝ˜^­jÑ8½;ÑFÑGÔGÐà×Ò˜* dÑ+Ô+Ð3ØÔ$ð 	Ø)-ˆN˜:Ñ&Ð&àð ÝØsñô ð õ & c­8Ñ4Ô4×7Ò7¸¼ÑEÔE×HÒHÈÑOÔOˆKØ×,Ò,¨[Ñ9Ô9‰HˆAˆuÝ),¨U¸¼	Ð)BÑ)BÔ)BˆN˜:Ñ&ØÐ"ÝØY­)°NÀ:Ô4NÔ*O×*UÒ*UÑ*WÔ*WÐYÐYñô ð ð # :Ô.€HØ×"Ò" 6¨<Ñ8Ô8€DÝØÔØÔ)ØØð	ñ ô €Iõ �/¥3Ñ'Ô'ð 
ð
ð 
Ø?NÐ!V ×!6Ò!6°sÑ!;Ô!;Ð!;ÐTVð
ñ 
ô 
ˆð WÐVÀoÐVÑVÔV€KÝ
ˆ;ÑÔ˜1ÒÐØ×Ò˜1ÑÔÐÝ
ˆ;ÑÔ˜!Ñ˜qÒ Ð Ø×Ò˜>Ñ*Ô*Ð*Ý(,­S°¸S¸S¸q¸SÔ1AÀ;ÈqÈtÐRSÈtÔCTÑ-UÔ-UÑ(VÔ(V€Jà@€Kàð T˜4 ;Ò.Ð.ÝŒÐRÑSÔSÐSð(¥e¤lð (µ~ð (ð (ð (ð (ð (ð (ð (ð (ð (ð (ð (ðT €HØ�hÔ Ô"€DÝÝ�%”*Ô(ñô €Lð 	•zÑ!¥KÑ/ð ð €JØ€LØÐà#œjÔ3°qÑ8¸1Ñ<ÐØÐ!Ø )× 0Ò 0°°~×7KÒ7KÑ7MÔ7MÑ1MÑ NÔ NÐØ×ÒÐ/Ñ0Ô0Ð0Ø¥3Ð'<Ñ#=Ô#=Ñ=ÐÐà "Ðð
Ýð
Ý#ð
Ý-2¬\ð
ÝCQð
ð 
ð 
ð 
ð 
ð 
ð 
õ$ 
ŒØ 8°WÀEÐ5Ið
ñ 
ô 
ð tCà	Ø #Ðð
 �˜Z™œÒ(Ñ(Ø-7¸Ô-AÑ*ˆO˜]Ø�oÒ%Ð%Ø&�Ø�}Ò$Ð$Ø˜A‘�Ø�c *™oœoÒ-Ð-Ø% hÔ/°Ô2�DØÝ ¥zÑ 1µKÑ ?Ñ@Ô@ˆKÝ# T­H¡_½
Ñ$BÅ[Ñ$PÑQÔQˆOÝ�x¨¸$Ñ)>ÀÐPTÑ@TÑUÔUˆLØ˜a˜a˜a ¨¨|Ñ(;Ð!;Ð;Ô<ˆKØ+­jÑ8½;ÑFÐÝ% kµ8Ñ<Ô<×?Ò?ÀÄÑMÔM×PÒPÐQVÑWÔWˆKà#ð KÝ�sÐ#8Ñ9Ô9Ð;MÑNÔN�Ø#-¨h¨i¨iÔ#8Ð:QÐ9QÐ9RÐ9RÔ#SÐ Ø+@ÐCSÑ+S�˜xÑ(Ð(à+5Ð6HÐ6IÐ6IÔ+J�˜xÑ(à%9Ð%9¸+Ñ%FÔ%FˆFÝ”\ &¤-Ñ0Ô0ˆFà"Ð.à$Ô3Ð6IÒI�à%Ð1ØÔ*Ð->Ò>Ð>ð #(�Kàð Ø˜LÑ(�DÙà ˆMØ!Ðð
­ð 
µ%ð 
ð 
ð 
ð 
ð@­HµT¬Nð @½tð @ð @ð @ð @ð @ð @ð @ðG­Tµ$¬Zð G½HÅT¼Nð Gð Gð Gð Gð .4¯YªY°yÔ7PÑ-QÔ-QÐØ&6°r°s°sÔ&;×&BÒ&BÑ&DÔ&DÈÐPTÈÒ&UÐ#åœ+Ð&6°s¸°sÔ&;Ð>NÈqÈrÈrÔ>RÑ&RÑSÔSÐTUÔVˆKØ×Ò˜QÑÔÐÝ�;ÑÔ !Ò#Ð#à$×+Ò+Ñ-Ô-�Ø*ð /Ø—M’M¥# f¡+¤+Ñ.Ô.Ð.à�
Ø%+ð /ð /�MØ$*¨:°mÐ+CÔ$D�Mà% aÔ(×-Ò-Ñ/Ô/°)Ô2KÑKð (ð & bÔ)×.Ò.Ñ0Ô0°9Ô3LÑLð &ð %×+Ò+Ø#˜Ø"-Ð0CÀnÑ0TÑ"TØ +Ð.?À.Ñ.PÑ PØ#0Ø#)ð	ñ ô ñô ð ð "/�J�Jà*ð >à˜LÑ(�D�Dð ˜z¨A™~Ô.×3Ò3Ñ5Ô5¸	Ô8QÑQð 'ð Ð.°Ñ=Ñ=�D�Dà+�Ø#Ð$4×$<Ò$<Ñ$>Ô$>×$FÒ$FÑ$HÔ$HÔI�
å˜
‘O”O aÒ'Ð'Ø" 2œ×+Ò+Ñ-Ô-°Ô1JÒJÐJð # 2œ×+Ò+Ñ-Ô-°	Ô0IÑIð 'ð  2°NÑB�Hà ×'Ò'Ø�KØ)Ø'¨(Ñ2Ø%Ø%ð	ñ ô ñô ð ð ˜Ñ$�àñ K:Ý#Ø-ØØ'Ø#Ø+Ø)=Ø(;Ø*?ð	ñ 	ô 	ð 	ð /ð HÝ$+Ð,<Ñ$=Ô$=�MØ$Ð0°]À[Ò5PÐ5PÝ$ ]Õ5FÑ%FÑGÔG˜ð 3Ñ>Ø ?�IØ2ð DÝ(/Ð0@Ñ(AÔ(A˜Ø(Ð4¸ÈÒ9TÐ9TØ1@À=Ñ1PÐ.Ø1°IÒ=Ð=Ý',¨]Õ=NÑ-NÑ'OÔ'O  à'4°|Ñ'C ð %7Ð$6Ð7GÑ$HÔ$H�MØ$Ð0Ð5GÐ5GÈÑ5VÔ5VÐ0Ø+¨GÔ4°{ÑB˜Ø š?˜?Ø#0µ5¸Õ?PÑ9PÑ3QÔ3QÑ#Q˜DÙ$ð $9�LÝ#¥CÐ(8Ñ$9Ô$9Ñ:Ô:ð 6ð 6˜Ø"2°2Ô"6˜Ø& wÔ/ð %Ø$Ø-Ð-¨gÑ6Ô6ð &Ø+=Ð+=Ø 0°°a±°°Ô :ñ,ô ,˜Lð  ,Ð7Ø1=¸gÔ1FÀqÔ1IÈ'Ô1R  à1<Ð?OÑ1O à '¨Ô 0°<Ñ ?À)Ò Kð !HØ#*¨7Ô#3°iÒ#?ð!Hà#*¨7Ô#3°kÑ#AÀCÒ#Gð +ð !/°¸´Ñ ?À)Ò Kð !JØ#5Ð#5°lÑ#CÔ#Cð!Jà#2°W¸U´^Ñ#CÀcÒ#Ið *ð
  .ð &°-ð &Ý',Ý$'¨°a©¸ÀÔ9IÑ$JÔ$JÝ&7ñ%8ñ("ô (" ð $4°g¸e´nÑ#DÀyÒ#PÐ#PØ+9 DØ8:Ð 0°°°Ñ 5Ø % Ø'.¨u¤~˜˜å 'Ð(8Ñ 9Ô 9�Ø Ð,Ø,9Ð)àð +Ø/ð +ð +�GØ'.¨wÔ'7¸À¼ÈÐQWÌ ˜3�EØ\Õ/°Ñ6Ô6Ð\Ð\Õ=MÈcÑ=RÔ=RÐ\Ð\ÐVZÐ\Ð\�DÝ�) D™/œ/Ñ*Ô*Ð*Ð*õ (Ð(8Ñ9Ô9ð *ð *‘
��7Ø˜7Ô# w¨u¤~Ò5Ð5¸À¼×9NÒ9NÑ9PÔ9PÐTVÒ9VÐ9VØ&(�G˜F‘OØ(*�G˜HÑ%Ø')�G˜GÑ$øà×Òðð å&/Ø(µ°LÑ0AÔ0Að'ñ 'ô 'ðñ ô ñô ð ð ×ÒØVÐVÐ&6ÐVÑVÔVñô ð ð .ð 5°Ô1CÀcÒ1IÐ1Iå%(¨¡_¤_Ð"ð �KŠK�˜N¨DÑ1Ô1°MÑAÑBÔBÐBðY �˜Z™œÒ(Ñ(ðtCð tCð tCñ tCô tCð tCð tCð tCð tCð tCð tCøøøð tCð tCð tCð tCõl Ø×Ò˜j­Ð-BÑ)CÔ)CÐ)EÐ)EÔFÑGÔGØØðñ ô ð s   Ð+^&oïo!ï$o!c                  ó2  ‡‡— ddl mŠ ˆfd„} t          j        t          j        ¬¦  «        }|                     ddt          d¬¦  «         |                     d	d
| d¬¦  «         |                     dt          d d¬¦  «         |                     dt          j         	                    ¦   «         rdndd¬¦  «         |                     ddt          dd¬¦  «         |                     ddt          dg d¢d¬¦  «         |                     dt          d d!¬¦  «         |                     d"t          d#d#d$gd%¬¦  «         |                     d&t          d t          t          j        ¦   «         ¦  «        t          d'„ t          j        ¦   «         D ¦   «         ¦  «        z   d(¬¦  «         |                     d)t          d*d+¬¦  «         |                     d,t           d-d.¬¦  «         |                     d/t           d-d0¬¦  «         |                     d1t          d d2¬¦  «         |                     d3t          d d4¬¦  «         |                     d5t          d6d7¬¦  «         |                     d8t          d d9¬¦  «         |                     d:t          d;d<¬¦  «         |                     d=t          d d>¬¦  «         |                     d?t          d d@¬¦  «         |                     dAt"          dBdC¬¦  «         |                     dDt"          dEdF¬¦  «         |                     dGt"          dHdI¬¦  «         |                     dJt"          dKdL¬¦  «         |                     dMt          d;dN¬¦  «         |                     dOt          dPdQ¬¦  «         |                     dRt          dSdT¬¦  «         |                     dUt          d;dV¬¦  «         |                     dWt           d dX¬¦  «         |                     dYt           d dZ¬¦  «         |                     d[t           d d\¬¦  «         |                     d]t           d*d^¬¦  «         |                     d_t          d`da¬¦  «         |                     dbt"          dc¬d¦  «         |                     ¦   «         j        Š‰                     de¦  «        }‰                     df¦  «        }‰                     dg¦  «        }‰                     dh¦  «        }‰                     di¦  «        }t+          j        |d ¬j¦  «         |                     dk¦  «        r7‰dl         dmvr-‰dl         � t1          j        |› dn‰dl         › do�¦  «         dp‰dl<   ‰                     dq¦  «        }‰                     dr¦  «        x}�$t5          t7          j        |ds|¦  «        ¦  «        }n|g}‰                     dt¦  «        x}	d*k    rt          j        |	¦  «         ddul m}
  |
|||¬v¦  «        }t?          ||¦  «        }g dw¢}‰dx         s&|D ]#}‰|         r|                      dy|› dz�¦  «         Œ$‰d{         r‰d|         st1          j        d}¦  «         ‰d~         r‰d|         rt1          j        d¦  «         ˆfd€„|D ¦   «         }‰                     d¦  «        D ]~}	 tC          ||fdq|i‰¤Ž} |||fi |¤Ž Œ# tD          $ rT}tG          j$        ¦   «          tK          d�|› d‚tM          |¦  «        j'        › dƒt          |¦  «        › �¦  «         Y d }~Œwd }~ww xY wd S )„Nr   )Úavailable_modelsc                 ó”   •— |  ‰¦   «         v st           j                             | ¦  «        r| S t          d ‰¦   «         › d�¦  «        ‚)Nzmodel should be one of z or path to a model checkpoint)ÚosÚpathÚexistsÚ
ValueError)Únamerý   s    €rH   Úvalid_model_namezcli.<locals>.valid_model_name  sZ   ø€ ØÐ#Ð#Ñ%Ô%Ð%Ð%­¬¯ª¸Ñ)=Ô)=Ð%ØˆKÝØXÐ&6Ð&6Ñ&8Ô&8ÐXÐXÐXñ
ô 
ð 	
rJ   )Úformatter_classr6   ú+zaudio file(s) to transcribe)ÚnargsÚtypeÚhelpz--modelÚturboz name of the Whisper model to use)Údefaultr  r	  z--model_dirz>the path to save model files; uses ~/.cache/whisper by default)r  r  r	  z--devicer¢   r9   z#device to use for PyTorch inference)r  r	  z--output_dirz-oú.zdirectory to save the outputsz--output_formatz-fÚall)ÚtxtÚvttÚsrtÚtsvÚjsonr  zSformat of the output file; if not specified, all available formats will be produced)r  r  Úchoicesr	  z	--verboseTz4whether to print out the progress and debug messagesz--taskr@   rO   zawhether to perform X->X speech recognition ('transcribe') or X->English translation ('translate')z
--languagec                 ó6   — g | ]}|                      ¦   «         ‘ŒS rC   )r®   )rF   Úks     rH   rI   zcli.<locals>.<listcomp>  s>   € ð  iUð  iUð  iUÐwxÐij×ipÒipÑirÔirð  iUð  iUð  iUrJ   zHlanguage spoken in the audio, specify None to perform language detectionz--temperaturer   ztemperature to use for samplingz	--best_ofé   z<number of candidates when sampling with non-zero temperaturez--beam_sizezHnumber of beams in beam search, only applicable when temperature is zeroz
--patiencez”optional patience value to use in beam decoding, as in https://arxiv.org/abs/2204.05424, the default (1.0) is equivalent to conventional beam searchz--length_penaltyz…optional token length penalty coefficient (alpha) as in https://arxiv.org/abs/1609.08144, uses simple length normalization by defaultz--suppress_tokensz-1z„comma-separated list of token ids to suppress during sampling; '-1' will suppress most special characters except common punctuationsz--initial_promptz:optional text to provide as a prompt for the first window.z--carry_initial_promptFz{if True, prepend initial_prompt to every internal decode() call. May reduce the effectiveness of condition_on_previous_textz--condition_on_previous_textzÏif True, provide the previous output of the model as a prompt for the next window; disabling may make the text inconsistent across windows, but the model becomes less prone to getting stuck in a failure loopz--fp16z5whether to perform inference in fp16; True by defaultz#--temperature_increment_on_fallbackr    zhtemperature to increase when falling back when the decoding fails to meet either of the thresholds belowz--compression_ratio_thresholdr#   zUif the gzip compression ratio is higher than this value, treat the decoding as failedz--logprob_thresholdr$   zUif the average log probability is lower than this value, treat the decoding as failedz--no_speech_thresholdr!   zžif the probability of the <|nospeech|> token is higher than this value AND the decoding has failed due to `logprob_threshold`, consider the segment as silencez--word_timestampszQ(experimental) extract word-level timestamps and refine the results based on themz--prepend_punctuationsr%   zNif word_timestamps is True, merge these punctuation symbols with the next wordz--append_punctuationsr&   zRif word_timestamps is True, merge these punctuation symbols with the previous wordz--highlight_wordszT(requires --word_timestamps True) underline each word as it is spoken in srt and vttz--max_line_widthze(requires --word_timestamps True) the maximum number of characters in a line before breaking the linez--max_line_countzJ(requires --word_timestamps True) the maximum number of lines in a segmentz--max_words_per_linezk(requires --word_timestamps True, no effect with --max_line_width) the maximum number of words in a segmentz	--threadsz]number of threads used by torch for CPU inference; supercedes MKL_NUM_THREADS/OMP_NUM_THREADSz--clip_timestampsr'   z–comma-separated list start,end,start,end,... timestamps (in seconds) of clips to process, where the last end timestamp defaults to the end of the filez!--hallucination_silence_thresholdz‡(requires --word_timestamps True) skip silent periods longer than this threshold (in seconds) when a possible hallucination is detected)r  r	  r5   Ú	model_dirÚ
output_dirÚoutput_formatr¡   )Úexist_okz.enr<   >   r=   ÚEnglishz) is an English-only model but receipted 'z'; using English instead.r=   r)   Ú!temperature_increment_on_fallbackgzo ð?Úthreads)Ú
load_model)r¡   Údownload_root)Úhighlight_wordsÚmax_line_countÚmax_line_widthÚmax_words_per_liner0   z--z  requires --word_timestamps Truer!  r"  z7--max_line_count has no effect without --max_line_widthr#  z8--max_words_per_line has no effect with --max_line_widthc                 ó<   •— i | ]}|‰                      |¦  «        “ŒS rC   )rX   )rF   ÚargÚargss     €rH   ú
<dictcomp>zcli.<locals>.<dictcomp>d  s%   ø€ Ð>Ð>Ð>¨#�3˜Ÿš ™œÐ>Ð>Ð>rJ   z	Skipping z due to z: )(r™   rý   ÚargparseÚArgumentParserÚArgumentDefaultsHelpFormatterÚadd_argumentr¯   rž   r¢   r£   r   Úsortedr   Úkeysr   rD   r   r   Ú
parse_argsÚ__dict__rX   rÿ   ÚmakedirsÚendswithr¤   r¥   ÚtupleÚnpÚarangeÚset_num_threadsr  r   Úerrorr@   Ú	ExceptionÚ	tracebackÚ	print_excrª   r  Ú__name__)r  ÚparserÚ
model_namer  r  r  r¡   r)   Ú	incrementr  r  r5   ÚwriterÚword_optionsÚoptionÚwriter_argsÚ
audio_pathri   Úer&  rý   s                      @@rH   ÚclirD    s{	  øø€ Ø"Ð"Ð"Ð"Ð"Ð"ð
ð 
ð 
ð 
ð 
õ Ô$µXÔ5[Ð\Ñ\Ô\€FØ
×Ò˜ sµÐ;XÐÑYÔYÐYØ
×Ò˜	¨7Ð9IÐPrÐÑsÔsÐsØ
×Ò˜­C¸ð  EEÐñ  Fô  Fð  FØ
×Ò˜
µe´j×6MÒ6MÑ6OÔ6OÐ,Z¨F¨FÐUZð  bGÐñ  Hô  Hð  HØ
×Ò˜¨µ3ÀÐJiÐÑjÔjÐjØ
×ÒÐ)¨4µcÀ5ÐR}ÐR}ÐR}ð  EZÐñ  [ô  [ð  [Ø
×Ò˜­(¸DÐG}ÐÑ~Ô~Ð~à
×Ò˜¥s°LÈ<ÐYdÐJeð  mPÐñ  Qô  Qð  QØ
×Ò˜­3¸ÅfÍYÌ^ÑM]ÔM]ÑF^ÔF^Õagð  iUð  iUõ  }Mô  }Rñ  }Tô  }Tð  iUñ  iUô  iUñ  bVô  bVñ  GVð  ]gÐñ  hô  hð  hà
×Ò˜­e¸QÐEfÐÑgÔgÐgØ
×Ò˜­,Àð  IGÐñ  Hô  Hð  HØ
×Ò˜­LÀ!ð  KUÐñ  Vô  Vð  VØ
×Ò˜­5¸$ð  F\Ðñ  ]ô  ]ð  ]Ø
×ÒÐ*µÀð  LSÐñ  Tô  Tð  Tà
×ÒÐ+µ#¸tð  KQÐñ  Rô  Rð  RØ
×ÒÐ*µ¸dð  JFÐñ  Gô  Gð  GØ
×ÒÐ0µxÈð  VSÐñ  Tô  Tð  Tà
×ÒÐ6½XÈtð  [lÐñ  mô  mð  mØ
×Ò˜¥x¸ÐD{ÐÑ|Ô|Ð|à
×ÒÐ=ÅNÐ\_ð  gQÐñ  Rô  Rð  RØ
×ÒÐ7½nÐVYð  axÐñ  yô  yð  yØ
×ÒÐ-µNÈDð  XoÐñ  pô  pð  pØ
×ÒÐ/µnÈcð  YyÐñ  zô  zð  zØ
×ÒÐ+µ(ÀEð  QdÐñ  eô  eð  eØ
×ÒÐ0µsÀOð  [kÐñ  lô  lð  lØ
×ÒÐ/µcÐCfð  nBÐñ  Cô  Cð  CØ
×ÒÐ+µ(ÀEð  QgÐñ  hô  hð  hØ
×ÒÐ*µÀtð  SzÐñ  {ô  {ð  {Ø
×ÒÐ*µÀtð  S_Ðñ  `ô  `ð  `Ø
×ÒÐ.µ\È4ð  WDÐñ  Eô  Eð  EØ
×Ò˜­,Àð  IhÐñ  iô  ið  iØ
×ÒÐ+µ#¸sð  JbÐñ  cô  cð  cØ
×ÒÐ;Å.ð  XaÐñ  bô  bð  bð ×ÒÑÔÔ'€DØ—h’h˜wÑ'Ô'€JØ—X’X˜kÑ*Ô*€IØ—h’h˜|Ñ,Ô,€JØŸš /Ñ2Ô2€MØ—(’(˜8Ñ$Ô$€FÝ„K�
 TÐ*Ñ*Ô*Ð*à×Ò˜5Ñ!Ô!ð   d¨:Ô&6Ð>OÐ&OÐ&OØ�
ÔÐ'ÝŒMØÐsÐsÈÈZÔHXÐsÐsÐsñô ð ð  ˆˆZÑà—(’(˜=Ñ)Ô)€KØ—X’XÐAÑBÔBÐBˆ	ÐOÝ�BœI k°:¸yÑIÔIÑJÔJˆˆà"�mˆà—8’8˜IÑ&Ô&Ð&ˆ¨!Ò+Ð+ÝÔ˜gÑ&Ô&Ð&àÐÐÐÐÐàˆJ�z¨&À	ÐJÑJÔJ€Eå˜ zÑ2Ô2€Fðð ð €Lð Ð!Ô"ð LØ"ð 	Lð 	LˆFØ�FŒ|ð LØ—’ÐJ &ÐJÐJÐJÑKÔKÐKøØÐÔð Q dÐ+;Ô&<ð QÝŒÐOÑPÔPÐPØÐ Ô!ð R dÐ+;Ô&<ð RÝŒÐPÑQÔQÐQØ>Ð>Ð>Ð>°Ð>Ñ>Ô>€KØ—h’h˜wÑ'Ô'ð Pð Pˆ
ð	PÝ  zÐSÐS¸{ÐSÈdÐSÐSˆFØˆF�6˜:Ð5Ð5¨Ð5Ð5Ð5Ð5øÝð 	Pð 	Pð 	PÝÔÑ!Ô!Ð!ÝÐN˜jÐNÐNµ$°q±'´'Ô2BÐNÐNÅcÈ!ÁfÄfÐNÐNÑOÔOÐOÐOÐOÐOÐOÐOøøøøð	Pøøøð	Pð Ps   ÚZ6Ú6
\Û A
\Ü\Ú__main__)2r(  rÿ   r8  r¤   Útypingr   r   r   r   r   Únumpyr3  rž   rº   r6   r	   r
   r   r   r   r   r   Údecodingr   r   Útimingr   rn   r   r   r   Úutilsr   r   r   r   r   r   r   r   r5   r   r¯   Úndarrayr´   r¾   rD   r@   rD  r:  rC   rJ   rH   ú<module>rL     s
  ðØ €€€Ø 	€	€	€	Ø Ð Ð Ð Ø €€€Ø >Ð >Ð >Ð >Ð >Ð >Ð >Ð >Ð >Ð >Ð >Ð >Ð >Ð >à Ð Ð Ð Ø €€€Ø €€€ðð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð 6Ð 5Ð 5Ð 5Ð 5Ð 5Ð 5Ð 5Ø 'Ð 'Ð 'Ð 'Ð 'Ð 'Ø AÐ AÐ AÐ AÐ AÐ AÐ AÐ AÐ AÐ Að	ð 	ð 	ð 	ð 	ð 	ð 	ð 	ð 	ð 	ð 	ð 	ð 	ð 	ð 	ð 	ð 	ð 	ð 	ð 	ð ð ØÐÐÐÐÐð #Ø3QØ36Ø)-Ø+.Ø'+Ø$(Ø!&Ø!Ø .ØAØ/2Ø7;ð!\ð \ð \Øð\à��b”j %¤,Ð.Ô/ð\ð �dŒ^ð	\ð
 �u˜e E¨3 JÔ/Ð/Ô0ð\ð "*¨%¤ð\ð   ”ð\ð " %œð\ð !%ð\ð ˜S”Mð\ð ð\ð ð\ð ð\ð ð\ð ˜3  U¤Ð+Ô,ð\ð  &.¨e¤_ð!\ð \ð \ð \ð~fPð fPð fPðR ˆzÒÐØ€C�E„E€E€E€Eð ÐrJ   