From source

This section describe how to install k2-fsa/sherpa from source.

Install dependencies

Before installing k2-fsa/sherpa from source, we have to install the following dependencies.

Suppose that we select torch==2.0.1. We can use the following commands to install the dependencies:

pip install torch==2.0.1+cpu -f https://download.pytorch.org/whl/torch_stable.html
pip install k2==1.24.4.dev20231220+cpu.torch2.0.1 -f https://k2-fsa.github.io/k2/cpu.html
pip install kaldifeat==1.25.3.dev20231221+cpu.torch2.0.1 -f https://csukuangfj.github.io/kaldifeat/cpu.html

Now we can start to build k2-fsa/sherpa from source.

For general users

You can use the following commands to install k2-fsa/sherpa:

# Please make sure you have installed PyTorch, k2, and kaldifeat
# before you continue
#
git clone http://github.com/k2-fsa/sherpa
cd sherpa
python3 -m pip install --verbose .

To uninstall k2-fsa/sherpa, please use

# Please run it outside of the k2-fsa/sherpa repo
#
pip uninstall k2-sherpa

Please see Check your installation.

For developers and advanced users

You can also use the following commands to install k2-fsa/sherpa.

The advantage is that you can have several versions of k2-fsa/sherpa in a single environment.

git clone http://github.com/k2-fsa/sherpa
cd sherpa
mkdir build
cd build

# For torch >= 2.0, please use
#
#  cmake -DCMAKE_CXX_STANDARD=17 ..
#

cmake ..
make -j

export PATH=$PWD/bin:$PATH
export PYTHONPATH=$PWD/lib:$PWD/../sherpa/python:$PYTHONPATH

Please see Check your installation.