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