montreal_forced_aligner/ivector/trainer.py
def parse_parameters(
        cls,
        config_path: Optional[str] = None,
        args: Optional[Namespace] = None,
        unknown_args: Optional[List[str]] = None,
    ) -> MetaDict:
        """
        Parse configuration parameters from a config file and command line arguments

        Parameters
        ----------
        config_path: str, optional
            Path to yaml configuration file
        args: :class:`~argparse.Namespace`, optional
            Arguments parsed by argparse
        unknown_args: list[str], optional
            List of unknown arguments from argparse

        Returns
        -------
        dict[str, Any]
            Dictionary of specified configuration parameters
        """
        global_params = {}
        training_params = []
        use_default = True
        if config_path is not None:
            with open(config_path, "r", encoding="utf8") as f:
                data = yaml.load(f, Loader=yaml.SafeLoader)
                training_params = []
                for k, v in data.items():
                    if k == "training":
                        for t in v:
                            for k2, v2 in t.items():
                                if "features" in v2:
                                    global_params.update(v2["features"])
                                    del v2["features"]
                                training_params.append((k2, v2))
                    elif k == "features":
                        if "type" in v:
                            v["feature_type"] = v["type"]
                            del v["type"]
                        global_params.update(v)
                    else:
                        if v is None and k in {
                            "punctuation",
                            "compound_markers",
                            "clitic_markers",
                        }:
                            v = []
                        global_params[k] = v
                if training_params:
                    use_default = False
        if use_default:  # default training configuration
            training_params.append(("dubm", {}))
            # training_params.append(("ubm", {}))
            training_params.append(("ivector", {}))
        if training_params:
            if training_params[0][0] != "dubm":
                raise ConfigError("The first round of training must be dubm.")
        global_params["training_configuration"] = training_params
        global_params.update(cls.parse_args(args, unknown_args))
        return global_params

        Parse configuration parameters from a config file and command line arguments

        Parameters
        ----------
        config_path: str, optional
            Path to yaml configuration file
        args: :class:`~argparse.Namespace`, optional
            Arguments parsed by argparse
        unknown_args: list[str], optional
            List of unknown arguments from argparse

        Returns
        -------
        dict[str, Any]
            Dictionary of specified configuration parameters
        
Parse configuration parameters from a config file and command line arguments
Parameters

str, optional
Path to yaml configuration file
args: :class:`~argparse.Namespace`, optional
Arguments parsed by argparse
unknown_args: list[str], optional
List of unknown arguments from argparse

Returns

dict[str, Any]
Dictionary of specified configuration parameters
Parse configuration parameters from a config file and command line arguments Parameters str optional Path to yaml configuration file args : : class : ` ~argparse . Namespace ` optional Arguments parsed by argparse unknown_args : list [ str ] optional List of unknown arguments from argparse Returns dict [ str Any ] Dictionary of specified configuration parameters
def parse_parameters(
        cls,
        config_path: Optional[str] = None,
        args: Optional[Namespace] = None,
        unknown_args: Optional[List[str]] = None,
    ) -> MetaDict:
        global_params = {}
        training_params = []
        use_default = True
        if config_path is not None:
            with open(config_path, "r", encoding="utf8") as f:
                data = yaml.load(f, Loader=yaml.SafeLoader)
                training_params = []
                for k, v in data.items():
                    if k == "training":
                        for t in v:
                            for k2, v2 in t.items():
                                if "features" in v2:
                                    global_params.update(v2["features"])
                                    del v2["features"]
                                training_params.append((k2, v2))
                    elif k == "features":
                        if "type" in v:
                            v["feature_type"] = v["type"]
                            del v["type"]
                        global_params.update(v)
                    else:
                        if v is None and k in {
                            "punctuation",
                            "compound_markers",
                            "clitic_markers",
                        }:
                            v = []
                        global_params[k] = v
                if training_params:
                    use_default = False
        if use_default:  
            training_params.append(("dubm", {}))
            training_params.append(("ivector", {}))
        if training_params:
            if training_params[0][0] != "dubm":
                raise ConfigError("The first round of training must be dubm.")
        global_params["training_configuration"] = training_params
        global_params.update(cls.parse_args(args, unknown_args))
        return global_params
def parse_parameters ( cls , config_path : Optional [ str ] = None , args : Optional [ Namespace ] = None , unknown_args : Optional [ List [ str ] ] = None , ) -> MetaDict : global_params = { } training_params = [ ] use_default = True if config_path is not None : with open ( config_path , "r" , encoding = "utf8" ) as f : data = yaml . load ( f , Loader = yaml . SafeLoader ) training_params = [ ] for k , v in data . items ( ) : if k == "training" : for t in v : for k2 , v2 in t . items ( ) : if "features" in v2 : global_params . update ( v2 [ "features" ] ) del v2 [ "features" ] training_params . append ( ( k2 , v2 ) ) elif k == "features" : if "type" in v : v [ "feature_type" ] = v [ "type" ] del v [ "type" ] global_params . update ( v ) else : if v is None and k in { "punctuation" , "compound_markers" , "clitic_markers" , } : v = [ ] global_params [ k ] = v if training_params : use_default = False if use_default : training_params . append ( ( "dubm" , { } ) ) training_params . append ( ( "ivector" , { } ) ) if training_params : if training_params [ 0 ] [ 0 ] != "dubm" : raise ConfigError ( "The first round of training must be dubm." ) global_params [ "training_configuration" ] = training_params global_params . update ( cls . parse_args ( args , unknown_args ) ) return global_params
Parse configuration parameters from a config file and command line arguments
Parameters
Parse configuration parameters from a config file and command line arguments Parameters
"""
        Parse configuration parameters from a config file and command line arguments

        Parameters
        ----------
        config_path: str, optional
            Path to yaml configuration file
        args: :class:`~argparse.Namespace`, optional
            Arguments parsed by argparse
        unknown_args: list[str], optional
            List of unknown arguments from argparse

        Returns
        -------
        dict[str, Any]
            Dictionary of specified configuration parameters
        """ # default training configuration # training_params.append(("ubm", {}))
cls
config_path
Optional[str]
args
Optional[Namespace]
unknown_args
Optional[List[str]]