forked from MontrealCorpusTools/Montreal-Forced-Aligner
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_commandline_create_segments.py
76 lines (70 loc) · 2.04 KB
/
test_commandline_create_segments.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
import os
import shutil
import click.testing
import pytest
from montreal_forced_aligner.command_line.mfa import mfa_cli
from montreal_forced_aligner.diarization.speaker_diarizer import FOUND_SPEECHBRAIN
def test_create_segments(
basic_corpus_dir,
generated_dir,
temp_dir,
basic_segment_config_path,
):
output_path = os.path.join(generated_dir, "segment_output")
shutil.rmtree(output_path, ignore_errors=True)
command = [
"segment",
basic_corpus_dir,
output_path,
"-t",
os.path.join(temp_dir, "sad_cli"),
"-q",
"--clean",
"--debug",
"-v",
"--config_path",
basic_segment_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.TextGrid"))
def test_create_segments_speechbrain(
basic_corpus_dir,
generated_dir,
temp_dir,
basic_segment_config_path,
):
if not FOUND_SPEECHBRAIN:
pytest.skip("SpeechBrain not installed")
output_path = os.path.join(generated_dir, "segment_output")
command = [
"segment",
basic_corpus_dir,
output_path,
"-t",
os.path.join(temp_dir, "sad_cli_speechbrain"),
"-q",
"--clean",
"--debug",
"-v",
"--speechbrain",
"--config_path",
basic_segment_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.TextGrid"))