§
    ‚Štj«Œ  ã                   ó  — d dl mZ d dlmZmZmZ d dlZd dlZddl	m
Z
 ddlmZ ddlmZmZmZmZ dd	lmZ dd
lmZ erd dlmZ ddlmZ ddlmZ  ej        e¦  «        Z e¦   «         r
d dlZddl m!Z! d„ Z"dd„Z#d„ Z$ G d„ de¦  «        Z%dS )é    )Údefaultdict)ÚTYPE_CHECKINGÚAnyÚUnionNé   )ÚGenerationConfig)ÚPreTrainedTokenizer)Úis_torch_availableÚis_torchaudio_availableÚis_torchcodec_availableÚloggingé   )Úffmpeg_read)ÚChunkPipeline)ÚBeamSearchDecoderCTC)ÚSequenceFeatureExtractor)ÚPreTrainedModel)Ú(MODEL_FOR_SPEECH_SEQ_2_SEQ_MAPPING_NAMESc                 ó  — g }| D ]ƒ\  }}}t          t          ||z  ¦  «        ¦  «        }t          t          ||z  |z  ¦  «        ¦  «        }t          t          ||z  |z  ¦  «        ¦  «        }|||f}|                     |¦  «         Œ„|S )zŽ
    Rescales the stride values from audio space to tokens/logits space.

    (160_000, 16_000, 16_000) -> (2000, 200, 200) for instance.
    )ÚintÚroundÚappend)ÚstrideÚratioÚnew_stridesÚinput_nÚleftÚrightÚtoken_nÚ
new_strides           úq/var/www/html/CA-Chatbot/venv/lib/python3.11/site-packages/transformers/pipelines/automatic_speech_recognition.pyÚrescale_strider"   )   s�   € ð €KØ &ð 'ð 'Ñˆ��uÝ•e˜G e™OÑ,Ô,Ñ-Ô-ˆÝ•5˜ ™¨'Ñ1Ñ2Ô2Ñ3Ô3ˆÝ•E˜% '™/¨GÑ3Ñ4Ô4Ñ5Ô5ˆØ˜t UÐ+ˆ
Ø×Ò˜:Ñ&Ô&Ð&Ð&àÐó    c              #   ó`  K  — | j         d         }||z
  |z
  }t          d||¦  «        D ]„}||z   }	| ||	…         }
 ||
|j        dd¬¦  «        }|�|                     |¬¦  «        }|dk    rdn|}|	|k    }|rdn|}|
j         d         }|||f}|
j         d         |k    r	||dœ|¥V — |r d S Œ…d S )Nr   ÚptT©Úsampling_rateÚreturn_tensorsÚreturn_attention_mask©Údtype)Úis_lastr   )ÚshapeÚranger'   Úto)ÚinputsÚfeature_extractorÚ	chunk_lenÚstride_leftÚstride_rightr+   Ú
inputs_lenÚstepÚchunk_start_idxÚchunk_end_idxÚchunkÚ	processedÚ_stride_leftr,   Ú_stride_rightr   s                   r!   Ú
chunk_iterr=   =   s  è è € Ø”˜a”€JØ�{Ñ" \Ñ1€DÝ   J°Ñ5Ô5ð ð ˆØ'¨)Ñ3ˆØ� }Ð4Ô5ˆØ%Ð%ØØ+Ô9ØØ"&ð	
ñ 
ô 
ˆ	ð ÐØ!Ÿš¨5˜Ñ1Ô1ˆIØ+¨qÒ0Ð0�q�q°kˆØ :Ò-ˆØ$Ð6˜˜¨,ˆà”K ”Nˆ	Ø˜\¨=Ð9ˆØŒ;�qŒ>˜LÒ(Ð(Ø%°ÐEÐE¸9ÐEÐEÐEÐEØð 	ØˆEˆEð	ð'ð r#   c           
      óF  ‡— ˆfd„| d         d                               ¦   «         D ¦   «         }| dd …         D ]Ö}ˆfd„|d                               ¦   «         D ¦   «         }d}d}t          dt          |¦  «        dz   ¦  «        D ]l}|dz  }t          j        t          j        || d …         ¦  «        t          j        |d |…         ¦  «        k    ¦  «        }	|	|z  |z   }
|	dk    r
|
|k    r|}|
}Œm|                     ||d …         ¦  «         Œ×t          j        |¦  «        S )Nc                 ó&   •— g | ]}|‰j         v¯|‘ŒS © ©Úall_special_ids©Ú.0Útok_idÚ	tokenizers     €r!   ú
<listcomp>z1_find_longest_common_sequence.<locals>.<listcomp>^   s&   ø€ ÐiÐiÐi˜6ÀÈyÔOhÐAhÐAh�ÐAhÐAhÐAhr#   r   r   c                 ó&   •— g | ]}|‰j         v¯|‘ŒS r@   rA   rC   s     €r!   rG   z1_find_longest_common_sequence.<locals>.<listcomp>`   s'   ø€ ÐlÐlÐl 6ÀFÐR[ÔRkÐDkÐDk˜ÐDkÐDkÐDkr#   g        g     ˆÃ@)Útolistr.   ÚlenÚnpÚsumÚarrayÚextend)Ú	sequencesrF   ÚsequenceÚnew_seqÚnew_sequenceÚindexÚmax_ÚiÚepsÚmatchesÚmatchings    `         r!   Ú_find_longest_common_sequencerY   W   s?  ø€ ð jÐiÐiÐi Y¨q¤\°!¤_×%;Ò%;Ñ%=Ô%=ÐiÑiÔi€HØ˜Q˜R˜R”=ð .ð .ˆØlÐlÐlÐl¨W°Q¬Z×->Ò->Ñ-@Ô-@ÐlÑlÔlˆàˆØˆÝ�q�#˜lÑ+Ô+¨aÑ/Ñ0Ô0ð 	 ð 	 ˆAà�g‘+ˆCÝ”f�RœX h°¨r¨s¨s¤mÑ4Ô4½¼ÀÈbÈqÈbÔAQÑ8RÔ8RÒRÑSÔSˆGØ ‘{ SÑ(ˆHØ˜Š{ˆ{˜x¨$š˜Ø�Ø�øØ�Š˜ U V VÔ,Ñ-Ô-Ð-Ð-ÝŒ8�HÑÔÐr#   c                   óX  ‡ — e Zd ZdZdZdZdZdZdZ e	dd¬¦  «        Z
	 	 	 	 ddd	d
