Exemple #1
0
def main():
    mp.freeze_support()
    args = parser.parse_args()

    fix_path()
    if args.subcommand == 'align':
        run_align_corpus(args, acoustic_languages)
    elif args.subcommand == 'train':
        run_train_corpus(args)
    elif args.subcommand == 'g2p':
        run_g2p(args, g2p_languages)
    elif args.subcommand == 'train_g2p':
        run_train_g2p(args)
    elif args.subcommand == 'validate':
        run_validate_corpus(args)
    elif args.subcommand == 'download':
        run_download(args)
    elif args.subcommand == 'train_lm':
        run_train_lm(args)
    elif args.subcommand == 'train_ivector':
        run_train_ivector_extractor(args)
    elif args.subcommand == 'annotator':
        run_annotator(args)
    elif args.subcommand == 'thirdparty':
        run_thirdparty(args)
    elif args.subcommand == 'transcribe':
        run_transcribe_corpus(args)
    unfix_path()
def test_expected_errors():
    args = DummyArgs()
    args.language = 'bulgarian'
    args.model_type = 'not_acoustic'
    with pytest.raises(ArgumentError):
        run_download(args)

    args = DummyArgs()
    args.language = 'not_bulgarian'
    args.model_type = 'acoustic'
    with pytest.raises(ArgumentError):
        run_download(args)
def test_download():
    args = DummyArgs()
    args.language = 'bulgarian'
    args.model_type = 'acoustic'

    run_download(args)

    assert os.path.exists(get_pretrained_acoustic_path(args.language))

    args = DummyArgs()
    args.language = 'bulgarian_g2p'
    args.model_type = 'g2p'

    run_download(args)

    assert os.path.exists(get_pretrained_g2p_path(args.language))

    args = DummyArgs()
    args.language = 'english'
    args.model_type = 'dictionary'

    run_download(args)

    assert os.path.exists(get_dictionary_path(args.language))

    args = DummyArgs()
    args.language = ''
    args.model_type = 'dictionary'

    run_download(args)
Exemple #4
0
def main():
    mp.freeze_support()
    args, unknown = parser.parse_known_args()
    fix_path()
    if args.subcommand in ['align', 'train', 'train_ivector']:
        from montreal_forced_aligner.thirdparty.kaldi import validate_alignment_binaries
        if not validate_alignment_binaries():
            print(
                "There was an issue validating Kaldi binaries, please ensure you've downloaded them via the "
                "'mfa thirdparty download' command.  See 'mfa thirdparty validate' for more detailed information "
                "on why this check failed.")
            sys.exit(1)
    elif args.subcommand in ['transcribe']:
        from montreal_forced_aligner.thirdparty.kaldi import validate_transcribe_binaries
        if not validate_transcribe_binaries():
            print(
                "There was an issue validating Kaldi binaries, please ensure you've downloaded them via the "
                "'mfa thirdparty download' command.  See 'mfa thirdparty validate' for more detailed information "
                "on why this check failed.  If you are on MacOS, please note that the thirdparty binaries available "
                "via the download command do not contain the transcription ones.  To get this functionality working "
                "for the time being, please build kaldi locally and follow the instructions for running the "
                "'mfa thirdparty kaldi' command.")
            sys.exit(1)
    elif args.subcommand in ['train_dictionary']:
        from montreal_forced_aligner.thirdparty.kaldi import validate_train_dictionary_binaries
        if not validate_train_dictionary_binaries():
            print(
                "There was an issue validating Kaldi binaries, please ensure you've downloaded them via the "
                "'mfa thirdparty download' command.  See 'mfa thirdparty validate' for more detailed information "
                "on why this check failed.  If you are on MacOS, please note that the thirdparty binaries available "
                "via the download command do not contain the train_dictionary ones.  To get this functionality working "
                "for the time being, please build kaldi locally and follow the instructions for running the "
                "'mfa thirdparty kaldi' command.")
            sys.exit(1)
    elif args.subcommand in ['g2p', 'train_g2p']:
        try:
            import pynini
        except ImportError:
            print(
                "There was an issue importing Pynini, please ensure that it is installed. If you are on Windows, "
                "please use the Windows Subsystem for Linux to use g2p functionality."
            )
            sys.exit(1)
    if args.subcommand == 'align':
        run_align_corpus(args, unknown, acoustic_languages)
    elif args.subcommand == 'train':
        run_train_corpus(args)
    elif args.subcommand == 'g2p':
        run_g2p(args, g2p_languages)
    elif args.subcommand == 'train_g2p':
        run_train_g2p(args)
    elif args.subcommand == 'validate':
        run_validate_corpus(args)
    elif args.subcommand == 'download':
        run_download(args)
    elif args.subcommand == 'train_lm':
        run_train_lm(args)
    elif args.subcommand == 'train_dictionary':
        run_train_dictionary(args)
    elif args.subcommand == 'train_ivector':
        run_train_ivector_extractor(args)
    elif args.subcommand == 'classify_speakers':
        run_classify_speakers(args)
    elif args.subcommand == 'annotator':
        from montreal_forced_aligner.command_line.annotator import run_annotator
        run_annotator(args)
    elif args.subcommand == 'thirdparty':
        run_thirdparty(args)
    elif args.subcommand == 'transcribe':
        run_transcribe_corpus(args)
    elif args.subcommand == 'create_segments':
        run_create_segments(args, unknown)
    elif args.subcommand == 'version':
        print(__version__)
    unfix_path()