forked from MontrealCorpusTools/Montreal-Forced-Aligner
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_commandline_transcribe.py
168 lines (155 loc) · 4.4 KB
/
test_commandline_transcribe.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
import os
import click.testing
from montreal_forced_aligner.command_line.mfa import mfa_cli
def test_transcribe(
basic_corpus_dir,
basic_dict_path,
english_acoustic_model,
generated_dir,
transcription_acoustic_model,
transcription_language_model,
temp_dir,
transcribe_config_path,
):
output_path = os.path.join(generated_dir, "transcribe_test")
command = [
"transcribe",
basic_corpus_dir,
basic_dict_path,
transcription_acoustic_model,
transcription_language_model,
output_path,
"-t",
os.path.join(temp_dir, "transcribe_cli"),
"-q",
"--clean",
"--debug",
"-v",
"--config_path",
transcribe_config_path,
]
result = click.testing.CliRunner(mix_stderr=False, echo_stdin=True).invoke(
mfa_cli, command, catch_exceptions=True
)
print(result.stdout)
print(result.stderr)
if result.exception:
print(result.exc_info)
raise result.exception
assert not result.return_value
assert os.path.exists(os.path.join(output_path, "michael", "acoustic_corpus.lab"))
def test_transcribe_arpa(
basic_corpus_dir,
basic_dict_path,
english_acoustic_model,
generated_dir,
transcription_language_model_arpa,
temp_dir,
transcribe_config_path,
):
temp_dir = os.path.join(temp_dir, "arpa_test_temp")
output_path = os.path.join(generated_dir, "transcribe_test_arpa")
command = [
"transcribe",
basic_corpus_dir,
basic_dict_path,
english_acoustic_model,
transcription_language_model_arpa,
output_path,
"-t",
os.path.join(temp_dir, "transcribe_cli"),
"-q",
"--clean",
"--debug",
"-v",
"--use_mp",
"false",
"--config_path",
transcribe_config_path,
]
result = click.testing.CliRunner(mix_stderr=False, echo_stdin=True).invoke(
mfa_cli, command, catch_exceptions=True
)
print(result.stdout)
print(result.stderr)
if result.exception:
print(result.exc_info)
raise result.exception
assert not result.return_value
assert os.path.exists(os.path.join(output_path, "michael", "acoustic_corpus.lab"))
def test_transcribe_speaker_dictionaries(
multilingual_ipa_corpus_dir,
mfa_speaker_dict_path,
english_mfa_acoustic_model,
generated_dir,
transcription_language_model,
temp_dir,
transcribe_config_path,
):
output_path = os.path.join(generated_dir, "transcribe_test")
command = [
"transcribe",
multilingual_ipa_corpus_dir,
mfa_speaker_dict_path,
english_mfa_acoustic_model,
transcription_language_model,
output_path,
"-t",
os.path.join(temp_dir, "transcribe_cli"),
"-q",
"--clean",
"--debug",
"--config_path",
transcribe_config_path,
]
result = click.testing.CliRunner(mix_stderr=False, echo_stdin=True).invoke(
mfa_cli, command, catch_exceptions=True
)
print(result.stdout)
print(result.stderr)
if result.exception:
print(result.exc_info)
raise result.exception
assert not result.return_value
assert os.path.exists(output_path)
def test_transcribe_speaker_dictionaries_evaluate(
multilingual_ipa_tg_corpus_dir,
mfa_speaker_dict_path,
english_mfa_acoustic_model,
generated_dir,
transcription_language_model,
temp_dir,
transcribe_config_path,
):
output_path = os.path.join(generated_dir, "transcribe_test")
command = [
"transcribe",
multilingual_ipa_tg_corpus_dir,
mfa_speaker_dict_path,
english_mfa_acoustic_model,
transcription_language_model,
output_path,
"-t",
os.path.join(temp_dir, "transcribe_cli"),
"-q",
"--clean",
"--debug",
"--no_use_mp",
"--language_model_weight",
"16",
"--word_insertion_penalty",
"1.0",
"--config_path",
transcribe_config_path,
"--evaluate",
]
result = click.testing.CliRunner(mix_stderr=False, echo_stdin=True).invoke(
mfa_cli, command, catch_exceptions=True
)
print(result.stdout)
print(result.stderr)
if result.exception:
print(result.exc_info)
raise result.exception
assert not result.return_value
assert os.path.exists(output_path)