edef         dz  dedz  dedef         dz  deedf         dz  f
ˆ fd„Zdej        ez  ez  ez  dedeeeef                  fˆ fd„Z	 	 	 	 	 	 dd„Zed„ ¦   «         Zdd„Zd d„Z	 d!dedz  fd„Zˆ xZS )"Ú"AutomaticSpeechRecognitionPipelineao  
    Pipeline that aims at extracting spoken text contained within some audio.

    The input can be either a raw waveform or a audio file. In case of the audio file, ffmpeg should be installed for
    to support multiple audio formats

    Unless the model you're using explicitly sets these generation parameters in its configuration files
    (`generation_config.json`), the following default values will be used:
    - max_new_tokens: 256
    - num_beams: 5

    Example:

    ```python
    >>> from transformers import pipeline

    >>> transcriber = pipeline(model="openai/whisper-base")
    >>> transcriber("https://huggingface.co/datasets/Narsil/asr_dummy/resolve/main/1.flac")
    {'text': ' He hoped there would be stew for dinner, turnips and carrots and bruised potatoes and fat mutton pieces to be ladled out in thick, peppered flour-fatten sauce.'}
    ```

    Learn more about the basics of using a pipeline in the [pipeline tutorial](../pipeline_tutorial)

    Arguments:
        model ([`PreTrainedModel`]):
            The model that will be used by the pipeline to make predictions. This needs to be a model inheriting from
            [`PreTrainedModel`].
        feature_extractor ([`SequenceFeatureExtractor`], *optional*):
            The feature extractor that will be used by the pipeline to encode waveform for the model.
        tokenizer ([`PreTrainedTokenizer`], *optional*):
            The tokenizer that will be used by the pipeline to encode data for the model. This object inherits from
            [`PreTrainedTokenizer`].
        decoder (`pyctcdecode.BeamSearchDecoderCTC`, *optional*):
            [PyCTCDecode's
            BeamSearchDecoderCTC](https://github.com/kensho-technologies/pyctcdecode/blob/2fd33dc37c4111417e08d89ccd23d28e9b308d19/pyctcdecode/decoder.py#L180)
            can be passed for language model boosted decoding. See [`Wav2Vec2ProcessorWithLM`] for more information.
        device (Union[`int`, `torch.device`], *optional*):
            Device ordinal for CPU/GPU supports. Setting this to `None` will leverage CPU, a positive will run the
            model on the associated CUDA device id.
    TFé   é   )Úmax_new_tokensÚ	num_beamsNÚmodelr   r1   r   rF   Údecoderr   Údeviceztorch.devicec                 ó  •— |j         j        dk    rd| _        nU|j        j        t          j        ¦   «         v rd| _        n.|j         j        dv rd| _        n|�|| _        d| _        nd| _         t          ¦   «         j	        |||fd|i|¤Ž d S )	NÚwhisperÚseq2seq_whisperÚseq2seq)Úparakeet_tdtÚparakeet_rnntÚnemotron_asr_streamingÚnemotron3_5_asrÚtdtÚctc_with_lmÚctcrb   )
