-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure_sphinx.py
executable file
·65 lines (54 loc) · 1.73 KB
/
configure_sphinx.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
#!/usr/bin/env python
import os
import generate_dict
import generate_phone_set_from_dict
import generate_filler
import generate_transcriptions
ETC_FOLDER_NAME = "etc"
PROJECT_NAME = "ops_aphasia"
TRANSCRIPT_FILE = "transcription.txt"
def execute_script_with_args_if_file_does_not_exists(script, file, *args):
# print(script)
# print(file)
# print(args)
if not os.path.exists(file):
print("Creating {}".format(file))
script(*args)
else:
print("{} already exists".format(file))
if __name__ == "__main__":
# Configuration Folder
if not os.path.exists(ETC_FOLDER_NAME):
print("Creating etc folder")
os.makedirs(ETC_FOLDER_NAME)
print("etc folder created")
# Dictionary file
dict_file = os.path.join(ETC_FOLDER_NAME, "{}.dic".format(PROJECT_NAME))
execute_script_with_args_if_file_does_not_exists(
generate_dict.execute_script,
dict_file,
TRANSCRIPT_FILE,
dict_file
)
# Phone file
phone_file = os.path.join(ETC_FOLDER_NAME, "{}.phone".format(PROJECT_NAME))
execute_script_with_args_if_file_does_not_exists(
generate_phone_set_from_dict.execute_script,
phone_file,
dict_file,
phone_file
)
filler_file = os.path.join(ETC_FOLDER_NAME, "{}.filler".format(PROJECT_NAME))
execute_script_with_args_if_file_does_not_exists(
generate_filler.execute_script,
filler_file,
filler_file,
)
fileids_file = os.path.join(ETC_FOLDER_NAME, "{}.fileids".format(PROJECT_NAME))
execute_script_with_args_if_file_does_not_exists(
generate_transcriptions.execute_script,
fileids_file,
ETC_FOLDER_NAME,
PROJECT_NAME,
TRANSCRIPT_FILE
)