2026-08-13 10:31:46 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
set -euo pipefail
|
|
|
|
|
|
|
|
|
|
RVSTTD_DIR="${HOME}/.rvsttd"
|
|
|
|
|
LIB_DIR="${RVSTTD_DIR}/lib"
|
|
|
|
|
INCLUDE_DIR="${RVSTTD_DIR}/include"
|
|
|
|
|
BUILD_DIR="${RVSTTD_DIR}/build"
|
|
|
|
|
|
|
|
|
|
ARCH="linux-x86_64"
|
|
|
|
|
|
|
|
|
|
# Fetch latest release tag from GitHub API
|
|
|
|
|
VERSION=$(curl -s https://api.github.com/repos/moonshine-ai/moonshine/releases/latest | grep '"tag_name"' | sed -E 's/.*"([^"]+)".*/\1/')
|
|
|
|
|
if [ -z "${VERSION}" ]; then
|
|
|
|
|
echo "ERROR: could not fetch latest release tag from GitHub API"
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
PREBUILT_URL="https://github.com/moonshine-ai/moonshine/releases/download/${VERSION}/moonshine-voice-${ARCH}.tar.gz"
|
|
|
|
|
SOURCE_URL="https://github.com/moonshine-ai/moonshine/archive/refs/tags/${VERSION}.tar.gz"
|
|
|
|
|
|
|
|
|
|
echo "=== rvsttd setup ==="
|
|
|
|
|
echo "Latest Moonshine release: ${VERSION}"
|
|
|
|
|
echo "Target: ${RVSTTD_DIR}"
|
|
|
|
|
echo ""
|
|
|
|
|
|
|
|
|
|
mkdir -p "${LIB_DIR}" "${INCLUDE_DIR}" "${BUILD_DIR}"
|
|
|
|
|
|
|
|
|
|
# Step 1: Download prebuilt package (for libonnxruntime.so.1 + header)
|
|
|
|
|
PREBUILT_TGZ="${BUILD_DIR}/moonshine-voice-${ARCH}.tar.gz"
|
|
|
|
|
PREBUILT_EXTRACTED="${BUILD_DIR}/moonshine-voice-${ARCH}"
|
|
|
|
|
|
|
|
|
|
if [ ! -f "${LIB_DIR}/libonnxruntime.so.1" ]; then
|
|
|
|
|
echo ">>> Downloading prebuilt package (for libonnxruntime.so.1)..."
|
|
|
|
|
curl -L -o "${PREBUILT_TGZ}" "${PREBUILT_URL}"
|
|
|
|
|
mkdir -p "${PREBUILT_EXTRACTED}"
|
|
|
|
|
tar xzf "${PREBUILT_TGZ}" -C "${PREBUILT_EXTRACTED}" --strip-components=1
|
|
|
|
|
|
|
|
|
|
# Copy ONNX Runtime (prebuilt is fine — it has no glibc issue)
|
|
|
|
|
cp "${PREBUILT_EXTRACTED}/lib/libonnxruntime.so.1" "${LIB_DIR}/"
|
|
|
|
|
echo " Installed libonnxruntime.so.1"
|
|
|
|
|
|
|
|
|
|
# Copy the header (it's the same in source and prebuilt)
|
|
|
|
|
cp "${PREBUILT_EXTRACTED}/include/moonshine-c-api.h" "${INCLUDE_DIR}/"
|
|
|
|
|
echo " Installed moonshine-c-api.h"
|
|
|
|
|
else
|
|
|
|
|
echo ">>> libonnxruntime.so.1 already present, skipping prebuilt download"
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
# Step 2: Download source
|
|
|
|
|
SOURCE_TGZ="${BUILD_DIR}/moonshine-source.tar.gz"
|
|
|
|
|
SOURCE_DIR="${BUILD_DIR}/moonshine-source"
|
|
|
|
|
|
|
|
|
|
if [ ! -d "${SOURCE_DIR}" ]; then
|
|
|
|
|
echo ">>> Downloading Moonshine source ${VERSION}..."
|
|
|
|
|
curl -L -o "${SOURCE_TGZ}" "${SOURCE_URL}"
|
|
|
|
|
mkdir -p "${SOURCE_DIR}"
|
|
|
|
|
tar xzf "${SOURCE_TGZ}" -C "${SOURCE_DIR}" --strip-components=1
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
# Step 3: Build libmoonshine.so from source
|
|
|
|
|
CMAKE_BUILD="${BUILD_DIR}/cmake-build"
|
|
|
|
|
|
|
|
|
|
if [ ! -f "${LIB_DIR}/libmoonshine.so" ]; then
|
|
|
|
|
echo ">>> Building libmoonshine.so from source..."
|
|
|
|
|
|
|
|
|
|
# Point CMake at the prebuilt ONNX Runtime
|
|
|
|
|
ORT_LIB_DIR="${LIB_DIR}"
|
|
|
|
|
ORT_INCLUDE_DIR="${SOURCE_DIR}/core/third-party/onnxruntime/include"
|
|
|
|
|
|
2026-08-13 10:35:26 +00:00
|
|
|
# Patch CMake minimum version for older distros (Debian 11 ships 3.18)
|
2026-08-13 10:37:43 +00:00
|
|
|
find "${SOURCE_DIR}" -name CMakeLists.txt -exec sed -i 's/cmake_minimum_required(VERSION 3\.22\.1)/cmake_minimum_required(VERSION 3.18.4)/' {} +
|
2026-08-13 10:35:26 +00:00
|
|
|
|
2026-08-13 10:43:10 +00:00
|
|
|
# Remove -Werror (fails on third-party headers with older compilers)
|
|
|
|
|
sed -i 's/-Werror//' "${SOURCE_DIR}/core/CMakeLists.txt"
|
|
|
|
|
|
2026-08-13 10:31:46 +00:00
|
|
|
mkdir -p "${CMAKE_BUILD}"
|
|
|
|
|
cd "${CMAKE_BUILD}"
|
|
|
|
|
|
|
|
|
|
cmake "${SOURCE_DIR}/core" \
|
|
|
|
|
-DCMAKE_BUILD_TYPE=Release \
|
|
|
|
|
-DONNXRUNTIME_LIB_PATH="${ORT_LIB_DIR}/libonnxruntime.so.1" \
|
2026-08-13 10:43:10 +00:00
|
|
|
-DMOONSHINE_TTS_BUILD_ONNX=OFF \
|
|
|
|
|
-DCMAKE_CXX_FLAGS="-I${SOURCE_DIR}/core/moonshine-tts/src"
|
2026-08-13 10:31:46 +00:00
|
|
|
|
|
|
|
|
make -j"$(nproc)" moonshine
|
|
|
|
|
|
|
|
|
|
cp "${CMAKE_BUILD}/libmoonshine.so" "${LIB_DIR}/"
|
|
|
|
|
cp "${SOURCE_DIR}/core/moonshine-c-api.h" "${INCLUDE_DIR}/"
|
|
|
|
|
echo " Installed libmoonshine.so (built from source)"
|
|
|
|
|
else
|
|
|
|
|
echo ">>> libmoonshine.so already present, skipping build"
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
echo ""
|
|
|
|
|
echo "=== Setup complete ==="
|
|
|
|
|
echo "Library: ${LIB_DIR}/libmoonshine.so"
|
|
|
|
|
echo "Library: ${LIB_DIR}/libonnxruntime.so.1"
|
|
|
|
|
echo "Header: ${INCLUDE_DIR}/moonshine-c-api.h"
|
|
|
|
|
echo ""
|
|
|
|
|
echo "Next: cd rvsttd && cargo build --release"
|
|
|
|
|
echo "Then: ./target/release/rvsttd fetch # downloads the model"
|
|
|
|
|
echo "Then: ./target/release/rvsttd # starts the server"
|