ÚconfigÚ
model_typeÚtypeÚ	__class__Ú__name__r   Úvaluesra   ÚsuperÚ__init__)Úselfr`   r1   rF   ra   rb   Úkwargsrq   s          €r!   ru   z+AutomaticSpeechRecognitionPipeline.__init__¥   s§   ø€ ð Œ<Ô" iÒ/Ð/Ø)ˆDŒIˆIØŒ_Ô%Õ)QÔ)XÑ)ZÔ)ZÐZÐZØ!ˆDŒIˆIØŒ\Ô$Ð(vÐvÐvàˆDŒIˆIØÐ Ø"ˆDŒLØ%ˆDŒIˆIàˆDŒIà�‰ŒÔ˜ 	Ð+<ÐVÐVÀVÐVÈvÐVÐVÐVÐVÐVr#   r0   rw   Úreturnc                 ó8   •—  t          ¦   «         j        |fi |¤ŽS )ae  
        Transcribe the audio sequence(s) given as inputs to text. See the [`AutomaticSpeechRecognitionPipeline`]
        documentation for more information.

        Args:
            inputs (`np.ndarray` or `bytes` or `str` or `dict`):
                The inputs is either :
                    - `str` that is either the filename of a local audio file, or a public URL address to download the
                      audio file. The file will be read at the correct sampling rate to get the waveform using
                      *ffmpeg*. This requires *ffmpeg* to be installed on the system.
                    - `bytes` it is supposed to be the content of an audio file and is interpreted by *ffmpeg* in the
                      same way.
                    - (`np.ndarray` of shape (n, ) of type `np.float32` or `np.float64`)
                        Raw audio at the correct sampling rate (no further check will be done)
                    - `dict` form can be used to pass raw audio sampled at arbitrary `sampling_rate` and let this
                      pipeline do the resampling. The dict must be in the format `{"sampling_rate": int, "raw":
                      np.array}` with optionally a `"stride": (left: int, right: int)` than can ask the pipeline to
                      treat the first `left` samples and last `right` samples to be ignored in decoding (but used at
                      inference to provide more context to the model). Only use `stride` with CTC models.
            return_timestamps (*optional*, `str` or `bool`):
                Only available for pure CTC models (Wav2Vec2, HuBERT, etc) and the Whisper model. Not available for
                other sequence-to-sequence models.

                For CTC models, timestamps can take one of two formats:
                    - `"char"`: the pipeline will return timestamps along the text for every character in the text. For
                        instance, if you get `[{"text": "h", "timestamp": (0.5, 0.6)}, {"text": "i", "timestamp": (0.7,
                        0.9)}]`, then it means the model predicts that the letter "h" was spoken after `0.5` and before
                        `0.6` seconds.
                    - `"word"`: the pipeline will return timestamps along the text for every word in the text. For
                        instance, if you get `[{"text": "hi ", "timestamp": (0.5, 0.9)}, {"text": "there", "timestamp":
                        (1.0, 1.5)}]`, then it means the model predicts that the word "hi" was spoken after `0.5` and
                        before `0.9` seconds.

                For the Whisper model, timestamps can take one of two formats:
                    - `"word"`: same as above for word-level CTC timestamps. Word-level timestamps are predicted
                        through the *dynamic-time warping (DTW)* algorithm, an approximation to word-level timestamps
                        by inspecting the cross-attention weights.
                    - `True`: the pipeline will return timestamps along the text for *segments* of words in the text.
                        For instance, if you get `[{"text": " Hi there!", "timestamp": (0.5, 1.5)}]`, then it means the
                        model predicts that the segment "Hi there!" was spoken after `0.5` and before `1.5` seconds.
                        Note that a segment of text refers to a sequence of one or more words, rather than individual
                        words as with word-level timestamps.
            generate_kwargs (`dict`, *optional*):
                The dictionary of ad-hoc parametrization of `generate_config` to be used for the generation call. For a
                complete overview of generate, check the [following
                guide](https://huggingface.co/docs/transformers/en/main_classes/text_generation).

        Return:
            `Dict`: A dictionary with the following keys:
                - **text** (`str`): The recognized text.
                - **chunks** (*optional(, `list[Dict]`)
                    When using `return_timestamps`, the `chunks` will become a list containing all the various text
                    chunks identified by the model, *e.g.* `[{"text": "hi ", "timestamp": (0.5, 0.9)}, {"text":
                    "there", "timestamp": (1.0, 1.5)}]`. The original full text can roughly be recovered by doing
                    `"".join(chunk["text"] for chunk in output["chunks"])`.
        )rt   Ú__call__)rv   r0   rw   rq   s      €r!   rz   z+AutomaticSpeechRecognitionPipeline.__call__¾   s%   ø€ ðr  �u‰wŒwÔ Ð1Ð1¨&Ð1Ð1Ð1r#   c                 óp  — i }i }	i }
|�<| j         dv r.|s,d}| j         dk    r|dz  }t                               |¦  «         ||d<   |�||d<   d|v r(|	                     |                     d¦  «        ¦  «         |	                     |¦  «         t          | dd ¦  «        �
| j        |	d<   t          | d	d ¦  «        �| j        |	d
<   | j        |	d	<   |�||
d<   |�$| j         dk    rt          d¦  «        ‚||
d<   ||	d<   t          | d¦  «        r#t          | j        d¦  «        r|p| j        j        }|�„| j         dk    r|rt          d¦  «        ‚| j         dk    r|dk    rt          d¦  «        ‚| j         dk    r|dvrt          d¦  «        ‚| j         dk    r|dk    rt          d¦  «        ‚||	d<   ||
d<   ||	|
fS )N)rf   re   a  Using `chunk_length_s` is very experimental with seq2seq models. The results will not necessarily be entirely accurate and will have caveats. More information: https://github.com/huggingface/transformers/pull/20104. Ignore this warning with pipeline(..., ignore_warning=True).re   zÕ To use Whisper for long-form transcription, use rather the model's `generate` method directly as the model relies on it's own chunking mechanism (cf. Whisper original paper, section 3.8. Long-form Transcription).Úchunk_length_sÚstride_length_sÚgenerate_kwargsÚassistant_modelÚassistant_tokenizerrF   Údecoder_kwargsz)Only Whisper can return language for now.Úreturn_languageÚgeneration_configÚreturn_timestampsrf   zEWe cannot return_timestamps yet on non-CTC models apart from Whisper!rl   ÚwordzRCTC with LM can only predict word level timestamps, set `return_timestamps='word'`rm   )Úcharr…   z–CTC can either predict character level timestamps, or word level timestamps. Set `return_timestamps='char'` or `return_timestamps='word'` as required.r†   zžWhisper cannot return `char` timestamps, only word level or segment level timestamps. Use `return_timestamps='word'` or `return_timestamps=True` respectively.)rp   ÚloggerÚwarningÚupdateÚpopÚgetattrr   rF   r€   Ú
ValueErrorÚhasattrrƒ   r„   )rv   r|   r}   Úignore_warningr�   r„   r‚   r~   Úpreprocess_paramsÚforward_paramsÚpostprocess_paramsÚtype_warnings               r!   Ú_sanitize_parametersz7AutomaticSpeechRecognitionPipeline._sanitize_parametersù   sƒ  € ð ÐØˆØÐð Ð%ØŒyÐ:Ð:Ð:À>Ð:ð-ð ð ”9Ð 1Ò1Ð1Ø ð4ñ�Lõ
 —’˜|Ñ,Ô,Ð,Ø2@ÐÐ.Ñ/ØÐ&Ø3BÐÐ/Ñ0ð  Ð/Ð/Ø×!Ò! /×"5Ò"5Ð6GÑ"HÔ"HÑIÔIÐIà×Ò˜oÑ.Ô.Ð.å�4Ð*¨DÑ1Ô1Ð=Ø04Ô0DˆNÐ,Ñ-Ý�4Ð.°Ñ5Ô5ÐAØ*.¬.ˆN˜;Ñ'Ø48Ô4LˆNÐ0Ñ1ð Ð%Ø3AÐÐ/Ñ0ØÐ&ØŒyÐ-Ò-Ð-Ý Ð!LÑMÔMÐMØ4CÐÐ0Ñ1Ø0?ˆNÐ,Ñ-õ �4Ð,Ñ-Ô-ð 	^µ'¸$Ô:PÐReÑ2fÔ2fð 	^Ø 1Ð ]°TÔ5KÔ5]ÐàÐ(àŒy˜IÒ%Ð%Ð*;Ð%Ý Ð!hÑiÔiÐiØŒy˜MÒ)Ð)Ð.?À6Ò.IÐ.IÝ Ð!uÑvÔvÐvØŒy˜EÒ!Ð!Ð&7Ð?OÐ&OÐ&OÝ ð`ñô ð ð ŒyÐ-Ò-Ð-Ð2CÀvÒ2MÐ2MÝ ð_ñô ð ð 3DˆNÐ.Ñ/Ø6GÐÐ2Ñ3à  .Ð2DÐDÐDr#   c                 ó„   — t          | j        j        dd¦  «        }| j        j        j        dk    r|| j        j        z  }|S )zSample stride per output.Úinputs_to_logits_ratior   Úlasr_ctc)r‹   r`   rn   ro   r1   Ú
