Install this version:
emerge -a =sci-ml/sherpa-onnx-1.13.7
If this version is masked, you can unmask it using the autounmask tool or standard emerge options:
autounmask =sci-ml/sherpa-onnx-1.13.7
Or alternatively:
emerge --autounmask-write -a =sci-ml/sherpa-onnx-1.13.7
# Copyright 1999-2026 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
EAPI=8
PYTHON_COMPAT=( python3_{12..14} )
inherit cmake python-single-r1
DESCRIPTION="Speech-to-text, TTS, speaker diarization etc. using onnxruntime"
HOMEPAGE="
https://k2-fsa.github.io/sherpa/onnx/
https://github.com/k2-fsa/sherpa-onnx
"
# FetchContent searches CMAKE_SOURCE_DIR for exact archive names, including
# transitive kissfft and kaldifst; prefetch and stage them to keep builds offline.
# Keep kissfft as ZIP despite TarballAvailable: kaldi-native-fbank verifies that
# filename and archive hash, so GitHub's tarball fails. verified 2026-09-02
SRC_URI="
https://github.com/k2-fsa/sherpa-onnx/archive/refs/tags/v${PV}.tar.gz
-> ${P}.gh.tar.gz
https://gitlab.com/libeigen/eigen/-/archive/5.0.1/eigen-5.0.1.tar.bz2
https://github.com/likle/cargs/archive/refs/tags/v1.0.3.tar.gz
-> cargs-1.0.3.tar.gz
https://github.com/csukuangfj/hclust-cpp/archive/refs/tags/2026-02-25.tar.gz
-> hclust-cpp-2026-02-25.tar.gz
https://github.com/nlohmann/json/archive/refs/tags/v3.12.0.tar.gz
-> json-3.12.0.tar.gz
https://github.com/k2-fsa/kaldi-decoder/archive/refs/tags/v0.3.0.tar.gz
-> kaldi-decoder-0.3.0.tar.gz
https://github.com/csukuangfj/kaldi-native-fbank/archive/refs/tags/v1.22.3.tar.gz
-> kaldi-native-fbank-1.22.3.tar.gz
https://github.com/csukuangfj/openfst/archive/refs/tags/v1.8.5-2026-07-09.tar.gz
-> openfst-1.8.5-2026-07-09.tar.gz
https://github.com/pkufool/simple-sentencepiece/archive/refs/tags/v0.7.tar.gz
-> simple-sentencepiece-0.7.tar.gz
https://github.com/mborgerding/kissfft/archive/febd4caeed32e33ad8b2e0bb5ea77542c40f18ec.zip
-> kissfft-febd4caeed32e33ad8b2e0bb5ea77542c40f18ec.zip
https://github.com/k2-fsa/kaldifst/archive/refs/tags/v1.8.0.tar.gz
-> kaldifst-1.8.0.tar.gz
portaudio? (
https://files.portaudio.com/archives/pa_stable_v190700_20210406.tgz
)
python? (
https://github.com/pybind/pybind11/archive/refs/tags/v3.0.0.tar.gz
-> pybind11-3.0.0.tar.gz
)
tts? (
https://github.com/csukuangfj/espeak-ng/archive/ed530aa113046142eb5115cf2fc9157854d0ffe1.tar.gz
-> espeak-ng-ed530aa113046142eb5115cf2fc9157854d0ffe1.tar.gz
https://github.com/csukuangfj/piper-phonemize/archive/f3ff95afc03640bc1399e113e83361192a2fafb4.tar.gz
-> piper-phonemize-f3ff95afc03640bc1399e113e83361192a2fafb4.tar.gz
)
websocket? (
https://github.com/chriskohlhoff/asio/archive/refs/tags/asio-1-24-0.tar.gz
-> asio-asio-1-24-0.tar.gz
https://github.com/zaphoyd/websocketpp/archive/b9aeec6eaf3d5610503439b4fae3581d9aff08e8.tar.gz
-> websocketpp-b9aeec6eaf3d5610503439b4fae3581d9aff08e8.tar.gz
)
"
LICENSE="Apache-2.0"
SLOT="0"
KEYWORDS="~amd64 ~arm64"
IUSE="cuda +portaudio +python +tts +websocket"
REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )"
# portaudio is vendored and static; its flag only controls microphone demo CLIs.
# ALSA demos always link libasound. Block -bin because both install sherpa_onnx.
RDEPEND="
!sci-ml/sherpa-onnx-bin
sci-libs/onnxruntime:=[cuda?]
media-libs/alsa-lib
cuda? ( dev-util/nvidia-cuda-toolkit:= )
python? (
${PYTHON_DEPS}
)
"
DEPEND="${RDEPEND}"
BDEPEND="
app-arch/unzip
python? (
${PYTHON_DEPS}
$(python_gen_cond_dep '
dev-python/pybind11[${PYTHON_USEDEP}]
')
)
"
# Private vendored libraries under /opt are outside the system ABI.
QA_PREBUILT="opt/sherpa-onnx/lib/*"
src_unpack() {
# Leave dependency archives intact for FetchContent's source-directory lookup.
unpack "${P}.gh.tar.gz"
# A is a space-separated string of distfile names (not an array).
local f
for f in ${A}; do
[[ ${f} == "${P}.gh.tar.gz" ]] && continue
cp -- "${DISTDIR}/${f}" "${S}/" || die
done
}
PATCHES=(
"${FILESDIR}/${PN}-1.13.4-compressed-tarballs.patch"
)
src_configure() {
use python && python_setup
local mycmakeargs=(
# Isolate the many CLI tools and vendored libraries under /opt.
-DCMAKE_INSTALL_PREFIX="${EPREFIX}/opt/sherpa-onnx"
-DBUILD_SHARED_LIBS=ON
-DSHERPA_ONNX_USE_PRE_INSTALLED_ONNXRUNTIME_IF_AVAILABLE=ON
-DSHERPA_ONNX_ENABLE_C_API=ON
-DSHERPA_ONNX_ENABLE_BINARY=ON
-DSHERPA_ONNX_ENABLE_SPEAKER_DIARIZATION=ON
-DSHERPA_ONNX_LINK_LIBSTDCPP_STATICALLY=OFF
-DSHERPA_ONNX_ENABLE_TESTS=OFF
-DSHERPA_ONNX_ENABLE_PYTHON=$(usex python)
-DSHERPA_ONNX_ENABLE_PORTAUDIO=$(usex portaudio)
-DSHERPA_ONNX_ENABLE_WEBSOCKET=$(usex websocket)
-DSHERPA_ONNX_ENABLE_TTS=$(usex tts)
-DSHERPA_ONNX_ENABLE_GPU=$(usex cuda)
-DSHERPA_ONNX_ENABLE_JNI=OFF
-DSHERPA_ONNX_ENABLE_WASM=OFF
)
if use cuda; then
# CUDA 13 nvcc rejects GCC >15.
export CUDAHOSTCXX="/usr/bin/g++-15"
fi
cmake_src_configure
}
src_install() {
cmake_src_install
# Expose the isolated commands and private libraries system-wide.
newenvd - 99sherpa-onnx <<-EOF
PATH="${EPREFIX}/opt/sherpa-onnx/bin"
LDPATH="${EPREFIX}/opt/sherpa-onnx/lib"
EOF
if use python; then
# Put bindings in site-packages; their private libraries resolve via LDPATH.
local opt_pylib="${ED}/opt/sherpa-onnx/lib"
local pylib_dst_rel="$(python_get_sitedir)/sherpa_onnx/lib"
dodir "${pylib_dst_rel}"
local so
for so in "${opt_pylib}"/_sherpa_onnx*.so; do
[[ -e ${so} ]] || continue
mv "${so}" "${ED}/${pylib_dst_rel}/" || die
done
python_moduleinto sherpa_onnx
python_domodule "${S}/sherpa-onnx/python/sherpa_onnx"/*.py
fi
}
pkg_postinst() {
elog ""
elog "sherpa-onnx ${PV} installed to /opt/sherpa-onnx."
elog "After re-sourcing /etc/profile (new shell or 'source /etc/profile')"
elog "the binaries on PATH:"
elog " sherpa-onnx --help # generic ASR/runtime entry"
elog " sherpa-onnx-offline-speaker-diarization --help"
elog " sherpa-onnx-vad --help # voice activity detection"
elog " ... (~23 task-specific tools under /opt/sherpa-onnx/bin/)"
elog ""
elog "Model files are not bundled — see"
elog " https://k2-fsa.github.io/sherpa/onnx/pretrained_models/"
elog "For speaker diarization specifically, the ONNX-converted pyannote"
elog "models + 3D-Speaker embeddings live at"
elog " https://huggingface.co/csukuangfj/sherpa-onnx-pyannote-segmentation-3-0"
elog "(ungated, no HuggingFace token required, unlike sci-ml/pyannote-audio)."
elog ""
}
Manage flags for this package:
euse -i <flag> -p sci-ml/sherpa-onnx |
euse -E <flag> -p sci-ml/sherpa-onnx |
euse -D <flag> -p sci-ml/sherpa-onnx
!sci-ml/sherpa-onnx-bin sci-libs/onnxruntime:=[cuda?] media-libs/alsa-lib cuda? ( dev-util/nvidia-cuda-toolkit:= ) python? ( )
!sci-ml/sherpa-onnx-bin sci-libs/onnxruntime:=[cuda?] media-libs/alsa-lib cuda? ( dev-util/nvidia-cuda-toolkit:= ) python? ( )
app-arch/unzip python? ( ${PYTHON_DEPS} $(python_gen_cond_dep ' dev-python/pybind11[${PYTHON_USEDEP}] ') )