Esempio n. 1
0
 def build_preprocess_fn(
     cls, args: argparse.Namespace, train: bool
 ) -> Optional[Callable[[str, Dict[str, np.array]], Dict[str, np.ndarray]]]:
     assert check_argument_types()
     if args.use_preprocessor:
         retval = CommonPreprocessor(
             train=train,
             token_type=args.token_type,
             token_list=args.token_list,
             bpemodel=args.bpemodel,
             non_linguistic_symbols=args.non_linguistic_symbols,
             text_cleaner=args.cleaner,
             g2p_type=args.g2p,
             # NOTE(kamo): Check attribute existence for backward compatibility
             rir_scp=args.rir_scp if hasattr(args, "rir_scp") else None,
             rir_apply_prob=args.rir_apply_prob if hasattr(
                 args, "rir_apply_prob") else 1.0,
             noise_scp=args.noise_scp
             if hasattr(args, "noise_scp") else None,
             noise_apply_prob=args.noise_apply_prob if hasattr(
                 args, "noise_apply_prob") else 1.0,
             noise_db_range=args.noise_db_range if hasattr(
                 args, "noise_db_range") else "13_15",
             short_noise_thres=args.short_noise_thres if hasattr(
                 args, "short_noise_thres") else 0.5,
             speech_volume_normalize=args.speech_volume_normalize
             if hasattr(args, "rir_scp") else None,
         )
     else:
         retval = None
     assert check_return_type(retval)
     return retval
Esempio n. 2
0
 def build_preprocess_fn(
     cls, args: argparse.Namespace, train: bool
 ) -> Optional[Callable[[str, Dict[str, np.array]], Dict[str, np.ndarray]]]:
     assert check_argument_types()
     if args.use_preprocessor:
         # FIXME (jiatong): add more argument here
         retval = CommonPreprocessor(train=train)
     else:
         retval = None
     assert check_return_type(retval)
     return retval
Esempio n. 3
0
File: lm.py Progetto: zy1022/espnet
 def build_preprocess_fn(
     cls, args: argparse.Namespace, train: bool
 ) -> Optional[Callable[[str, Dict[str, np.array]], Dict[str, np.ndarray]]]:
     assert check_argument_types()
     if args.use_preprocessor:
         retval = CommonPreprocessor(
             train=train,
             token_type=args.token_type,
             token_list=args.token_list,
             bpemodel=args.bpemodel,
         )
     else:
         retval = None
     assert check_return_type(retval)
     return retval
Esempio n. 4
0
    def build_preprocess_fn(
        cls, args: argparse.Namespace, train: bool
    ) -> Optional[Callable[[str, Dict[str, np.array]], Dict[str, np.ndarray]]]:
        """Build pre-processing function.

        Args:
            cls: ASRTransducerTask object.
            args: Task arguments.
            train: Training mode.

        Return:
            : Callable pre-processing function.

        """
        assert check_argument_types()

        if args.use_preprocessor:
            retval = CommonPreprocessor(
                train=train,
                token_type=args.token_type,
                token_list=args.token_list,
                bpemodel=args.bpemodel,
                non_linguistic_symbols=args.non_linguistic_symbols,
                text_cleaner=args.cleaner,
                g2p_type=args.g2p,
                rir_scp=args.rir_scp if hasattr(args, "rir_scp") else None,
                rir_apply_prob=args.rir_apply_prob if hasattr(
                    args, "rir_apply_prob") else 1.0,
                noise_scp=args.noise_scp
                if hasattr(args, "noise_scp") else None,
                noise_apply_prob=args.noise_apply_prob if hasattr(
                    args, "noise_apply_prob") else 1.0,
                noise_db_range=args.noise_db_range if hasattr(
                    args, "noise_db_range") else "13_15",
                speech_volume_normalize=args.speech_volume_normalize
                if hasattr(args, "rir_scp") else None,
            )
        else:
            retval = None

        assert check_return_type(retval)
        return retval