hop_length)rv   Úalign_tos     r!   Ú	_align_toz,AutomaticSpeechRecognitionPipeline._align_toK  sE   € õ ˜4œ:Ô,Ð.FÈÑJÔJˆØŒ:ÔÔ'¨:Ò5Ð5ð ˜Ô.Ô9Ñ9ˆHØˆr#   r   c              #   óÀ  K  — t          |t          ¦  «        r‚|                     d¦  «        s|                     d¦  «        rt          j        |d¬¦  «        j        }n<t          |d¦  «        5 }|                     ¦   «         }d d d ¦  «         n# 1 swxY w Y   t          |t          ¦  «        rt          || j
        j        ¦  «        }d }i }t          ¦   «         r?dd l}t          ||j        ¦  «        r&|                     ¦   «                              ¦   «         }t#          ¦   «         ridd l}t          ||j        j        ¦  «        rK|                     ¦   «         }	|	j        }
|
j        dk    r|
j        d         dk    r|
d         n|
}
|
|	j        d	œ}t          |t4          ¦  «        �r¸|                     d
d ¦  «        }d|v rd|v sd|v st9          d¦  «        ‚|                     dd ¦  «        }|€,|                     dd ¦  «         |                     dd ¦  «        }|                     d¦  «        }|}|}|| j
        j        k    r‘t;          ¦   «         rddlm} ntA          d¦  «        ‚| !                    t          |tD          j#        ¦  «        r |j$        |¦  «        n||| j
        j        ¦  «                             ¦   «         }| j
        j        |z  }nd}|�…|d         |d         z   |j        d         k    rt9          d¦  «        ‚|j        d         tK          tM          |d         |z  ¦  «        ¦  «        tK          tM          |d         |z  ¦  «        ¦  «        f}t          |tD          j#        |j        f¦  «        s tO          dtQ          |¦  «        › d�¦  «        ‚|j        dk    r9tR           *                    d|j        › d�¦  «         | +                    d¬¦  «        }|�r
|€|dz  }t          |tJ          tX          f¦  «        r||g}| j-        }tK          tM          || j
        j        z  |z  ¦  «        |z  ¦  «        }tK          tM          |d         | j
        j        z  |z  ¦  «        |z  ¦  «        }tK          tM          |d         | j
        j        z  |z  ¦  «        |z  ¦  «        }|||z   k     rt9          d¦  «        ‚t]          || j
        |||| j/        ¦  «        D ]
}i |¥|¥V — Œd S | j(        dk    rA|j        d         | j
        j0        k    r&|  
                    || j
        j        dddd¬¦  «        }nT| j(        dk    r&|€$|  
                    || j
        j        dd¬¦  «        }n#|  
                    || j
        j        dd¬¦  «        }| j/        �| 1                    | j/        ¬ ¦  «        }|�| j(        d!k    rt9          d"¦  «        ‚||d
<   d#di|¥|¥V — d S )$Nzhttp://zhttps://T)Úfollow_redirectsÚrbr   r   r   )rM   r'   r   r'   ÚrawrM   zûWhen passing a dictionary to AutomaticSpeechRecognitionPipeline, the dict needs to contain a "raw" key containing the numpy array or torch tensor representing the audio and a "sampling_rate" key, containing the sampling_rate associated with that arrayÚpath)Ú
functionalz¢torchaudio is required to resample audio samples in AutomaticSpeechRecognitionPipeline. The torchaudio package can be installed through: `pip install torchaudio`.zStride is too large for inputz9We expect a numpy ndarray or torch tensor as input, got `ú`zSWe expect a single channel audio input for AutomaticSpeechRecognitionPipeline, got z6. Taking the mean of the channels for mono conversion.©Úaxisé   z.Chunk length must be superior to stride lengthre   FÚlongestr%   )r'   Ú
truncationÚpaddingr(   r)   r&   r*   rf   z8Stride is only usable with CTC models, try removing it !r,   )2Ú
isinstanceÚstrÚ
startswithÚhttpxÚgetÚcontentÚopenÚreadÚbytesr   r1   r'   r
   ÚtorchÚTensorÚcpuÚnumpyr   Ú
