示例#1
0
def validate_args(args):
    if not os.path.exists(args.corpus_directory):
        raise (
            ArgumentError(
                "Could not find the corpus directory {}.".format(args.corpus_directory)
            )
        )
    if not os.path.isdir(args.corpus_directory):
        raise (
            ArgumentError(
                "The specified corpus directory ({}) is not a directory.".format(
                    args.corpus_directory
                )
            )
        )
    if not os.path.exists(args.dictionary_path):
        raise (
            ArgumentError(
                "Could not find the dictionary file {}".format(args.dictionary_path)
            )
        )
    if not os.path.isfile(args.dictionary_path):
        raise (
            ArgumentError(
                "The specified dictionary path ({}) is not a text file.".format(
                    args.dictionary_path
                )
            )
        )
def align_included_model(args):
    if not os.path.exists(args.corpus_directory):
        raise (ArgumentError('Could not find the corpus directory {}.'.format(
            args.corpus_directory)))
    if not os.path.isdir(args.corpus_directory):
        raise (ArgumentError(
            'The specified corpus directory ({}) is not a directory.'.format(
                args.corpus_directory)))
    if not os.path.exists(args.dictionary_path):
        raise (ArgumentError('Could not find the dictionary file {}'.format(
            args.dictionary_path)))
    if not os.path.isfile(args.dictionary_path):
        raise (ArgumentError(
            'The specified dictionary path ({}) is not a text file.'.format(
                args.dictionary_path)))
    if getattr(sys, 'frozen', False):
        root_dir = os.path.dirname(os.path.dirname(sys.executable))
    else:
        path = os.path.abspath(__file__)
        root_dir = os.path.dirname(os.path.dirname(os.path.dirname(path)))
    pretrained_dir = os.path.join(root_dir, 'pretrained_models')
    args.acoustic_model_path = os.path.join(
        pretrained_dir, '{}{}'.format(args.acoustic_model_path.lower(),
                                      AcousticModel.extension))
    align_corpus(args)
示例#3
0
def validate(args):
    if not os.path.exists(args.dictionary_path):
        raise (ArgumentError('Could not find the dictionary file {}'.format(
            args.dictionary_path)))
    if not os.path.isfile(args.dictionary_path):
        raise (ArgumentError(
            'The specified dictionary path ({}) is not a text file.'.format(
                args.dictionary_path)))
示例#4
0
def validate_args(args):
    if args.corpus_directory == args.output_directory:
        raise Exception('Corpus directory and output directory cannot be the same folder.')
    if not os.path.exists(args.corpus_directory):
        raise (ArgumentError('Could not find the corpus directory {}.'.format(args.corpus_directory)))
    if not os.path.isdir(args.corpus_directory):
        raise (ArgumentError('The specified corpus directory ({}) is not a directory.'.format(args.corpus_directory)))
    if not os.path.exists(args.dictionary_path):
        raise (ArgumentError('Could not find the dictionary file {}'.format(args.dictionary_path)))
    if not os.path.isfile(args.dictionary_path):
        raise (ArgumentError('The specified dictionary path ({}) is not a text file.'.format(args.dictionary_path)))
def validate_args(args):
    args.model_type = args.model_type.lower()
    if args.model_type not in ['acoustic', 'g2p', 'dictionary']:
        raise ArgumentError(
            "model_type must be one of 'acoustic', 'g2p', or 'dictionary'")
    if args.language is not None:
        available_languages = list_available_languages(args.model_type)
        if args.language not in available_languages:
            raise ArgumentError(
                'Could not find {}, possible languages for download are: {}'.
                format(args.language, ', '.join(available_languages)))
示例#6
0
def validate(args):
    if args.g2p_model_path and not os.path.exists(args.g2p_model_path):
        raise (ArgumentError('Could not find the G2P model file {}.'.format(
            args.g2p_model_path)))
    if not os.path.isfile(
            args.g2p_model_path) or not args.g2p_model_path.endswith('.zip'):
        raise (ArgumentError(
            'The specified G2P model path ({}) is not a zip file.'.format(
                args.g2p_model_path)))

    if not os.path.exists(args.input_path):
        raise (ArgumentError('Could not find the input path {}.'.format(
            args.input_path)))
