提交 e3e9bb43 编写于 作者: Y Yibing Liu

Make the kaldi root directory flexible

上级 77ce7a92
...@@ -17,6 +17,12 @@ import glob ...@@ -17,6 +17,12 @@ import glob
from distutils.core import setup, Extension from distutils.core import setup, Extension
from distutils.sysconfig import get_config_vars from distutils.sysconfig import get_config_vars
try:
kaldi_root = os.environ['KALDI_ROOT']
except:
raise ValueError("Enviroment variable 'KALDI_ROOT' is not defined. Please "
"install kaldi and export KALDI_ROOT=<kaldi's root dir> .")
args = [ args = [
'-std=c++11', '-Wno-sign-compare', '-Wno-unused-variable', '-std=c++11', '-Wno-sign-compare', '-Wno-unused-variable',
'-Wno-unused-local-typedefs', '-Wno-unused-but-set-variable', '-Wno-unused-local-typedefs', '-Wno-unused-but-set-variable',
...@@ -35,21 +41,21 @@ LIBS = [ ...@@ -35,21 +41,21 @@ LIBS = [
] ]
LIB_DIRS = [ LIB_DIRS = [
'kaldi/tools/openfst/lib', 'kaldi/src/base', 'kaldi/src/matrix', 'tools/openfst/lib', 'src/base', 'src/matrix', 'src/util', 'src/tree',
'kaldi/src/util', 'kaldi/src/tree', 'kaldi/src/hmm', 'kaldi/src/fstext', 'src/hmm', 'src/fstext', 'src/decoder', 'src/lat'
'kaldi/src/decoder', 'kaldi/src/lat'
] ]
LIB_DIRS = [os.path.join(kaldi_root, path) for path in LIB_DIRS]
ext_modules = [ ext_modules = [
Extension( Extension(
'post_decode_faster', 'post_decode_faster',
['pybind.cc', 'post_decode_faster.cc'], ['pybind.cc', 'post_decode_faster.cc'],
include_dirs=[ include_dirs=[
'pybind11/include', '.', 'kaldi/src/', 'pybind11/include', '.', os.path.join(kaldi_root, 'src'),
'kaldi/tools/openfst/src/include' os.path.join(kaldi_root, 'tools/openfst/src/include')
], ],
libraries=LIBS,
language='c++', language='c++',
libraries=LIBS,
library_dirs=LIB_DIRS, library_dirs=LIB_DIRS,
runtime_library_dirs=LIB_DIRS, runtime_library_dirs=LIB_DIRS,
extra_compile_args=args, ), extra_compile_args=args, ),
......
...@@ -4,8 +4,4 @@ if [ ! -d pybind11 ]; then ...@@ -4,8 +4,4 @@ if [ ! -d pybind11 ]; then
git clone https://github.com/pybind/pybind11.git git clone https://github.com/pybind/pybind11.git
fi fi
if [ ! -d kaldi ]; then
git clone https://github.com/kaldi-asr/kaldi.git
fi
python setup.py build_ext -i python setup.py build_ext -i
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册