torchcodecÚdecodersÚAudioDecoderÚget_all_samplesÚdataÚndimr-   Úsample_rateÚdictrŠ   rŒ   r   Ú
torchaudiorŸ   ÚImportErrorÚresamplerK   ÚndarrayÚ
from_numpyr   r   Ú	TypeErrorrp   r‡   rˆ   ÚmeanÚfloatr™   r=   r+   Ú	n_samplesr/   )rv   r0   r|   r}   Úfr   Úextrar°   r´   Ú_audio_samplesÚ_arrayÚ_inputsÚin_sampling_rateÚFr   r˜   r2   r3   r4   Úitemr:   s                        r!   Ú
preprocessz-AutomaticSpeechRecognitionPipeline.preprocessY  sÈ  è è € Ý�f�cÑ"Ô"ð 	&Ø× Ò  Ñ+Ô+ð &¨v×/@Ò/@ÀÑ/LÔ/Lð &õ œ 6¸DÐAÑAÔAÔI��å˜& $Ñ'Ô'ð &¨1ØŸVšV™XœX�Fð&ð &ð &ñ &ô &ð &ð &ð &ð &ð &ð &øøøð &ð &ð &ð &õ �f�eÑ$Ô$ð 	OÝ  ¨Ô)?Ô)MÑNÔNˆFàˆØˆåÑÔð 	.ØˆLˆLˆLå˜& %¤,Ñ/Ô/ð .ØŸš™œ×+Ò+Ñ-Ô-�å"Ñ$Ô$ð 
	XØÐÐÐå˜& *Ô"5Ô"BÑCÔCð XØ!'×!7Ò!7Ñ!9Ô!9�ð (Ô,�Ø&,¤k°QÒ&6Ð&6¸6¼<È¼?ÈaÒ;OÐ;O˜ œ˜ÐU[�Ø#)¸NÔ<VÐWÐW�å�f�dÑ#Ô#ñ ,	iØ—Z’Z ¨$Ñ/Ô/ˆFð $ vÐ-Ð-°5¸F°?°?ÀgÐQWÐFWÐFWÝ ðNñô ð ð —j’j ¨Ñ-Ô-ˆGØˆà—
’
˜6 4Ñ(Ô(Ð(Ø Ÿ*š* W¨dÑ3Ô3�Ø%Ÿzšz¨/Ñ:Ô:ÐØˆEØˆFØ 4Ô#9Ô#GÒGÐGÝ*Ñ,Ô,ð Ø:Ð:Ð:Ð:Ð:Ð:Ð:å%ðeñô ð ð
 ŸšÝ0:¸6Å2Ä:Ñ0NÔ0NÐZÐ$�EÔ$ VÑ,Ô,Ð,ÐTZØ$ØÔ*Ô8ñô ÷ ’%‘'”'ð	 ð
 Ô.Ô<Ð?OÑO��à�ØÐ!Ø˜!”9˜v aœyÑ(¨6¬<¸¬?Ò:Ð:Ý$Ð%DÑEÔEÐEð !œ, qœ/­3­u°V¸A´YÀÑ5FÑ/GÔ/GÑ+HÔ+HÍ#ÍeÐTZÐ[\ÔT]Ð`eÑTeÑNfÔNfÑJgÔJgÐh�Ý˜&¥2¤:¨u¬|Ð"<Ñ=Ô=ð 	iÝÐgÕX\Ð]cÑXdÔXdÐgÐgÐgÑhÔhÐhØŒ;˜!ÒÐÝ�NŠNð jÐflÔfqð  jð  jð  jñô ð ð —[’[ a�[Ñ(Ô(ˆFàñ 1	:ØÐ&Ø"0°1Ñ"4�å˜/­Cµ¨<Ñ8Ô8ð EØ#2°OÐ"D�à”~ˆHÝ�E .°4Ô3IÔ3WÑ"WÐZbÑ"bÑcÔcÐfnÑnÑoÔoˆIÝ�e O°AÔ$6¸Ô9OÔ9]Ñ$]Ð`hÑ$hÑiÔiÐltÑtÑuÔuˆKÝ�u _°QÔ%7¸$Ô:PÔ:^Ñ%^ÐaiÑ%iÑjÔjÐmuÑuÑvÔvˆLà˜;¨Ñ5Ò5Ð5Ý Ð!QÑRÔRÐRå" 6¨4Ô+AÀ9ÈkÐ[gÐimÔisÑtÔtð (ð (�Ø'˜Ð' Ð'Ð'Ð'Ð'Ð'ð(ð (ð ŒyÐ-Ò-Ð-°&´,¸q´/ÀDÔDZÔDdÒ2dÐ2dØ ×2Ò2ØØ"&Ô"8Ô"FØ$Ø%Ø#'Ø*.ð 3ñ ô �	�	ð ”9Ð 1Ò1Ð1°f°nØ $× 6Ò 6ØØ&*Ô&<Ô&JØ'+Ø.2ð	 !7ñ !ô !�I�Ið !%× 6Ò 6ØØ&*Ô&<Ô&JØ'+Ø.2ð	 !7ñ !ô !�Ið ŒzÐ%Ø%ŸLšL¨t¬z˜LÑ:Ô:�	ØÐ!Ø”9 	Ò)Ð)Ý$Ð%_Ñ`Ô`Ð`à&,�	˜(Ñ#Ø˜dÐ9 iÐ9°5Ð9Ð9Ð9Ð9Ð9Ð9s   Á.BÂBÂBc                 óT  — |                      dd ¦  «        }|                      dd ¦  «        }|                      dd ¦  «        }|                      d¦  «        }|�|�t          d¦  «        ‚| j        dv �rcd|v r|                      d¦  «        }	n>d|v r|                      d¦  «        }	n$t          d	|                     ¦   «         › �¦  «        ‚|pt	          | j        d
d¦  «        }|r-| j        dk    r"t          |¦  «        |d
<   |dk    r
d|d<   d|d<   d|vr
| j        |d<   t          | j        d¦  «        r| j        j	        nd}
|
|	d|i|¥}|r| j        dk    rd|d<    | j        j
        d'i |¤Ž}|dk    r?| j        dk    r4d|vr|d         |d         dœ}nFd„ |d         D ¦   «         }|d         |dœ}n(t          |t          ¦  «        rd|v rd|d         i}nd|i}| j        dk    rí|�||d<   |rät          |t          ¦  «        rÏd|v rË|d         }|rÁ|d         r¹|d         d         d         }t          |t          ¦  «        r|d         n|}|                     d| j        ¦  «        }t          |d¦  «        r[t          |j                             ¦   «         ¦  «        }|                     ¦   «         D ] }||v rt%          j        |g¦  «        |d<    nŒ!�nH| j        dv r¹| j        j	        |                      | j        j	        ¦  «        d|i}	 | j        d'i |	¤Ž}|j        }| j        dk    rd |i}nd|                     d!¬"¦  «        i}|�Md#| j        z  }t          |t.          ¦  «        rt1          |g|¦  «        d         |d<   nšt1          ||¦  «        |d<   n†| j        d$k    rc| j        j	        |                      | j        j	        ¦  «        i}	d|v r|                      d¦  «        |	d<    | j        j
        d'i |	¤Ž}d|j        i}nt          d%| j        › d&�¦  «        ‚|}d|i|¥|¥S )(NÚattention_maskr   Ú
