o
    iD                     @   sf   d Z ddlZddlZddlZddlZddlZddlZdd Zdd Z	e
dkr1e	ejdd  dS dS )	z1Neural machine translation model decoding script.    Nc                  C   s  t jdt jt jd} | jdddd | jdddd | jd	dd
d | jdtddd | jddddd | jdtdddgdd | jdtddd | jdtddd | jddtdd d | jd!tdd"d | jd#td$d%d | jd&d'd'd(gd)d* | jd+td,d- | jd.tdd/d0 | jd1tdd2d0 | jd3td$d4d | jd5tdd6d | jd7tdd8d | jd9td:d;d | jd<td=d>d | jd?td@dAd | jdBdCtdDdE | S )FzGet default arguments.zMTranslate text from speech using a speech translation model on one CPU or GPU)descriptionconfig_file_parser_classformatter_classz--configTzConfig file path)is_config_filehelpz	--config2zBSecond config file path that overwrites the settings in `--config`z	--config3zQThird config file path that overwrites the settings in `--config` and `--config2`z--ngpur   zNumber of GPUs)typedefaultr   z--dtype)float16float32float64r
   z,Float precision (only available in --api v2))choicesr   r   z	--backendchainerpytorchzBackend library)r   r   r   r   z--debugmode   	Debugmodez--seedzRandom seedz	--verbosez-VzVerbose optionz--batchsizez9Batch size for beam search (0: means no batch processing)z--preprocess-confNz-The configuration file for the pre-processingz--apiv1v2zBeam search APIs v1: Default API. It only supports the ASRInterface.recognize method and DefaultRNNLM. v2: Experimental API. It supports any models that implements ScorerInterface.)r   r   r   z--trans-jsonz#Filename of translation data (json))r   r   z--result-labelz$Filename of result label data (json))r   requiredr   z--modelzModel file parameters to readz--model-confzModel config filez--nbestzOutput N-best hypothesesz--beam-sizez	Beam sizez	--penaltyg?zIncertion penaltyz--maxlenratiog      @zInput length ratio to obtain max output length.
                        If maxlenratio=0.0 (default), it uses a end-detect function
                        to automatically find maximum hypothesis lengthsz--minlenratiog        z.Input length ratio to obtain min output lengthz
--tgt-langFz4target language ID (e.g., <en>, <de>, and <fr> etc.))r   r   r   )	configargparseArgumentParserYAMLConfigFileParserArgumentDefaultsHelpFormatteraddadd_argumentintstrfloat)parser r   G/home/ubuntu/.local/lib/python3.10/site-packages/espnet/bin/mt_trans.py
get_parser   s   r    c                 C   sj  t  }|| } | jdkrtjtjdd n| jdkr$tjtjdd ntjtjdd td | j	dkrit
jd}|du rFtd	 n| j	t|d
krZtd td | j	dkritd td tdt
jdd  t| j tj| j td| j  td| j  | jdkrddlm} | jdkrtd| j d||  dS td)zRun the main decoding function.r   z>%(asctime)s (%(module)s:%(lineno)d) %(levelname)s: %(message)s)levelformat   zSkip DEBUG/INFO messagesr   CUDA_VISIBLE_DEVICESNz CUDA_VISIBLE_DEVICES is not set.,z/#gpus is not matched with CUDA_VISIBLE_DEVICES.z!The program only supports ngpu=1.zpython path = 
PYTHONPATHz(None)zset random seed = %dz
backend = r   )transr
   z	`--dtype z#` is only available with `--api v2`zOnly pytorch are supported.)r    
parse_argsverboseloggingbasicConfigINFODEBUGWARNwarningngpuosenvirongetlenspliterrorsysexitinforandomseednpbackendespnet.mt.pytorch_backend.mtr'   dtypeNotImplementedError
ValueError)argsr   cvdr'   r   r   r   main}   sP   











rD   __main__r   )__doc__r*   r1   r:   r7   r   numpyr<   r    rD   __name__argvr   r   r   r   <module>   s   j<