Add non-streaming ASR (#92)
This commit is contained in:
10
.github/scripts/Main.kt
vendored
10
.github/scripts/Main.kt
vendored
@@ -33,18 +33,20 @@ fun main() {
|
||||
config = config,
|
||||
)
|
||||
|
||||
var samples = WaveReader.readWave(
|
||||
var objArray = WaveReader.readWave(
|
||||
assetManager = AssetManager(),
|
||||
filename = "./sherpa-onnx-streaming-zipformer-en-2023-02-21/test_wavs/1089-134686-0001.wav",
|
||||
)
|
||||
var samples : FloatArray = objArray[0] as FloatArray
|
||||
var sampleRate : Int = objArray[1] as Int
|
||||
|
||||
model.acceptWaveform(samples!!, sampleRate=16000)
|
||||
model.acceptWaveform(samples, sampleRate=sampleRate)
|
||||
while (model.isReady()) {
|
||||
model.decode()
|
||||
}
|
||||
|
||||
var tail_paddings = FloatArray(8000) // 0.5 seconds
|
||||
model.acceptWaveform(tail_paddings, sampleRate=16000)
|
||||
var tail_paddings = FloatArray((sampleRate * 0.5).toInt()) // 0.5 seconds
|
||||
model.acceptWaveform(tail_paddings, sampleRate=sampleRate)
|
||||
model.inputFinished()
|
||||
while (model.isReady()) {
|
||||
model.decode()
|
||||
|
||||
60
.github/scripts/test-offline-transducer.sh
vendored
Executable file
60
.github/scripts/test-offline-transducer.sh
vendored
Executable file
@@ -0,0 +1,60 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
|
||||
log() {
|
||||
# This function is from espnet
|
||||
local fname=${BASH_SOURCE[1]##*/}
|
||||
echo -e "$(date '+%Y-%m-%d %H:%M:%S') (${fname}:${BASH_LINENO[0]}:${FUNCNAME[1]}) $*"
|
||||
}
|
||||
|
||||
echo "EXE is $EXE"
|
||||
echo "PATH: $PATH"
|
||||
|
||||
which $EXE
|
||||
|
||||
log "------------------------------------------------------------"
|
||||
log "Run Conformer transducer (English)"
|
||||
log "------------------------------------------------------------"
|
||||
|
||||
repo_url=https://huggingface.co/csukuangfj/sherpa-onnx-conformer-en-2023-03-18
|
||||
log "Start testing ${repo_url}"
|
||||
repo=$(basename $repo_url)
|
||||
log "Download pretrained model and test-data from $repo_url"
|
||||
|
||||
GIT_LFS_SKIP_SMUDGE=1 git clone $repo_url
|
||||
pushd $repo
|
||||
git lfs pull --include "*.onnx"
|
||||
cd test_wavs
|
||||
popd
|
||||
|
||||
waves=(
|
||||
$repo/test_wavs/0.wav
|
||||
$repo/test_wavs/1.wav
|
||||
$repo/test_wavs/2.wav
|
||||
)
|
||||
|
||||
for wave in ${waves[@]}; do
|
||||
time $EXE \
|
||||
$repo/tokens.txt \
|
||||
$repo/encoder-epoch-99-avg-1.onnx \
|
||||
$repo/decoder-epoch-99-avg-1.onnx \
|
||||
$repo/joiner-epoch-99-avg-1.onnx \
|
||||
$wave \
|
||||
2
|
||||
done
|
||||
|
||||
|
||||
if command -v sox &> /dev/null; then
|
||||
echo "test 8kHz"
|
||||
sox $repo/test_wavs/0.wav -r 8000 8k.wav
|
||||
time $EXE \
|
||||
$repo/tokens.txt \
|
||||
$repo/encoder-epoch-99-avg-1.onnx \
|
||||
$repo/decoder-epoch-99-avg-1.onnx \
|
||||
$repo/joiner-epoch-99-avg-1.onnx \
|
||||
8k.wav \
|
||||
2
|
||||
fi
|
||||
|
||||
rm -rf $repo
|
||||
10
.github/scripts/test-online-transducer.sh
vendored
10
.github/scripts/test-online-transducer.sh
vendored
@@ -40,7 +40,7 @@ for wave in ${waves[@]}; do
|
||||
$repo/decoder-epoch-99-avg-1.onnx \
|
||||
$repo/joiner-epoch-99-avg-1.onnx \
|
||||
$wave \
|
||||
4
|
||||
2
|
||||
done
|
||||
|
||||
rm -rf $repo
|
||||
@@ -72,7 +72,7 @@ for wave in ${waves[@]}; do
|
||||
$repo/decoder-epoch-11-avg-1.onnx \
|
||||
$repo/joiner-epoch-11-avg-1.onnx \
|
||||
$wave \
|
||||
4
|
||||
2
|
||||
done
|
||||
|
||||
rm -rf $repo
|
||||
@@ -104,7 +104,7 @@ for wave in ${waves[@]}; do
|
||||
$repo/decoder-epoch-99-avg-1.onnx \
|
||||
$repo/joiner-epoch-99-avg-1.onnx \
|
||||
$wave \
|
||||
4
|
||||
2
|
||||
done
|
||||
|
||||
rm -rf $repo
|
||||
@@ -138,7 +138,7 @@ for wave in ${waves[@]}; do
|
||||
$repo/decoder-epoch-99-avg-1.onnx \
|
||||
$repo/joiner-epoch-99-avg-1.onnx \
|
||||
$wave \
|
||||
4
|
||||
2
|
||||
done
|
||||
|
||||
# Decode a URL
|
||||
@@ -149,7 +149,7 @@ if [ $EXE == "sherpa-onnx-ffmpeg" ]; then
|
||||
$repo/decoder-epoch-99-avg-1.onnx \
|
||||
$repo/joiner-epoch-99-avg-1.onnx \
|
||||
https://huggingface.co/csukuangfj/sherpa-onnx-streaming-zipformer-bilingual-zh-en-2023-02-20/resolve/main/test_wavs/4.wav \
|
||||
4
|
||||
2
|
||||
fi
|
||||
|
||||
rm -rf $repo
|
||||
|
||||
37
.github/workflows/linux.yaml
vendored
37
.github/workflows/linux.yaml
vendored
@@ -7,11 +7,11 @@ on:
|
||||
paths:
|
||||
- '.github/workflows/linux.yaml'
|
||||
- '.github/scripts/test-online-transducer.sh'
|
||||
- '.github/scripts/test-offline-transducer.sh'
|
||||
- 'CMakeLists.txt'
|
||||
- 'cmake/**'
|
||||
- 'sherpa-onnx/csrc/*'
|
||||
- 'sherpa-onnx/c-api/*'
|
||||
- 'ffmpeg-examples/**'
|
||||
- 'c-api-examples/**'
|
||||
pull_request:
|
||||
branches:
|
||||
@@ -19,11 +19,11 @@ on:
|
||||
paths:
|
||||
- '.github/workflows/linux.yaml'
|
||||
- '.github/scripts/test-online-transducer.sh'
|
||||
- '.github/scripts/test-offline-transducer.sh'
|
||||
- 'CMakeLists.txt'
|
||||
- 'cmake/**'
|
||||
- 'sherpa-onnx/csrc/*'
|
||||
- 'sherpa-onnx/c-api/*'
|
||||
- 'ffmpeg-examples/**'
|
||||
|
||||
concurrency:
|
||||
group: linux-${{ github.ref }}
|
||||
@@ -39,35 +39,26 @@ jobs:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [ubuntu-latest]
|
||||
build_type: [Release, Debug]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Install ffmpeg
|
||||
- name: Install sox
|
||||
shell: bash
|
||||
run: |
|
||||
sudo apt-get install -y software-properties-common
|
||||
sudo add-apt-repository ppa:savoury1/ffmpeg4
|
||||
sudo add-apt-repository ppa:savoury1/ffmpeg5
|
||||
|
||||
sudo apt-get install -y libavdevice-dev libavutil-dev ffmpeg
|
||||
pkg-config --modversion libavutil
|
||||
ffmpeg -version
|
||||
|
||||
- name: Show ffmpeg version
|
||||
shell: bash
|
||||
run: |
|
||||
pkg-config --modversion libavutil
|
||||
ffmpeg -version
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y sox
|
||||
sox -h
|
||||
|
||||
- name: Configure CMake
|
||||
shell: bash
|
||||
run: |
|
||||
mkdir build
|
||||
cd build
|
||||
cmake -D CMAKE_BUILD_TYPE=Release ..
|
||||
cmake -D CMAKE_BUILD_TYPE=${{ matrix.build_type }} ..
|
||||
|
||||
- name: Build sherpa-onnx for ubuntu
|
||||
shell: bash
|
||||
@@ -78,21 +69,19 @@ jobs:
|
||||
ls -lh lib
|
||||
ls -lh bin
|
||||
|
||||
cd ../ffmpeg-examples
|
||||
make
|
||||
|
||||
- name: Display dependencies of sherpa-onnx for linux
|
||||
shell: bash
|
||||
run: |
|
||||
file build/bin/sherpa-onnx
|
||||
readelf -d build/bin/sherpa-onnx
|
||||
|
||||
- name: Test sherpa-onnx-ffmpeg
|
||||
- name: Test offline transducer
|
||||
shell: bash
|
||||
run: |
|
||||
export PATH=$PWD/ffmpeg-examples:$PATH
|
||||
export EXE=sherpa-onnx-ffmpeg
|
||||
export PATH=$PWD/build/bin:$PATH
|
||||
export EXE=sherpa-onnx-offline
|
||||
|
||||
.github/scripts/test-online-transducer.sh
|
||||
.github/scripts/test-offline-transducer.sh
|
||||
|
||||
- name: Test online transducer
|
||||
shell: bash
|
||||
|
||||
19
.github/workflows/macos.yaml
vendored
19
.github/workflows/macos.yaml
vendored
@@ -7,6 +7,7 @@ on:
|
||||
paths:
|
||||
- '.github/workflows/macos.yaml'
|
||||
- '.github/scripts/test-online-transducer.sh'
|
||||
- '.github/scripts/test-offline-transducer.sh'
|
||||
- 'CMakeLists.txt'
|
||||
- 'cmake/**'
|
||||
- 'sherpa-onnx/csrc/*'
|
||||
@@ -16,6 +17,7 @@ on:
|
||||
paths:
|
||||
- '.github/workflows/macos.yaml'
|
||||
- '.github/scripts/test-online-transducer.sh'
|
||||
- '.github/scripts/test-offline-transducer.sh'
|
||||
- 'CMakeLists.txt'
|
||||
- 'cmake/**'
|
||||
- 'sherpa-onnx/csrc/*'
|
||||
@@ -34,18 +36,25 @@ jobs:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [macos-latest]
|
||||
build_type: [Release, Debug]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Install sox
|
||||
shell: bash
|
||||
run: |
|
||||
brew install sox
|
||||
sox -h
|
||||
|
||||
- name: Configure CMake
|
||||
shell: bash
|
||||
run: |
|
||||
mkdir build
|
||||
cd build
|
||||
cmake -D CMAKE_BUILD_TYPE=Release ..
|
||||
cmake -D CMAKE_BUILD_TYPE=${{ matrix.build_type }} ..
|
||||
|
||||
- name: Build sherpa-onnx for macos
|
||||
shell: bash
|
||||
@@ -64,6 +73,14 @@ jobs:
|
||||
otool -L build/bin/sherpa-onnx
|
||||
otool -l build/bin/sherpa-onnx
|
||||
|
||||
- name: Test offline transducer
|
||||
shell: bash
|
||||
run: |
|
||||
export PATH=$PWD/build/bin:$PATH
|
||||
export EXE=sherpa-onnx-offline
|
||||
|
||||
.github/scripts/test-offline-transducer.sh
|
||||
|
||||
- name: Test online transducer
|
||||
shell: bash
|
||||
run: |
|
||||
|
||||
Reference in New Issue
Block a user