Skip to content

Commit

Permalink
Fix whisper test script for the latest onnxruntime. (#494)
Browse files Browse the repository at this point in the history
  • Loading branch information
csukuangfj authored Dec 20, 2023
1 parent 03ff9db commit ef8d112
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
15 changes: 14 additions & 1 deletion .github/workflows/export-whisper-to-onnx.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
- name: Install dependencies
shell: bash
run: |
python3 -m pip install torch==1.13.0 -f https://download.pytorch.org/whl/cpu/torch_stable.html
python3 -m pip install torch==1.13.0 torchaudio==0.13.0 -f https://download.pytorch.org/whl/cpu/torch_stable.html
python3 -m pip install openai-whisper==20230314 onnxruntime onnx
- name: export ${{ matrix.model }}
Expand Down Expand Up @@ -108,6 +108,19 @@ jobs:
repo_token: ${{ secrets.UPLOAD_GH_SHERPA_ONNX_TOKEN }}
tag: asr-models

- name: Test ${{ matrix.model }}
shell: bash
run: |
python3 -m pip install kaldi-native-fbank
git checkout .
model=${{ matrix.model }}
src=sherpa-onnx-whisper-$model
python3 scripts/whisper/test.py \
--encoder $src/$model-encoder.int8.onnx \
--decoder $src/$model-decoder.int8.onnx \
--tokens $src/$model-tokens.txt \
$src/test_wavs/0.wav
- name: Publish ${{ matrix.model }} to huggingface
shell: bash
env:
Expand Down
4 changes: 2 additions & 2 deletions build-apk-two-pass.sh
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,11 @@ git lfs pull --include "*.onnx"

# remove .git to save spaces
rm -rf .git
rm README.md
rm -fv README.md
rm -rf test_wavs
rm .gitattributes

rm *.ort
rm -fv *.ort
rm tiny.en-encoder.onnx
rm tiny.en-decoder.onnx

Expand Down
2 changes: 2 additions & 0 deletions scripts/whisper/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ def init_encoder(self, encoder: str):
self.encoder = ort.InferenceSession(
encoder,
sess_options=self.session_opts,
providers=["CPUExecutionProvider"],
)

meta = self.encoder.get_modelmeta().custom_metadata_map
Expand Down Expand Up @@ -113,6 +114,7 @@ def init_decoder(self, decoder: str):
self.decoder = ort.InferenceSession(
decoder,
sess_options=self.session_opts,
providers=["CPUExecutionProvider"],
)

def run_encoder(
Expand Down

0 comments on commit ef8d112

Please sign in to comment.