Path: blob/master/examples/mfa_extraction/run_mfa.py
1558 views
# -*- coding: utf-8 -*-1# Copyright 2020 TensorFlowTTS Team.2#3# Licensed under the Apache License, Version 2.0 (the "License");4# you may not use this file except in compliance with the License.5# You may obtain a copy of the License at6#7# http://www.apache.org/licenses/LICENSE-2.08#9# Unless required by applicable law or agreed to in writing, software10# distributed under the License is distributed on an "AS IS" BASIS,11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.12# See the License for the specific language governing permissions and13# limitations under the License.14"""Runing mfa to extract textgrids."""1516from subprocess import call17from pathlib import Path1819import click20import os212223@click.command()24@click.option("--mfa_path", default=os.path.join('mfa', 'montreal-forced-aligner', 'bin', 'mfa_align'))25@click.option("--corpus_directory", default="libritts")26@click.option("--lexicon", default=os.path.join('mfa', 'lexicon', 'librispeech-lexicon.txt'))27@click.option("--acoustic_model_path", default=os.path.join('mfa', 'montreal-forced-aligner', 'pretrained_models', 'english.zip'))28@click.option("--output_directory", default=os.path.join('mfa', 'parsed'))29@click.option("--jobs", default="8")30def run_mfa(31mfa_path: str,32corpus_directory: str,33lexicon: str,34acoustic_model_path: str,35output_directory: str,36jobs: str,37):38Path(output_directory).mkdir(parents=True, exist_ok=True)39call(40[41f".{os.path.sep}{mfa_path}",42corpus_directory,43lexicon,44acoustic_model_path,45output_directory,46f"-j {jobs}"47]48)495051if __name__ == "__main__":52run_mfa()535455