Test go inside sherpa-onnx (#374)
Previously, we only test the go api examples with pre-built packages. This PR tests go API examples against the latest source code of sherpa-onnx.
This commit is contained in:
@@ -1,24 +1,24 @@
|
||||
name: test-go
|
||||
name: test-go-package
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
tags:
|
||||
- '*'
|
||||
pull_request:
|
||||
branches:
|
||||
- master
|
||||
schedule:
|
||||
# minute (0-59)
|
||||
# hour (0-23)
|
||||
# day of the month (1-31)
|
||||
# month (1-12)
|
||||
# day of the week (0-6)
|
||||
# nightly build at 15:50 UTC time every day
|
||||
- cron: "50 15 * * *"
|
||||
|
||||
workflow_dispatch:
|
||||
|
||||
concurrency:
|
||||
group: go-${{ github.ref }}
|
||||
group: test-go-package-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
go:
|
||||
name: go ${{ matrix.os }} ${{matrix.arch }}
|
||||
test-go-package:
|
||||
name: ${{ matrix.os }} ${{matrix.arch }}
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
123
.github/workflows/test-go.yaml
vendored
Normal file
123
.github/workflows/test-go.yaml
vendored
Normal file
@@ -0,0 +1,123 @@
|
||||
name: test-go
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
pull_request:
|
||||
branches:
|
||||
- master
|
||||
|
||||
workflow_dispatch:
|
||||
|
||||
concurrency:
|
||||
group: test-go-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
test-go:
|
||||
name: ${{ matrix.os }} ${{matrix.arch }}
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- os: macos-latest
|
||||
arch: amd64
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: ccache
|
||||
uses: hendrikmuhs/ccache-action@v1.2
|
||||
with:
|
||||
key: ${{ matrix.os }}-${{ matrix.arch }}
|
||||
|
||||
- uses: actions/setup-go@v4
|
||||
with:
|
||||
go-version: '>=1.12'
|
||||
|
||||
- name: Display go version
|
||||
shell: bash
|
||||
run: |
|
||||
go version
|
||||
go env GOPATH
|
||||
go env GOARCH
|
||||
|
||||
- name: Build sherpa-onnx
|
||||
shell: bash
|
||||
run: |
|
||||
export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH"
|
||||
mkdir build
|
||||
cd build
|
||||
cmake -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DBUILD_SHARED_LIBS=ON -DSHERPA_ONNX_ENABLE_PORTAUDIO=OFF -DSHERPA_ONNX_ENABLE_WEBSOCKET=OFF ..
|
||||
make -j
|
||||
cp -v _deps/onnxruntime-src/lib/libonnxruntime*dylib ./lib/
|
||||
|
||||
cd ../scripts/go/_internal/
|
||||
go mod tidy
|
||||
go build
|
||||
|
||||
- name: Test non-streaming decoding files (macOS)
|
||||
shell: bash
|
||||
run: |
|
||||
cd scripts/go/_internal/non-streaming-decode-files/
|
||||
ls -lh
|
||||
go mod tidy
|
||||
cat go.mod
|
||||
go build
|
||||
ls -lh
|
||||
|
||||
git lfs install
|
||||
|
||||
echo "Test transducer"
|
||||
git clone https://huggingface.co/csukuangfj/sherpa-onnx-zipformer-en-2023-06-26
|
||||
./run-transducer.sh
|
||||
rm -rf sherpa-onnx-zipformer-en-2023-06-26
|
||||
|
||||
echo "Test paraformer"
|
||||
git clone https://huggingface.co/csukuangfj/sherpa-onnx-paraformer-zh-2023-03-28
|
||||
./run-paraformer.sh
|
||||
rm -rf sherpa-onnx-paraformer-zh-2023-03-28
|
||||
|
||||
echo "Test NeMo CTC"
|
||||
git clone https://huggingface.co/csukuangfj/sherpa-onnx-nemo-ctc-en-conformer-medium
|
||||
./run-nemo-ctc.sh
|
||||
rm -rf sherpa-onnx-nemo-ctc-en-conformer-medium
|
||||
|
||||
echo "Test Whisper tiny.en"
|
||||
GIT_LFS_SKIP_SMUDGE=1 git clone https://huggingface.co/csukuangfj/sherpa-onnx-whisper-tiny.en
|
||||
cd sherpa-onnx-whisper-tiny.en
|
||||
git lfs pull --include "*.onnx"
|
||||
cd ..
|
||||
./run-whisper.sh
|
||||
rm -rf sherpa-onnx-whisper-tiny.en
|
||||
|
||||
echo "Test Tdnn yesno"
|
||||
git clone https://huggingface.co/csukuangfj/sherpa-onnx-tdnn-yesno
|
||||
./run-tdnn-yesno.sh
|
||||
rm -rf sherpa-onnx-tdnn-yesno
|
||||
|
||||
- name: Test streaming decoding files
|
||||
shell: bash
|
||||
run: |
|
||||
cd scripts/go/_internal/streaming-decode-files
|
||||
ls -lh
|
||||
go mod tidy
|
||||
cat go.mod
|
||||
go build
|
||||
ls -lh
|
||||
|
||||
git lfs install
|
||||
|
||||
echo "Test transducer"
|
||||
git clone https://huggingface.co/csukuangfj/sherpa-onnx-streaming-zipformer-en-2023-06-26
|
||||
./run-transducer.sh
|
||||
rm -rf sherpa-onnx-streaming-zipformer-en-2023-06-26
|
||||
|
||||
echo "Test paraformer"
|
||||
git clone https://huggingface.co/csukuangfj/sherpa-onnx-streaming-paraformer-bilingual-zh-en
|
||||
./run-paraformer.sh
|
||||
rm -rf sherpa-onnx-streaming-paraformer-bilingual-zh-en
|
||||
4
scripts/go/README.md
Normal file
4
scripts/go/README.md
Normal file
@@ -0,0 +1,4 @@
|
||||
# Introduction
|
||||
|
||||
- [./_internal](./_internal) is for testing only. As a general user, you don't
|
||||
need to care about it.
|
||||
6
scripts/go/_internal/build_darwin_amd64.go
Normal file
6
scripts/go/_internal/build_darwin_amd64.go
Normal file
@@ -0,0 +1,6 @@
|
||||
//go:build darwin && amd64 && !ios
|
||||
|
||||
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
|
||||
import "C"
|
||||
1
scripts/go/_internal/c-api.h
Symbolic link
1
scripts/go/_internal/c-api.h
Symbolic link
@@ -0,0 +1 @@
|
||||
../../../sherpa-onnx/c-api/c-api.h
|
||||
3
scripts/go/_internal/go.mod
Normal file
3
scripts/go/_internal/go.mod
Normal file
@@ -0,0 +1,3 @@
|
||||
module sherpa_onnx
|
||||
|
||||
go 1.12
|
||||
1
scripts/go/_internal/lib/x86_64-apple-darwin
Symbolic link
1
scripts/go/_internal/lib/x86_64-apple-darwin
Symbolic link
@@ -0,0 +1 @@
|
||||
../../../../build/lib
|
||||
2
scripts/go/_internal/non-streaming-decode-files/.gitignore
vendored
Normal file
2
scripts/go/_internal/non-streaming-decode-files/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
non-streaming-decode-files
|
||||
sherpa-onnx-tdnn-yesno
|
||||
11
scripts/go/_internal/non-streaming-decode-files/go.mod
Normal file
11
scripts/go/_internal/non-streaming-decode-files/go.mod
Normal file
@@ -0,0 +1,11 @@
|
||||
module non-streaming-decode-files
|
||||
|
||||
go 1.12
|
||||
|
||||
replace github.com/k2-fsa/sherpa-onnx-go/sherpa_onnx => ../
|
||||
|
||||
require (
|
||||
github.com/k2-fsa/sherpa-onnx-go/sherpa_onnx v0.0.0-00010101000000-000000000000
|
||||
github.com/spf13/pflag v1.0.5
|
||||
github.com/youpy/go-wav v0.3.2
|
||||
)
|
||||
27
scripts/go/_internal/non-streaming-decode-files/go.sum
Normal file
27
scripts/go/_internal/non-streaming-decode-files/go.sum
Normal file
@@ -0,0 +1,27 @@
|
||||
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/google/go-cmp v0.5.6 h1:BKbKCqvP6I+rmFHt06ZmyQtvB8xAkWdhFyr0ZUNZcxQ=
|
||||
github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
|
||||
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
|
||||
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0=
|
||||
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/youpy/go-riff v0.1.0 h1:vZO/37nI4tIET8tQI0Qn0Y79qQh99aEpponTPiPut7k=
|
||||
github.com/youpy/go-riff v0.1.0/go.mod h1:83nxdDV4Z9RzrTut9losK7ve4hUnxUR8ASSz4BsKXwQ=
|
||||
github.com/youpy/go-wav v0.3.2 h1:NLM8L/7yZ0Bntadw/0h95OyUsen+DQIVf9gay+SUsMU=
|
||||
github.com/youpy/go-wav v0.3.2/go.mod h1:0FCieAXAeSdcxFfwLpRuEo0PFmAoc+8NU34h7TUvk50=
|
||||
github.com/zaf/g711 v0.0.0-20190814101024-76a4a538f52b h1:QqixIpc5WFIqTLxB3Hq8qs0qImAgBdq0p6rq2Qdl634=
|
||||
github.com/zaf/g711 v0.0.0-20190814101024-76a4a538f52b/go.mod h1:T2h1zV50R/q0CVYnsQOQ6L7P4a2ZxH47ixWcMXFGyx8=
|
||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
|
||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gotest.tools v2.2.0+incompatible h1:VsBPFP1AI068pPrMxtb/S8Zkgf9xEmTLJjfM+P5UIEo=
|
||||
gotest.tools v2.2.0+incompatible/go.mod h1:DsYFclhRJ6vuDpmuTbkuFWG+y2sxOXAzmJt81HFBacw=
|
||||
1
scripts/go/_internal/non-streaming-decode-files/main.go
Symbolic link
1
scripts/go/_internal/non-streaming-decode-files/main.go
Symbolic link
@@ -0,0 +1 @@
|
||||
../../../../go-api-examples/non-streaming-decode-files/main.go
|
||||
1
scripts/go/_internal/non-streaming-decode-files/run-nemo-ctc.sh
Symbolic link
1
scripts/go/_internal/non-streaming-decode-files/run-nemo-ctc.sh
Symbolic link
@@ -0,0 +1 @@
|
||||
../../../../go-api-examples/non-streaming-decode-files/run-nemo-ctc.sh
|
||||
@@ -0,0 +1 @@
|
||||
../../../../go-api-examples/non-streaming-decode-files/run-paraformer.sh
|
||||
@@ -0,0 +1 @@
|
||||
../../../../go-api-examples/non-streaming-decode-files/run-tdnn-yesno.sh
|
||||
@@ -0,0 +1 @@
|
||||
../../../../go-api-examples/non-streaming-decode-files/run-transducer.sh
|
||||
1
scripts/go/_internal/non-streaming-decode-files/run-whisper.sh
Symbolic link
1
scripts/go/_internal/non-streaming-decode-files/run-whisper.sh
Symbolic link
@@ -0,0 +1 @@
|
||||
../../../../go-api-examples/non-streaming-decode-files/run-whisper.sh
|
||||
1
scripts/go/_internal/real-time-speech-recognition-from-microphone/.gitignore
vendored
Normal file
1
scripts/go/_internal/real-time-speech-recognition-from-microphone/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
real-time-speech-recognition-from-microphone
|
||||
@@ -0,0 +1,11 @@
|
||||
module real-time-speech-recognition-from-microphone
|
||||
|
||||
go 1.12
|
||||
|
||||
replace github.com/k2-fsa/sherpa-onnx-go/sherpa_onnx => ../
|
||||
|
||||
require (
|
||||
github.com/gordonklaus/portaudio v0.0.0-20230709114228-aafa478834f5
|
||||
github.com/k2-fsa/sherpa-onnx-go/sherpa_onnx v0.0.0-00010101000000-000000000000
|
||||
github.com/spf13/pflag v1.0.5
|
||||
)
|
||||
@@ -0,0 +1,4 @@
|
||||
github.com/gordonklaus/portaudio v0.0.0-20230709114228-aafa478834f5 h1:5AlozfqaVjGYGhms2OsdUyfdJME76E6rx5MdGpjzZpc=
|
||||
github.com/gordonklaus/portaudio v0.0.0-20230709114228-aafa478834f5/go.mod h1:WY8R6YKlI2ZI3UyzFk7P6yGSuS+hFwNtEzrexRyD7Es=
|
||||
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
|
||||
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
|
||||
@@ -0,0 +1 @@
|
||||
../../../../go-api-examples/real-time-speech-recognition-from-microphone/main.go
|
||||
@@ -0,0 +1 @@
|
||||
../../../../go-api-examples/real-time-speech-recognition-from-microphone/run.sh
|
||||
1
scripts/go/_internal/sherpa_onnx.go
Symbolic link
1
scripts/go/_internal/sherpa_onnx.go
Symbolic link
@@ -0,0 +1 @@
|
||||
../sherpa_onnx.go
|
||||
1
scripts/go/_internal/streaming-decode-files/.gitignore
vendored
Normal file
1
scripts/go/_internal/streaming-decode-files/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
streaming-decode-files
|
||||
11
scripts/go/_internal/streaming-decode-files/go.mod
Normal file
11
scripts/go/_internal/streaming-decode-files/go.mod
Normal file
@@ -0,0 +1,11 @@
|
||||
module streaming-decode-files
|
||||
|
||||
go 1.12
|
||||
|
||||
replace github.com/k2-fsa/sherpa-onnx-go/sherpa_onnx => ../
|
||||
|
||||
require (
|
||||
github.com/k2-fsa/sherpa-onnx-go/sherpa_onnx v0.0.0-00010101000000-000000000000
|
||||
github.com/spf13/pflag v1.0.5
|
||||
github.com/youpy/go-wav v0.3.2
|
||||
)
|
||||
27
scripts/go/_internal/streaming-decode-files/go.sum
Normal file
27
scripts/go/_internal/streaming-decode-files/go.sum
Normal file
@@ -0,0 +1,27 @@
|
||||
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/google/go-cmp v0.5.6 h1:BKbKCqvP6I+rmFHt06ZmyQtvB8xAkWdhFyr0ZUNZcxQ=
|
||||
github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
|
||||
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
|
||||
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0=
|
||||
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/youpy/go-riff v0.1.0 h1:vZO/37nI4tIET8tQI0Qn0Y79qQh99aEpponTPiPut7k=
|
||||
github.com/youpy/go-riff v0.1.0/go.mod h1:83nxdDV4Z9RzrTut9losK7ve4hUnxUR8ASSz4BsKXwQ=
|
||||
github.com/youpy/go-wav v0.3.2 h1:NLM8L/7yZ0Bntadw/0h95OyUsen+DQIVf9gay+SUsMU=
|
||||
github.com/youpy/go-wav v0.3.2/go.mod h1:0FCieAXAeSdcxFfwLpRuEo0PFmAoc+8NU34h7TUvk50=
|
||||
github.com/zaf/g711 v0.0.0-20190814101024-76a4a538f52b h1:QqixIpc5WFIqTLxB3Hq8qs0qImAgBdq0p6rq2Qdl634=
|
||||
github.com/zaf/g711 v0.0.0-20190814101024-76a4a538f52b/go.mod h1:T2h1zV50R/q0CVYnsQOQ6L7P4a2ZxH47ixWcMXFGyx8=
|
||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
|
||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gotest.tools v2.2.0+incompatible h1:VsBPFP1AI068pPrMxtb/S8Zkgf9xEmTLJjfM+P5UIEo=
|
||||
gotest.tools v2.2.0+incompatible/go.mod h1:DsYFclhRJ6vuDpmuTbkuFWG+y2sxOXAzmJt81HFBacw=
|
||||
1
scripts/go/_internal/streaming-decode-files/main.go
Symbolic link
1
scripts/go/_internal/streaming-decode-files/main.go
Symbolic link
@@ -0,0 +1 @@
|
||||
../../../../go-api-examples/streaming-decode-files/main.go
|
||||
Reference in New Issue
Block a user