
    9i>	                        S SK JrJrJrJr  S SKrS SKJr  S SKJ	r	J
r
  S SKJrJr  S SKJr  S SKJr  S SKJrJrJr  S S	KJr  S S
KJr  \" 5       r\R6                  " \R8                  \R:                  S9 " S S\5      5       rg)    )AnyDictOptionalUnionN)	Pipelines)MPlugForAllTasksOfaForAllTasks)ModelPipeline)	PIPELINES)batch_process)MPlugPreprocessorOfaPreprocessorPreprocessor)Tasks)
get_logger)module_namec                      ^  \ rS rSr SS\\\4   S\\   4U 4S jjjr	U 4S jr
S\\\4   S\\\4   4U 4S jjrS\\\4   S\\\4   4S	 jrS
rU =r$ )"AutomaticSpeechRecognitionPipeline   modelpreprocessorc                   > [        U[        5      (       d  [        U[        5      (       d   S5       e[        U[        5      (       a  [        R                  " U5      nO[        U[        5      (       a  UnO[        eUR
                  R                  5         UcU  [        U[        5      (       a  [        UR                  5      nO*[        U[        5      (       a  [        UR                  5      n[        TU ]4  " SXBS.UD6  g)z
use `model` and `preprocessor` to create an automatic speech recognition pipeline for prediction
Args:
    model: model id on modelscope hub.
z,model must be a single str or OfaForAllTasksN)r   r    )
isinstancestrr
   from_pretrainedNotImplementedErrorr   evalr	   r   	model_dirr   r   super__init__)selfr   r   kwargs
pipe_model	__class__s        m/var/www/html/land-doc-ocr/venv/lib/python3.13/site-packages/modelscope/pipelines/multi_modal/asr_pipeline.pyr"   +AutomaticSpeechRecognitionPipeline.__init__   s     %%%E5)A)A 	;:	;AeS!!..u5Ju%%J%%*n55.z/C/CDJ(89901E1EFOzOO    c                    > [        U R                  [        5      (       a  [        U R                  U5      $ [        [
        U ]  U5      $ N)r   r   r	   r   r!   r   _batch)r#   datar&   s     r'   r,   )AutomaticSpeechRecognitionPipeline._batch0   s8    djj.11 T22;TI$OOr)   inputsreturnc                    > [         R                  " 5          [        TU ]  " U40 UD6sS S S 5        $ ! , (       d  f       g = fr+   )torchno_gradr!   forward)r#   r/   forward_paramsr&   s      r'   r4   *AutomaticSpeechRecognitionPipeline.forward6   s'    ]]_7?6<^< __s	   2
A c                     U$ r+   r   )r#   r/   s     r'   postprocess.AutomaticSpeechRecognitionPipeline.postprocess;   s    r)   r   r+   )__name__
__module____qualname____firstlineno__r   r
   r   r   r   r"   r,   r   r   r4   r8   __static_attributes____classcell__)r&   s   @r'   r   r      s     9=PeSj)P'5P P2P=d38n =%)#s(^=
$sCx. T#s(^  r)   r   )typingr   r   r   r   r2   modelscope.metainfor   modelscope.models.multi_modalr   r	   modelscope.pipelines.baser
   r   modelscope.pipelines.builderr   modelscope.pipelines.utilr   modelscope.preprocessorsr   r   r   modelscope.utils.constantr   modelscope.utils.loggerr   loggerregister_moduleauto_speech_recognitionofa_asrr   r   r)   r'   <module>rM      sm    - -  ) J 5 2 34 4 + .	 	!!y/@/@B' 'B'r)   