forked from readbeyond/aeneas
-
Notifications
You must be signed in to change notification settings - Fork 0
/
check_dependencies.py
168 lines (142 loc) · 5.17 KB
/
check_dependencies.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
#!/usr/bin/env python
# coding=utf-8
"""
Check dependencies
"""
import os
import tempfile
__author__ = "Alberto Pettarin"
__copyright__ = """
Copyright 2012-2013, Alberto Pettarin (www.albertopettarin.it)
Copyright 2013-2015, ReadBeyond Srl (www.readbeyond.it)
Copyright 2015, Alberto Pettarin (www.albertopettarin.it)
"""
__license__ = "GNU AGPL 3"
__version__ = "1.2.0"
__email__ = "[email protected]"
__status__ = "Production"
def on_error(msg):
print "[ERRO] %s" % msg
def on_info(msg):
print "[INFO] %s" % msg
def on_warning(msg):
print "[WARN] %s" % msg
def get_abs_path(rel_path):
file_dir = os.path.dirname(__file__)
return os.path.join(file_dir, rel_path)
def step1():
on_info("Test 1/6 (import)...")
try:
on_info(" Trying to import package aeneas...")
import aeneas
on_info(" Trying to import package aeneas... succeeded.")
return True
except ImportError:
on_error(" Unable to import package aeneas.")
on_error(" Check that you have installed the following Python (2.7.x) packages:")
on_error(" 1. BeautifulSoup")
on_error(" 2. lxml")
on_error(" 3. numpy")
on_error(" 4. scikits.audiolab")
except:
pass
return False
def step2():
on_info("Test 2/6 (ffprobe)...")
try:
on_info(" Trying to call ffprobe...")
from aeneas.ffprobewrapper import FFPROBEWrapper
file_path = get_abs_path("aeneas/tests/res/container/job/assets/p001.mp3")
prober = FFPROBEWrapper()
properties = prober.read_properties(file_path)
on_info(" Trying to call ffprobe... succeeded.")
return True
except:
on_error(" Unable to call ffprobe.")
on_error(" Please make sure you have ffprobe installed correctly and that it is in your $PATH.")
return False
def step3():
on_info("Test 3/6 (ffmpeg)...")
try:
on_info(" Trying to call ffmpeg...")
from aeneas.ffmpegwrapper import FFMPEGWrapper
input_file_path = get_abs_path("aeneas/tests/res/container/job/assets/p001.mp3")
handler, output_file_path = tempfile.mkstemp(suffix=".wav")
converter = FFMPEGWrapper()
result = converter.convert(input_file_path, output_file_path)
os.close(handler)
os.remove(output_file_path)
if result:
on_info(" Trying to call ffmpeg... succeeded.")
return True
else:
on_error(" Unable to call ffmpeg.")
on_error(" Please make sure you have ffmpeg installed correctly and that it is in your $PATH.")
except:
on_error(" Unable to call ffmpeg.")
on_error(" Please make sure you have ffmpeg installed correctly and that it is in your $PATH.")
return False
def step4():
on_info("Test 4/6 (espeak)...")
try:
on_info(" Trying to call espeak...")
from aeneas.espeakwrapper import ESPEAKWrapper
from aeneas.language import Language
text = u"From fairest creatures we desire increase,"
language = Language.EN
handler, output_file_path = tempfile.mkstemp(suffix=".wav")
espeak = ESPEAKWrapper()
result = espeak.synthesize(text, language, output_file_path)
os.close(handler)
os.remove(output_file_path)
if result:
on_info(" Trying to call espeak... succeeded.")
return True
else:
on_error(" Unable to call espeak.")
on_error(" Please make sure you have espeak installed correctly and that it is in your $PATH.")
except:
on_error(" Unable to call espeak.")
on_error(" Please make sure you have espeak installed correctly and that it is in your $PATH.")
return False
def stepC1():
on_info("Test 5/6 (cdtw)...")
try:
import aeneas.cdtw
on_info(" Python C Extension cdtw correctly loaded")
return True
except:
on_warning(" Unable to load Python C Extension cdtw")
on_warning(" You can still run aeneas, but it will be slower")
on_warning(" Try running \"bash compile_c_extensions.sh\" to compile the cdtw module")
return False
def stepC2():
on_info("Test 6/6 (cmfcc)...")
try:
import aeneas.cmfcc
on_info(" Python C Extension cmfcc correctly loaded")
return True
except:
on_warning(" Unable to load Python C Extension cmfcc")
on_warning(" You can still run aeneas, but it will be slower")
on_warning(" Try running \"bash compile_c_extensions.sh\" to compile the cmfcc module")
return False
def main():
if not step1():
return
if not step2():
return
if not step3():
return
if not step4():
return
has_cdtw = stepC1()
has_cmfcc = stepC2()
if has_cdtw and has_cmfcc:
on_info("Congratulations, all dependencies are met and C extensions are available.")
else:
on_warning("All dependencies are met, but C extensions are not available.")
on_warning("Try running \"bash compile_c_extensions.sh\" to compile the C extensions.")
on_info("Enjoy running aeneas!")
if __name__ == '__main__':
main()