示例#7
0
def validate(args):
    if not os.path.exists(args.g2p_model_path):
        raise (ArgumentError('Could not find the G2P model file {}.'.format(
            args.g2p_model_path)))
    if not os.path.isfile(
            args.g2p_model_path) or not args.g2p_model_path.endswith('.zip'):
        raise (ArgumentError(
            'The specified G2P model path ({}) is not a zip file.'.format(
                args.g2p_model_path)))

    if not os.path.exists(args.corpus_directory):
        raise (ArgumentError('Could not find the corpus directory {}.'.format(
            args.corpus_directory)))
    if not os.path.isdir(args.corpus_directory):
        raise (ArgumentError(
            'The specified corpus directory ({}) is not a directory.'.format(
                args.g2p_model_path)))
示例#8
0
def validate(args, pretrained_languages):
    if not args.g2p_model_path:
        args.g2p_model_path = None
    elif args.g2p_model_path in pretrained_languages:
        args.g2p_model_path = get_pretrained_g2p_path(args.g2p_model_path)
    if args.g2p_model_path and not os.path.exists(args.g2p_model_path):
        raise (ArgumentError('Could not find the G2P model file {}.'.format(
            args.g2p_model_path)))
    if args.g2p_model_path and (not os.path.isfile(args.g2p_model_path)
                                or not args.g2p_model_path.endswith('.zip')):
        raise (ArgumentError(
            'The specified G2P model path ({}) is not a zip file.'.format(
                args.g2p_model_path)))

    if not os.path.exists(args.input_path):
        raise (ArgumentError('Could not find the input path {}.'.format(
            args.input_path)))
示例#9
0
def validate_args(args, pretrained):
    if not os.path.exists(args.corpus_directory):
        raise ArgumentError('Could not find the corpus directory {}.'.format(
            args.corpus_directory))
    if not os.path.isdir(args.corpus_directory):
        raise ArgumentError(
            'The specified corpus directory ({}) is not a directory.'.format(
                args.corpus_directory))
    if not os.path.exists(args.dictionary_path):
        raise ArgumentError('Could not find the dictionary file {}'.format(
            args.dictionary_path))
    if not os.path.isfile(args.dictionary_path):
        raise ArgumentError(
            'The specified dictionary path ({}) is not a text file.'.format(
                args.dictionary_path))
    if args.corpus_directory == args.output_directory:
        raise ArgumentError(
            'Corpus directory and output directory cannot be the same folder.')
    if args.acoustic_model_path.lower() in pretrained:
        args.acoustic_model_path = get_pretrained_acoustic_path(
            args.acoustic_model_path.lower())
    elif args.acoustic_model_path.lower().endswith(AcousticModel.extension):
        if not os.path.exists(args.acoustic_model_path):
            raise ArgumentError('The specified model path does not exist: ' +
                                args.acoustic_model_path)
    else:
        raise ArgumentError(
            'The language \'{}\' is not currently included in the distribution, '
            'please align via training or specify one of the following language names: {}.'
            .format(args.acoustic_model_path.lower(), ', '.join(pretrained)))
def validate_args(args):
    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('Could not find the corpus directory {}.'.format(
            args.corpus_directory)))
    if not os.path.isdir(args.corpus_directory):
        raise (ArgumentError(
            'The specified corpus directory ({}) is not a directory.'.format(
                args.corpus_directory)))
    if not os.path.exists(args.dictionary_path):
        raise (ArgumentError('Could not find the dictionary file {}'.format(
            args.dictionary_path)))
    if not os.path.isfile(args.dictionary_path):
        raise (ArgumentError(
            'The specified dictionary path ({}) is not a text file.'.format(
                args.dictionary_path)))
示例#11
0
    )
    parser.add_argument(
        "-d",
        "--debug",
        help="Output debug messages about alignment",
        action="store_true",
    )
    parser.add_argument(
        "--config_path",
        type=str,
        default="",
        help="Path to config file to use for alignment",
    )
    args = parser.parse_args()
    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 args.corpus_directory == args.output_directory:
        raise ArgumentError(
            "Corpus directory and output directory cannot be the same folder."
        )

    fix_path()
    validate_args(args)
    unfix_path()