num_framesr,   z0num_frames must be used only when stride is None¾   rf   re   Úinput_featuresÚinput_valueszhSeq2Seq speech recognition model requires either a `input_features` or `input_values` key, but only has r„   Fre   r…   TÚreturn_token_timestampsÚreturn_segmentsrƒ   Úmain_input_namer0   ÚsegmentsrO   Útoken_timestamps)ÚtokensrØ   c                 óJ   — g | ] }t          j        d „ |D ¦   «         ¦  «        ‘Œ!S )c                 ó   — g | ]
}|d          ‘ŒS )rØ   r@   )rD   Úsegments     r!   rG   zJAutomaticSpeechRecognitionPipeline._forward.<locals>.<listcomp>.<listcomp>  s   € Ð"[Ð"[Ð"[À7 7Ð+=Ô#>Ð"[Ð"[Ð"[r#   )r°   Úcat)rD   Úsegment_lists     r!   rG   z?AutomaticSpeechRecognitionPipeline._forward.<locals>.<listcomp>  sA   € ð (ð (ð (à(õ œ	Ð"[Ð"[ÈlÐ"[Ñ"[Ô"[Ñ\Ô\ð(ð (ð (r#   rÙ   r   ÚresultÚ
lang_to_idÚlang_id¾   rm   rl   rl   Úlogitséÿÿÿÿ©Údimr   rk   zUnsupported model type ú.r@   )rŠ   rŒ   rp   Úkeysr‹   rƒ   Úboolr�   r`   rÖ   Úgenerater§   r»   r«   Úsetrà   rs   rI   r°   Útensorrã   Úargmaxr™   Útupler"   rO   )rv   Úmodel_inputsr„   r‚   r~   rÏ   r   rÐ   r,   r0   rÖ   rÙ   ÚoutrØ   r×   rß   Úfull_seqÚ
gen_configÚlang_idsÚtoken_idÚoutputsrã   r   rÆ   s                           r!   Ú_forwardz+AutomaticSpeechRecognitionPipeline._forwardã  sV  € Ø%×)Ò)Ð*:¸DÑAÔAˆØ×!Ò! (¨DÑ1Ô1ˆØ!×%Ò% l°DÑ9Ô9ˆ
Ø×"Ò" 9Ñ-Ô-ˆàÐ *Ð"8ÝÐOÑPÔPÐPàŒ9Ð6Ð6Ñ6ð   <Ð/Ð/Ø%×)Ò)Ð*:Ñ;Ô;��Ø <Ð/Ð/Ø%×)Ò)¨.Ñ9Ô9��å ðbØLX×L]ÒL]ÑL_ÔL_ðbð bñô ð ð !2Ð pµW¸TÔ=SÐUhÐjoÑ5pÔ5pÐØ ð > T¤YÐ2CÒ%CÐ%CÝ7;Ð<MÑ7NÔ7N�Ð 3Ñ4Ø$¨Ò.Ð.ØAE�OÐ$=Ñ>Ø9=�OÐ$5Ñ6ð #¨/Ð9Ð9Ø7;Ô7M�Ð 3Ñ4å<CÀDÄJÐPaÑ<bÔ<bÐp˜dœjÔ8Ð8ÐhpˆOà Ø  .ðð "ðˆOð ð : 4¤9Ð0AÒ#AÐ#AØ59�Ð 1Ñ2à(�T”ZÔ(Ð;Ð;¨?Ð;Ð;ˆFð ! FÒ*Ð*¨t¬yÐ<MÒ/MÐ/MØ VÐ+Ð+Ø%+¨KÔ%8ÈfÐUgÔNhÐiÐi�C�Cð(ð (à,2°:Ô,>ð(ñ (ô (Ð$ð &,¨KÔ%8ÐN^Ð_Ð_�C�CÝ˜F¥DÑ)Ô)ð )¨k¸VÐ.CÐ.CØ ¨Ô!4Ð5��à Ð(�ØŒyÐ-Ò-Ð-ØÐ%Ø$*�C˜‘MØ"ð *¥z°&½$Ñ'?Ô'?ð *ÀJÐRXÐDXÐDXð  & jÔ1�HØð 	* H¨Q¤Kð 	*Ø!)¨!¤¨Q¤°Ô!9˜Ý:DÀVÍTÑ:RÔ:RÐ#^ 6¨+Ô#6Ð#6ÐX^˜Ø%4×%8Ò%8Ð9LÈdÔNdÑ%eÔ%e˜
Ý" :¨|Ñ<Ô<ð *Ý'*¨:Ô+@×+GÒ+GÑ+IÔ+IÑ'JÔ'J˜HØ,4¯OªOÑ,=Ô,=ð *ð * Ø#+¨xÐ#7Ð#7Ý5:´\À8À*Ñ5MÔ5M C¨	¡NØ$) Eð $8ùð ŒYÐ0Ð0Ð0à”
Ô*¨L×,<Ò,<¸T¼ZÔ=WÑ,XÔ,XØ  .ðˆFð !�d”jÐ*Ð* 6Ð*Ð*ˆGØ”^ˆFàŒy˜MÒ)Ð)Ø Ð(��à §¢°2 Ñ!6Ô!6Ð7�ØÐ!ð ˜DœNÑ*�Ý˜f¥eÑ,Ô,ð BÝ$2°F°8¸UÑ$CÔ$CÀAÔ$F�C˜‘M�Må$2°6¸5Ñ$AÔ$A�C˜‘MøØŒY˜%ÒÐà”
Ô*¨L×,<Ò,<¸T¼ZÔ=WÑ,XÔ,XðˆFð   <Ð/Ð/Ø+7×+;Ò+;Ð<LÑ+MÔ+M�Ð'Ñ(Ø)�d”jÔ)Ð3Ð3¨FÐ3Ð3ˆGØ˜WÔ.Ð/ˆCˆCåÐC°t´yÐCÐCÐCÑDÔDÐDð ˆØ˜7Ð3 cÐ3¨UÐ3Ð3r#   r�   c                 ó	  — i }g }| j         dk    rdnd}d }|D ]È}	|	|         j        t          j        t          j        fv r8|	|                              t          j        ¦  «                             ¦   «         }
n|	|                              ¦   «         }
|	                     dd ¦  «        }|�"| j         dv r|\  }}}||z
  }|
d d …||…f         }
| 	                    |
¦  «         ŒÉ|r"| j         dk    rt          || j        ¦  «        }
�nD| j         dk    �r| j        j        | j        j        j        z  }| j        j        }|D ])}d|v r#|d         \  }}}||z  }||z  }||z  }|||f|d<   Œ*|r“|D ]�}d|v rŠ|d         }|                     ¦   «         d	k    r|                     d	¦  «        }|                     d	¦  «                             |d         j        ¬
¦  «        }t          j        ||d         gd¬¦  «        |d<   Œ‘| j                             ||||¬¦  «        \  }}n+t-          j        |d¬¦  «        }
|
                     d	¦  «        }
| j         dk    r\|€i } | j        j        |
fi |¤Ž}|d	         d	         }|r4|d	         d         }g }|D ]!\  }\  }}| 	                    |||dœ¦  «         Œ"n…| j         dk    rz| j         dk    }| j         dk    rddini } | j        j        |
fd|i|¤Ž}|rG | j        j        |
f|ddœ|¤Žd         }|dk    r%| j                             || j        j        ¦  «        }|rp| j         dvrgg } | j        }!|D ]V}"|"d         |!z  }#|#| j        j        z  }#|"d         |!z  }$|$| j        j        z  }$|  	                    |"|         |#|$fdœ¦  «         ŒW| |d<   t?          t@          ¦  «        }%|D ]»}| !                    dd ¦  «         | !                    dd ¦  «         | !                    d d ¦  «         | !                    dd ¦  «         | !                    d!d ¦  «         | !                    dd ¦  «         | "                    ¦   «         D ] \  }&}'|%|&          	                    |'¦  «         Œ!Œ¼d"|i|¥|%¥S )#Nrl   rã   rÙ   r   râ   rf   re   rá   r   r*   rä   rå   )r„   r‚   Útime_precisionr   r¡   r   )r…   Ústart_offsetÚ
end_offsetrm   rk   Úgroup_tokensFÚskip_special_tokensT)rü   Úoutput_char_offsetsÚchar_offsetsr…   rÑ   rù   rú   )ÚtextÚ	timestampÚchunksr,   rØ   rÿ   )#rp   r+   r°   Úbfloat16Úfloat16r/   Úfloat32r³   r«   r   rY   rF   r1   Úchunk_lengthr`   rn   Úmax_source_positionsr'   ræ   Ú	unsqueezerÝ   Ú_decode_asrrK   ÚconcatenateÚsqueezera   Údecode_beamsÚdecodeÚ_get_word_offsetsÚreplace_word_delimiter_charr™   r   ÚlistrŠ   Úitems)(rv   Úmodel_outputsr�   r„   r‚   ÚoptionalÚfinal_itemsÚkeyr   rõ   r  Útotal_nr   r   Úright_nrø   r'   Úoutputr2   r3   r4   rá   Ú
lang_tokenrÿ   ÚbeamsÚchunk_offsetÚoffsetsr…   rù   rú   rü   Údecode_kwargsr  r˜   rÌ   ÚstartÚstoprÆ   ÚkÚvs(                                           r!   Úpostprocessz.AutomaticSpeechRecognitionPipeline.postprocessX  s�  € ð ˆàˆØœ) }Ò4Ð4ˆhˆh¸(ˆØˆØ$ð 	&ð 	&ˆGØ�sŒ|Ô!¥e¤nµe´mÐ%DÐDÐDØ œŸš­¬Ñ6Ô6×<Ò<Ñ>Ô>��à œ×*Ò*Ñ,Ô,�Ø—[’[ ¨4Ñ0Ô0ˆFØÐ! d¤iÐ3IÐ&IÐ&IØ'-Ñ$�˜˜uð
 " E™/�Ø˜a˜a˜a  g ˜oÔ.�Ø×Ò˜uÑ%Ô%Ð%Ð%àð #	%�d”i 9Ò,Ð,Ý1°+¸t¼~ÑNÔNˆE‰EØŒYÐ+Ò+Ñ+Ø!Ô3Ô@À4Ä:ÔCTÔCiÑiˆNà Ô2Ô@ˆMØ'ð Lð L�Ø˜vÐ%Ð%Ø;AÀ(Ô;KÑ8�I˜{¨Là Ñ.�IØ =Ñ0�KØ  MÑ1�LØ'0°+¸|Ð'K�F˜8Ñ$øð
 ð ]Ø+ð ]ð ]�FØ  FÐ*Ð*Ø"(¨Ô"3˜Ø"Ÿ;š;™=œ=¨AÒ-Ð-Ø&-×&7Ò&7¸Ñ&:Ô&:˜GØ%,×%6Ò%6°qÑ%9Ô%9×%<Ò%<À6È(ÔCSÔCYÐ%<Ñ%ZÔ%Z˜
Ý+0¬9°jÀ&ÈÔBRÐ5SÐY[Ð+\Ñ+\Ô+\˜˜xÑ(øà!œ^×7Ò7ØØ"3Ø /Ø-ð	 8ñ ô ‰NˆD�(�(õ ”N ;°QÐ7Ñ7Ô7ˆEØ—M’M !Ñ$Ô$ˆEàŒ9˜Ò%Ð%ØÐ%Ø!#�Ø-�D”LÔ-¨eÐFÐF°~ÐFÐFˆEØ˜”8˜A”;ˆDØ ð kð  % Qœx¨œ{�Ø�Ø8Dð kð kÑ4�DÑ4˜<¨Ø—N’N¨DÀ,Ð^hÐ#iÐ#iÑjÔjÐjÐjøØŒYÐ+Ò+Ð+Ø"&¤)¨uÒ"4Ðð 8<´yÀEÒ7IÐ7I˜^¨UÐ3Ð3ÈrˆMØ(�4”>Ô(¨ÐiÐiÐDWÐiÐ[hÐiÐiˆDØ ð tØ/˜$œ.Ô/ØðØ/BÐX\ðð Ø`mðð à ô"�ð %¨Ò.Ð.Ø"œn×>Ò>¸wÈÌÔHrÑsÔs�Gàð 	( ¤Ð2PÐ!PÐ!PØˆFØ”~ˆHØð ]ð ]�Ø˜^Ô,¨xÑ7�Ø˜Ô/Ô=Ñ=�à˜LÔ)¨HÑ4�Ø˜Ô.Ô<Ñ<�à—’ tÐ,=Ô'>ÈeÐUYÈ]Ð[Ð[Ñ\Ô\Ð\Ð\Ø!'ˆH�XÑå�DÑ!Ô!ˆØ#ð 	#ð 	#ˆFØ�JŠJ�x Ñ&Ô&Ð&Ø�JŠJ�x Ñ&Ô&Ð&Ø�JŠJ�y $Ñ'Ô'Ð'Ø�JŠJ�x Ñ&Ô&Ð&Ø�JŠJÐ)¨4Ñ0Ô0Ð0Ø�JŠJ�y $Ñ'Ô'Ð'ØŸš™œð #ð #‘��1Ø�a”—’ Ñ"Ô"Ð"Ð"ð#à˜Ð2 Ð2¨EÐ2Ð2r#   )NNNN)NNNNNN)r   N)FN)NNN)rr   Ú
__module__Ú__qualname__Ú__doc__Ú_pipeline_calls_generateÚ_load_processorÚ_load_image_processorÚ_load_feature_extractorÚ_load_tokenizerr   Ú_default_generation_configr   r¨   r	   r   ru   rK   r¿   r¯   r»   r   r  rz   r“   Úpropertyr™   rÍ   rö   r!  Ú__classcell__)rq   s   @r!   r[   r[   p   s  ø€ € € € € ð'ð 'ðR  $ÐØ€OØ!ÐØ"ÐØ€Oà!1Ð!1ØØð"ñ "ô "Ðð LPØ04Ø=AØ48ðWð Wà ðWð !Ð!;¸SÐ!@ÔAÀDÑHðWð '¨Ñ-ð	Wð
 Ð-¨sÐ2Ô3°dÑ:ðWð �c˜>Ð)Ô*¨TÑ1ðWð Wð Wð Wð Wð Wð292˜rœz¨EÑ1°CÑ7¸$Ñ>ð 92È#ð 92ÐRVÐW[Ð\_ÐadÐ\dÔWeÔRfð 92ð 92ð 92ð 92ð 92ð 92ðz ØØØØØðPEð PEð PEð PEðd ðð ñ „XððH:ð H:ð H:ð H:ðTs4ð s4ð s4ð s4ðl jnðn3ð n3Ø-1°D©[ðn3ð n3ð n3ð n3ð n3ð n3ð n3ð n3r#   r[   )N)&Úcollectionsr   Útypingr   r   r   rª   r³   rK   Ú
generationr   Útokenization_pythonr	   Úutilsr
   r   r   r   Úaudio_utilsr   Úbaser   Úpyctcdecoder   Ú!feature_extraction_sequence_utilsr   Úmodeling_utilsr   Ú
get_loggerrr   r‡   r°   Úmodels.auto.modeling_autor   r"   r=   rY   r[   r@   r#   r!   ú<module>r9     s§  ðð $Ð #Ð #Ð #Ð #Ð #Ø ,Ð ,Ð ,Ð ,Ð ,Ð ,Ð ,Ð ,Ð ,Ð ,à €€€Ø Ð Ð Ð à )Ð )Ð )Ð )Ð )Ð )Ø 5Ð 5Ð 5Ð 5Ð 5Ð 5Ø aÐ aÐ aÐ aÐ aÐ aÐ aÐ aÐ aÐ aÐ aÐ aØ $Ð $Ð $Ð $Ð $Ð $Ø Ð Ð Ð Ð Ð ð ð 1Ø0Ð0Ð0Ð0Ð0Ð0àLÐLÐLÐLÐLÐLØ0Ð0Ð0Ð0Ð0Ð0à	ˆÔ	˜HÑ	%Ô	%€àÐÑÔð UØ€L€L€LàTÐTÐTÐTÐTÐTðð ð ð(ð ð ð ð4ð ð ð2V	3ð V	3ð V	3ð V	3ð V	3¨ñ V	3ô V	3ð V	3ð V	3ð V	3r#   