def validate_args(args: Namespace) -> None: """ Validate the command line arguments Parameters ---------- args: :class:`~argparse.Namespace` Parsed command line arguments Raises ------ :class:`~montreal_forced_aligner.exceptions.ArgumentError` If there is a problem with any arguments """ try: args.speaker_characters = int(args.speaker_characters) except ValueError: pass args.output_directory = args.output_directory.rstrip("/").rstrip("\\") args.corpus_directory = args.corpus_directory.rstrip("/").rstrip("\\") if not os.path.exists(args.corpus_directory): raise ArgumentError( f"Could not find the corpus directory {args.corpus_directory}.") if not os.path.isdir(args.corpus_directory): raise ArgumentError( f"The specified corpus directory ({args.corpus_directory}) is not a directory." ) args.dictionary_path = validate_model_arg(args.dictionary_path, "dictionary") args.acoustic_model_path = validate_model_arg(args.acoustic_model_path, "acoustic")
def validate_args(args: Namespace) -> None: """ Validate the command line arguments Parameters ---------- args: :class:`~argparse.Namespace` Parsed command line arguments Raises ------ :class:`~montreal_forced_aligner.exceptions.ArgumentError` If there is a problem with any arguments """ try: args.speaker_characters = int(args.speaker_characters) except ValueError: pass if args.test_transcriptions and args.ignore_acoustics: raise ArgumentError( "Cannot test transcriptions without acoustic feature generation.") if not os.path.exists(args.corpus_directory): raise (ArgumentError( f"Could not find the corpus directory {args.corpus_directory}.")) if not os.path.isdir(args.corpus_directory): raise (ArgumentError( f"The specified corpus directory ({args.corpus_directory}) is not a directory." )) args.dictionary_path = validate_model_arg(args.dictionary_path, "dictionary") if args.acoustic_model_path: args.acoustic_model_path = validate_model_arg(args.acoustic_model_path, "acoustic")
def validate_args(args: Namespace) -> None: # pragma: no cover """ Validate the command line arguments Parameters ---------- args: :class:`~argparse.Namespace` Parsed command line arguments Raises ------ :class:`~montreal_forced_aligner.exceptions.ArgumentError` If there is a problem with any arguments """ args.output_directory = args.output_directory.rstrip("/").rstrip("\\") args.corpus_directory = args.corpus_directory.rstrip("/").rstrip("\\") if args.cluster and not args.num_speakers: raise ArgumentError( "If using clustering, num_speakers must be specified") if not os.path.exists(args.corpus_directory): raise ArgumentError( f"Could not find the corpus directory {args.corpus_directory}.") if not os.path.isdir(args.corpus_directory): raise ArgumentError( f"The specified corpus directory ({args.corpus_directory}) is not a directory." ) if args.corpus_directory == args.output_directory: raise ArgumentError( "Corpus directory and output directory cannot be the same folder.") args.ivector_extractor_path = validate_model_arg( args.ivector_extractor_path, "ivector")
def validate_dictionary_args(args: Namespace) -> None: """ Validate the command line arguments Parameters ---------- args: :class:`~argparse.Namespace` Parsed command line arguments Raises ------ :class:`~montreal_forced_aligner.exceptions.ArgumentError` If there is a problem with any arguments """ if sys.platform == "win32": raise ArgumentError( "Cannot validate dictionaries on native Windows, please use Windows Subsystem for Linux." ) args.dictionary_path = validate_model_arg(args.dictionary_path, "dictionary") if args.g2p_model_path: args.g2p_model_path = validate_model_arg(args.g2p_model_path, "g2p")
def validate_args(args: Namespace) -> None: """ Validate the command line arguments Parameters ---------- args: :class:`~argparse.Namespace` Parsed command line arguments Raises ------ :class:`~montreal_forced_aligner.exceptions.ArgumentError` If there is a problem with any arguments """ args.dictionary_path = validate_model_arg(args.dictionary_path, "dictionary")
def validate_args(args: Namespace) -> None: """ Validate the command line arguments Parameters ---------- args: :class:`~argparse.Namespace` Parsed command line arguments Raises ------ :class:`~montreal_forced_aligner.exceptions.ArgumentError` If there is a problem with any arguments """ try: args.speaker_characters = int(args.speaker_characters) except ValueError: pass args.output_directory = None if not args.output_model_path: args.output_model_path = None output_paths = args.output_paths if len(output_paths) > 2: raise ArgumentError(f"Got more arguments for output_paths than 2: {output_paths}") for path in output_paths: if path.endswith(".zip"): args.output_model_path = path else: args.output_directory = path.rstrip("/").rstrip("\\") args.corpus_directory = args.corpus_directory.rstrip("/").rstrip("\\") if args.corpus_directory == args.output_directory: raise ArgumentError("Corpus directory and output directory cannot be the same folder.") if not os.path.exists(args.corpus_directory): raise (ArgumentError(f'Could not find the corpus directory "{args.corpus_directory}".')) if not os.path.isdir(args.corpus_directory): raise ( ArgumentError( f'The specified corpus directory "{args.corpus_directory}" is not a directory.' ) ) args.dictionary_path = validate_model_arg(args.dictionary_path, "dictionary")
def validate_args(args: Namespace) -> None: """ Validate the command line arguments Parameters ---------- args: :class:`~argparse.Namespace` Parsed command line arguments Raises ------ :class:`~montreal_forced_aligner.exceptions.ArgumentError` If there is a problem with any arguments """ args.source_path = args.source_path.rstrip("/").rstrip("\\") if args.dictionary_path: args.dictionary_path = validate_model_arg(args.dictionary_path, "dictionary") if not args.source_path.endswith(".arpa"): if not os.path.exists(args.source_path): raise (ArgumentError( f"Could not find the corpus directory {args.source_path}.")) if not os.path.isdir(args.source_path): raise (ArgumentError( f"The specified corpus directory ({args.source_path}) is not a directory." )) else: if not os.path.exists(args.source_path): raise (ArgumentError( f"Could not find the source file {args.source_path}.")) if args.config_path and not os.path.exists(args.config_path): raise (ArgumentError( f"Could not find the config file {args.config_path}.")) if args.model_path and not os.path.exists(args.model_path): raise ( ArgumentError(f"Could not find the model file {args.model_path}."))