Install from source

Before installing sherpa, you have to install PyTorch and k2. If you want to install a CUDA version of sherpa, please install a CUDA version of PyTorch and k2.

Supported operating systems, Python versions, PyTorch versions, and CUDA versions are listed as follows:

  • Supported operating systems

  • Supported python versions

  • Supported pytorch versions

  • Supported cuda versions

Hint

If you install a CUDA version of PyTorch, please also install cuDNN. Otherwise, you will get CMake configuration errors later.

Install PyTorch

Please refer to https://pytorch.org/get-started/locally/ to install PyTorch.

Install k2

Please refer to https://k2-fsa.github.io/k2/installation/index.html to install k2. You have to install k2 >= v1.16.

Install sherpa

git clone https://github.com/k2-fsa/sherpa
cd sherpa

# Install the dependencies
pip install -r ./requirements.txt

# Install the C++ extension.
# Use one of the following methods:
#
# (1)
python3 setup.py install --verbose
#
# (2)
# pip install --verbose k2-sherpa

# To uninstall the C++ extension, use
# pip uninstall k2-sherpa

Note

You can use either python3 setup.py install --verbose or pip install --verbose k2-sherpa to install the C++ extension.

python3 setup.py install always installs the latest version.

Hint

Refer to How to fix Caffe2: Cannot find cuDNN library if you encouter this problem during installation.

Caution

pip install -r ./requirements.txt won’t install all dependencies of sherpa. You have to install PyTorch and k2 before you install sherpa.

To check that you have installed sherpa successfully, run

python3 -c "import sherpa; print(sherpa.__version__)"

It should print the version of sherpa.

Congratulations!

You have installed sherpa successfully. Let us start to play with it.

The following shows you a YouTube video, demonstrating streaming ASR with sherpa.

Note

If you have no access to YouTube, please visit the following link from bilibili https://www.bilibili.com/video/BV1BU4y197bs

Read more to see how to use sherpa for streaming ASR and non-streaming ASR.