Fix releasing go packages (#476)

This commit is contained in:
Fangjun Kuang
2023-12-09 00:07:52 +08:00
committed by GitHub
parent aef74c5125
commit cae0231f93
13 changed files with 261 additions and 301 deletions

View File

@@ -2,5 +2,5 @@
package sherpa_onnx
// #cgo LDFLAGS: -L ${SRCDIR}/lib/x86_64-apple-darwin -lsherpa-onnx-c-api -lsherpa-onnx-core -lkaldi-native-fbank-core -lonnxruntime -Wl,-rpath,${SRCDIR}/lib/x86_64-apple-darwin
// #cgo LDFLAGS: -L ${SRCDIR}/lib/x86_64-apple-darwin -lsherpa-onnx-c-api -lsherpa-onnx-core -lkaldi-native-fbank-core -lkaldi-decoder-core -lsherpa-onnx-kaldifst-core -lsherpa-onnx-fst -lpiper_phonemize -lespeak-ng -lucd -lonnxruntime -Wl,-rpath,${SRCDIR}/lib/x86_64-apple-darwin
import "C"

View File

@@ -5,145 +5,159 @@ set -ex
git config --global user.email "csukuangfj@gmail.com"
git config --global user.name "Fangjun Kuang"
SHERPA_ONNX_VERSION=v$(grep "SHERPA_ONNX_VERSION" ./CMakeLists.txt | cut -d " " -f 2 | cut -d '"' -f 2)
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
SHERPA_ONNX_DIR=$(realpath $SCRIPT_DIR/../..)
echo "SCRIPT_DIR: $SCRIPT_DIR"
echo "SHERPA_ONNX_DIR: $SHERPA_ONNX_DIR"
echo "========================================================================="
git clone git@github.com:k2-fsa/sherpa-onnx-go-linux.git
SHERPA_ONNX_VERSION=$(grep "SHERPA_ONNX_VERSION" $SHERPA_ONNX_DIR/CMakeLists.txt | cut -d " " -f 2 | cut -d '"' -f 2)
echo "SHERPA_ONNX_VERSION $SHERPA_ONNX_VERSION"
echo "Copy libs for Linux x86_64"
function linux() {
echo "Process linux"
git clone git@github.com:k2-fsa/sherpa-onnx-go-linux.git
cp -v ./sherpa_onnx.go ./sherpa-onnx-go-linux/
cp -v ./_internal/c-api.h ./sherpa-onnx-go-linux/
rm -rf sherpa-onnx-go-linux/lib/x86_64-unknown-linux-gnu/lib*
rm -rf sherpa-onnx-go-linux/lib/x86_64-unknown-linux-gnu/lib*
dst=$(realpath sherpa-onnx-go-linux/lib/x86_64-unknown-linux-gnu)
mkdir t
cd t
wget -q https://huggingface.co/csukuangfj/sherpa-onnx-wheels/resolve/main/sherpa_onnx-${SHERPA_ONNX_VERSION}-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
unzip ./sherpa_onnx-${SHERPA_ONNX_VERSION}-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
cp -v ./linux/sherpa_onnx/lib/libkaldi-native-fbank-core.so sherpa-onnx-go-linux/lib/x86_64-unknown-linux-gnu/
cp -v ./linux/sherpa_onnx/lib/libonnxruntime* sherpa-onnx-go-linux/lib/x86_64-unknown-linux-gnu/
cp -v ./linux/sherpa_onnx/lib/libsherpa-onnx-c-api.so sherpa-onnx-go-linux/lib/x86_64-unknown-linux-gnu/
cp -v ./linux/sherpa_onnx/lib/libsherpa-onnx-core.so sherpa-onnx-go-linux/lib/x86_64-unknown-linux-gnu/
cp -v sherpa_onnx/lib/*.so* $dst
echo "Copy sources for Linux x86_64"
cp sherpa-onnx/c-api/c-api.h sherpa-onnx-go-linux/
cp scripts/go/sherpa_onnx.go sherpa-onnx-go-linux/
cd ..
rm -rf t
pushd sherpa-onnx-go-linux
tag=$(git describe --abbrev=0 --tags)
if [[ x"$VERSION" == x"auto" ]]; then
# this is a pre-release
if [[ $tag == ${SHERPA_ONNX_VERSION}* ]]; then
# echo we have already release pre-release before, so just increment it
last=$(echo $tag | rev | cut -d'.' -f 1 | rev)
new_last=$((last+1))
new_tag=${SHERPA_ONNX_VERSION}-alpha.${new_last}
else
new_tag=${SHERPA_ONNX_VERSION}-alpha.1
fi
else
new_tag=$VERSION
fi
rm -rf sherpa-onnx-go-linux/lib/aarch64-unknown-linux-gnu/lib*
dst=$(realpath sherpa-onnx-go-linux/lib/aarch64-unknown-linux-gnu)
mkdir t
cd t
wget -q https://huggingface.co/csukuangfj/sherpa-onnx-wheels/resolve/main/sherpa_onnx-${SHERPA_ONNX_VERSION}-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
unzip ./sherpa_onnx-${SHERPA_ONNX_VERSION}-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
echo "new_tag: $new_tag"
git add .
git status
git commit -m "Release $new_tag" && \
git push && \
git tag $new_tag && \
git push origin $new_tag || true
cp -v sherpa_onnx/lib/*.so* $dst
popd
echo "========================================================================="
cd ..
rm -rf t
git clone git@github.com:k2-fsa/sherpa-onnx-go-macos.git
rm -rf sherpa-onnx-go-linux/lib/arm-unknown-linux-gnueabihf/lib*
dst=$(realpath sherpa-onnx-go-linux/lib/arm-unknown-linux-gnueabihf)
mkdir t
cd t
wget -q https://huggingface.co/csukuangfj/sherpa-onnx-wheels/resolve/main/sherpa_onnx-${SHERPA_ONNX_VERSION}-cp38-cp38-linux_armv7l.whl
unzip ./sherpa_onnx-${SHERPA_ONNX_VERSION}-cp38-cp38-linux_armv7l.whl
echo "Copy libs for macOS x86_64"
rm -rf sherpa-onnx-go-macos/lib/x86_64-apple-darwin/lib*
cp -v ./macos-x86_64/libkaldi-native-fbank-core.dylib sherpa-onnx-go-macos/lib/x86_64-apple-darwin
cp -v ./macos-x86_64/libonnxruntime* sherpa-onnx-go-macos/lib/x86_64-apple-darwin
cp -v ./macos-x86_64/libsherpa-onnx-c-api.dylib sherpa-onnx-go-macos/lib/x86_64-apple-darwin
cp -v ./macos-x86_64/libsherpa-onnx-core.dylib sherpa-onnx-go-macos/lib/x86_64-apple-darwin
cp -v sherpa_onnx/lib/*.so* $dst
echo "Copy libs for macOS arm64"
rm -rf sherpa-onnx-go-macos/lib/aarch64-apple-darwin/lib*
cp -v ./macos-arm64/libkaldi-native-fbank-core.dylib sherpa-onnx-go-macos/lib/aarch64-apple-darwin
cp -v ./macos-arm64/libonnxruntime* sherpa-onnx-go-macos/lib/aarch64-apple-darwin
cp -v ./macos-arm64/libsherpa-onnx-c-api.dylib sherpa-onnx-go-macos/lib/aarch64-apple-darwin
cp -v ./macos-arm64/libsherpa-onnx-core.dylib sherpa-onnx-go-macos/lib/aarch64-apple-darwin
cd ..
rm -rf t
echo "Copy sources for macOS"
cp sherpa-onnx/c-api/c-api.h sherpa-onnx-go-macos/
cp scripts/go/sherpa_onnx.go sherpa-onnx-go-macos/
echo "------------------------------"
cd sherpa-onnx-go-linux
git status
git add .
git commit -m "Release v$SHERPA_ONNX_VERSION" && \
git push && \
git tag v$SHERPA_ONNX_VERSION && \
git push origin v$SHERPA_ONNX_VERSION || true
cd ..
rm -rf sherpa-onnx-go-linux
}
pushd sherpa-onnx-go-macos
tag=$(git describe --abbrev=0 --tags)
if [[ x"$VERSION" == x"auto" ]]; then
# this is a pre-release
if [[ $tag == ${SHERPA_ONNX_VERSION}* ]]; then
# echo we have already release pre-release before, so just increment it
last=$(echo $tag | rev | cut -d'.' -f 1 | rev)
new_last=$((last+1))
new_tag=${SHERPA_ONNX_VERSION}-alpha.${new_last}
else
new_tag=${SHERPA_ONNX_VERSION}-alpha.1
fi
else
new_tag=$VERSION
fi
function osx() {
echo "Process osx-x64"
git clone git@github.com:k2-fsa/sherpa-onnx-go-macos.git
cp -v ./sherpa_onnx.go ./sherpa-onnx-go-macos/
cp -v ./_internal/c-api.h ./sherpa-onnx-go-macos/
echo "new_tag: $new_tag"
git add .
git status
git commit -m "Release $new_tag" && \
git push && \
git tag $new_tag && \
git push origin $new_tag || true
rm -rf sherpa-onnx-go-macos/lib/x86_64-apple-darwin/lib*
dst=$(realpath sherpa-onnx-go-macos/lib/x86_64-apple-darwin/)
popd
echo "========================================================================="
mkdir t
cd t
wget -q https://huggingface.co/csukuangfj/sherpa-onnx-wheels/resolve/main/sherpa_onnx-${SHERPA_ONNX_VERSION}-cp38-cp38-macosx_10_14_x86_64.whl
unzip ./sherpa_onnx-${SHERPA_ONNX_VERSION}-cp38-cp38-macosx_10_14_x86_64.whl
git clone git@github.com:k2-fsa/sherpa-onnx-go-windows.git
echo "Copy libs for Windows x86_64"
rm -fv sherpa-onnx-go-windows/lib/x86_64-pc-windows-gnu/*
cp -v ./windows-x64/kaldi-native-fbank-core.dll sherpa-onnx-go-windows/lib/x86_64-pc-windows-gnu
cp -v ./windows-x64/onnxruntime.dll sherpa-onnx-go-windows/lib/x86_64-pc-windows-gnu
cp -v ./windows-x64/sherpa-onnx-c-api.dll sherpa-onnx-go-windows/lib/x86_64-pc-windows-gnu
cp -v ./windows-x64/sherpa-onnx-core.dll sherpa-onnx-go-windows/lib/x86_64-pc-windows-gnu
cp -v sherpa_onnx/lib/*.dylib $dst/
echo "Copy libs for Windows x86"
rm -fv sherpa-onnx-go-windows/lib/i686-pc-windows-gnu/*
cp -v ./windows-win32/kaldi-native-fbank-core.dll sherpa-onnx-go-windows/lib/i686-pc-windows-gnu
cp -v ./windows-win32/onnxruntime.dll sherpa-onnx-go-windows/lib/i686-pc-windows-gnu
cp -v ./windows-win32/sherpa-onnx-c-api.dll sherpa-onnx-go-windows/lib/i686-pc-windows-gnu
cp -v ./windows-win32/sherpa-onnx-core.dll sherpa-onnx-go-windows/lib/i686-pc-windows-gnu
cd ..
rm -rf t
echo "Copy sources for Windows"
cp sherpa-onnx/c-api/c-api.h sherpa-onnx-go-windows/
cp scripts/go/sherpa_onnx.go sherpa-onnx-go-windows/
echo "process macos arm64"
rm -rf sherpa-onnx-go-macos/lib/aarch64-apple-darwin/lib*
dst=$(realpath sherpa-onnx-go-macos/lib/aarch64-apple-darwin)
pushd sherpa-onnx-go-windows
tag=$(git describe --abbrev=0 --tags)
if [[ x"$VERSION" == x"auto" ]]; then
# this is a pre-release
if [[ $tag == ${SHERPA_ONNX_VERSION}* ]]; then
# echo we have already release pre-release before, so just increment it
last=$(echo $tag | rev | cut -d'.' -f 1 | rev)
new_last=$((last+1))
new_tag=${SHERPA_ONNX_VERSION}-alpha.${new_last}
else
new_tag=${SHERPA_ONNX_VERSION}-alpha.1
fi
else
new_tag=$VERSION
fi
mkdir t
cd t
wget -q https://huggingface.co/csukuangfj/sherpa-onnx-wheels/resolve/main/sherpa_onnx-${SHERPA_ONNX_VERSION}-cp38-cp38-macosx_11_0_arm64.whl
unzip ./sherpa_onnx-${SHERPA_ONNX_VERSION}-cp38-cp38-macosx_11_0_arm64.whl
echo "new_tag: $new_tag"
git add .
git status
git commit -m "Release $new_tag" && \
git push && \
git tag $new_tag && \
git push origin $new_tag || true
cp -v sherpa_onnx/lib/*.dylib $dst/
popd
cd ..
rm -rf t
echo "------------------------------"
cd sherpa-onnx-go-macos
git status
git add .
git commit -m "Release v$SHERPA_ONNX_VERSION" && \
git push && \
git tag v$SHERPA_ONNX_VERSION && \
git push origin v$SHERPA_ONNX_VERSION || true
cd ..
rm -rf sherpa-onnx-go-macos
}
echo "========================================================================="
function windows() {
echo "Process windows"
git clone git@github.com:k2-fsa/sherpa-onnx-go-windows.git
cp -v ./sherpa_onnx.go ./sherpa-onnx-go-windows/
cp -v ./_internal/c-api.h ./sherpa-onnx-go-windows/
rm -fv sherpa-onnx-go-windows/lib/x86_64-pc-windows-gnu/*
dst=$(realpath sherpa-onnx-go-windows/lib/x86_64-pc-windows-gnu)
mkdir t
cd t
wget -q https://huggingface.co/csukuangfj/sherpa-onnx-wheels/resolve/main/sherpa_onnx-${SHERPA_ONNX_VERSION}-cp38-cp38-win_amd64.whl
unzip ./sherpa_onnx-${SHERPA_ONNX_VERSION}-cp38-cp38-win_amd64.whl
cp -v sherpa_onnx-${SHERPA_ONNX_VERSION}.data/data/bin/*.dll $dst
cp -v sherpa_onnx-${SHERPA_ONNX_VERSION}.data/data/bin/*.lib $dst
cd ..
rm -rf t
rm -fv sherpa-onnx-go-windows/lib/i686-pc-windows-gnu/*
dst=$(realpath sherpa-onnx-go-windows/lib/i686-pc-windows-gnu)
mkdir t
cd t
wget -q https://huggingface.co/csukuangfj/sherpa-onnx-wheels/resolve/main/sherpa_onnx-${SHERPA_ONNX_VERSION}-cp38-cp38-win32.whl
unzip ./sherpa_onnx-${SHERPA_ONNX_VERSION}-cp38-cp38-win32.whl
cp -v sherpa_onnx-${SHERPA_ONNX_VERSION}.data/data/bin/*.dll $dst
cp -v sherpa_onnx-${SHERPA_ONNX_VERSION}.data/data/bin/*.lib $dst
cd ..
rm -rf t
echo "------------------------------"
cd sherpa-onnx-go-windows
git status
git add .
git commit -m "Release v$SHERPA_ONNX_VERSION" && \
git push && \
git tag v$SHERPA_ONNX_VERSION && \
git push origin v$SHERPA_ONNX_VERSION || true
cd ..
rm -rf sherpa-onnx-go-windows
}
windows
linux
osx
rm -fv ~/.ssh/github

View File

@@ -503,6 +503,7 @@ type OfflineTtsVitsModelConfig struct {
Model string // Path to the VITS onnx model
Lexicon string // Path to lexicon.txt
Tokens string // Path to tokens.txt
DataDir string // Path to tokens.txt
NoiseScale float32 // noise scale for vits models. Please use 0.667 in general
NoiseScaleW float32 // noise scale for vits models. Please use 0.8 in general
LengthScale float32 // Please use 1.0 in general. Smaller -> Faster speech speed. Larger -> Slower speech speed
@@ -522,7 +523,9 @@ type OfflineTtsModelConfig struct {
}
type OfflineTtsConfig struct {
Model OfflineTtsModelConfig
Model OfflineTtsModelConfig
RuleFsts string
MaxNumSentences int
}
type GeneratedAudio struct {
@@ -547,6 +550,12 @@ func DeleteOfflineTts(tts *OfflineTts) {
// the returned tts to avoid memory leak
func NewOfflineTts(config *OfflineTtsConfig) *OfflineTts {
c := C.struct_SherpaOnnxOfflineTtsConfig{}
c.rule_fsts = C.CString(config.RuleFsts)
defer C.free(unsafe.Pointer(c.rule_fsts))
c.max_num_sentences = C.int(config.MaxNumSentences)
c.model.vits.model = C.CString(config.Model.Vits.Model)
defer C.free(unsafe.Pointer(c.model.vits.model))
@@ -556,6 +565,9 @@ func NewOfflineTts(config *OfflineTtsConfig) *OfflineTts {
c.model.vits.tokens = C.CString(config.Model.Vits.Tokens)
defer C.free(unsafe.Pointer(c.model.vits.tokens))
c.model.vits.data_dir = C.CString(config.Model.Vits.DataDir)
defer C.free(unsafe.Pointer(c.model.vits.data_dir))
c.model.vits.noise_scale = C.float(config.Model.Vits.NoiseScale)
c.model.vits.noise_scale_w = C.float(config.Model.Vits.NoiseScaleW)
c.model.vits.length_scale = C.float(config.Model.Vits.LengthScale)