[Linux][PyKaldi] Ubuntu 18.04 install Pykaldi

Charlie Chen (陳慶裕)
2 min readApr 27, 2020

預載軟體:Anaconda3

1、install PyKaldi with CUDA support

conda install -c pykaldi pykaldi

2、install PyKaldi without CUDA support (CPU only)

conda install -c pykaldi pykaldi-cpu

3、Clone PyKaldi Repository and Create a New Python Environment

git clone https://github.com/pykaldi/pykaldi.git

4、creating a new Python environment

cd pykaldi
virtualenv env

出現錯誤

The executable python2 (from — python=python2) does not exist
後面加上 — python=python3

virtualenv env --python=python3
source env/bin/activate

5、Install Dependencies

sudo apt-get install autoconf automake cmake curl g++ git graphviz \
libatlas3-base libtool make pkg-config subversion unzip wget zlib1g-dev

6、install the Python packages needed for building PyKaldi

pip install --upgrade pip
pip install --upgrade setuptools
pip install numpy pyparsing
pip install ninja

7、PyKaldi compatible fork of CLIF.

git clone -b pykaldi https://github.com/pykaldi/clif

8、PyKaldi compatible fork of Kaldi.

git clone -b pykaldi https://github.com/pykaldi/kaldi

9、install or update these software locally. Make sure you check the output of these scripts.

cd tools
./check_dependencies.sh # checks if system dependencies are installed
./install_protobuf.sh # installs both the C++ library and the Python package
./install_clif.sh # installs both the C++ library and the Python package
./install_kaldi.sh # installs the C++ library
cd ..

10、Install PyKaldi

python setup.py install

錯誤訊息:

Could NOT find PythonLibs (missing: PYTHON_LIBRARIES PYTHON_INCLUDE_DIRS) Call Stack (most recent call first):

sudo apt-get install python3-dev python3-pip python3-tk python3-lxml python3-six

Found PythonInterp: /home/charlie/smartoffice/pykaldi/env/bin/python (found version “3.7.6”)
CMake Error at /usr/share/cmake-

CMakeLists.txt:16 (find_package)

— Configuring incomplete, errors occurred!
See also … non-zero exit status 1.

安裝完python3所需套件後,最後再執行一次指令

python setup.py install

11、PyKaldi tests with the following command

python setup.py test

以上,執行完成大致上已可以進行pykaldi的運用!

來源:

https://github.com/pykaldi/pykaldi

--

--