o
    i                     @   sz   d dl Z d dlZd dlZd dlZd dlmZ d dlZd dlZd dl	m
Z
 dd Zdd Zedkr;eejd	d  dS dS )
    N)	strtobool)enhancec                  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dtdd | jddtddgdd | jddtdd | jddtdd | jdddtdd | jddtdd | jdtd dd  | jd!td"d# | jd$tdd%d& | jd'td d(d  | jd)td d*d  | jd+td,g d-d.d/ | jd0td1d2d  | jd3tdd4d  | jd5td d6d  | jd7td8d9d  | jd:tdd;d  | jd<td=d>d  | jd?td@dAd  | jdBtdCdAd  | S )DNz+Enhance noisy speech for speech recognition)descriptionconfig_file_parser_classformatter_classz--configTzconfig file path)is_config_filehelpz	--config2zCsecond config file path that overwrites the settings in `--config`.z	--config3zRthird config file path that overwrites the settings in `--config` and `--config2`.z--ngpur   zNumber of GPUs)defaulttyper   z	--backendchainerpytorchzBackend library)r	   r
   choicesr   z--debugmode   	Debugmodez--seedzRandom seedz	--verbosez-VzVerbose optionz--batchsizez9Batch size for beam search (0: means no batch processing)z--preprocess-confz-The configuration file for the pre-processing)r
   r	   r   z--recog-jsonz#Filename of recognition data (json))r
   r   z--modelzModel file parameters to read)r
   requiredr   z--model-confzModel config filez--enh-wspecifierzFSpecify the output way for enhanced speech.e.g. ark,scp:outdir,wav.scpz--enh-filetypesound)mathdf5z
sound.hdf5r   zPSpecify the file format for enhanced speech. "mat" is the matrix format in kaldi)r
   r	   r   r   z--fsi>  zThe sample frequencyz--keep-lengthzDAdjust the output length to match with the input for enhanced speechz--image-dirz The directory saving the images.z--num-images   zQThe number of images files to be saved. If negative, all samples are to be saved.z--apply-istftz*Apply istft to the output from the networkz--istft-win-lengthi   z[The window length for istft. This option is ignored if stft is found in the preprocess-confz--istft-n-shift   zYThe window type for istft. This option is ignored if stft is found in the preprocess-confz--istft-windowhann)	configargparseArgumentParserYAMLConfigFileParserArgumentDefaultsHelpFormatteraddadd_argumentintstrr   )parser r    J/home/ubuntu/.local/lib/python3.10/site-packages/espnet/bin/asr_enhance.py
get_parser   s   	r"   c                 C   sB  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rt|  d S td)Nr   z>%(asctime)s (%(module)s:%(lineno)d) %(levelname)s: %(message)s)levelformat   zSkip DEBUG/INFO messagesr   CUDA_VISIBLE_DEVICESz 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   zOnly pytorch is supported.)r"   
parse_argsverboseloggingbasicConfigINFODEBUGWARNwarningngpuosenvirongetlenspliterrorsysexitinforandomseednpbackendr   
ValueError)argsr   cvdr    r    r!   main   sF   










rB   __main__r   )r+   r2   r;   r8   distutils.utilr   r   numpyr=   espnet.asr.pytorch_backend.asrr   r"   rB   __name__argvr    r    r    r!   <module>   s   {4