-
Notifications
You must be signed in to change notification settings - Fork 110
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add streaming ASR with Emformer RNN-T (#6)
* First working version. * First C++ working version. * Refactoring. * Add streaming ASR with stateless Emformer RNN-T. * typo fixes * Fix comments. * Add web interface. * Add CI for streaming ASR. * Minor fixes to README. * Minor fixes.
- Loading branch information
1 parent
259d2b9
commit ba865c7
Showing
35 changed files
with
2,282 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
# Copyright 2022 Xiaomi Corp. (author: Fangjun Kuang) | ||
|
||
# See ../../LICENSE for clarification regarding multiple authors | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
name: Run streaming ASR tests | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
pull_request: | ||
branches: | ||
- master | ||
|
||
jobs: | ||
run_streaming_asr_tests: | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
os: [ubuntu-18.04, macos-10.15] | ||
torch: ["1.10.0"] | ||
torchaudio: ["0.10.0"] | ||
python-version: [3.7, 3.8, 3.9] | ||
steps: | ||
- uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Setup Python | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
|
||
- name: Install GCC 7 | ||
if: startsWith(matrix.os, 'ubuntu') | ||
run: | | ||
sudo apt-get install -y gcc-7 g++-7 | ||
echo "CC=/usr/bin/gcc-7" >> $GITHUB_ENV | ||
echo "CXX=/usr/bin/g++-7" >> $GITHUB_ENV | ||
- name: Install PyTorch ${{ matrix.torch }} | ||
shell: bash | ||
if: startsWith(matrix.os, 'ubuntu') | ||
run: | | ||
python3 -m pip install -qq --upgrade pip | ||
python3 -m pip install -qq wheel twine typing_extensions websockets sentencepiece>=0.1.96 | ||
python3 -m pip install -qq torch==${{ matrix.torch }}+cpu torchaudio==${{ matrix.torchaudio }}+cpu numpy -f https://download.pytorch.org/whl/cpu/torch_stable.html | ||
- name: Install PyTorch ${{ matrix.torch }} | ||
shell: bash | ||
if: startsWith(matrix.os, 'macos') | ||
run: | | ||
python3 -m pip install -qq --upgrade pip | ||
python3 -m pip install -qq wheel twine typing_extensions websockets sentencepiece>=0.1.96 | ||
python3 -m pip install -qq torch==${{ matrix.torch }} torchaudio==${{ matrix.torchaudio }} numpy -f https://download.pytorch.org/whl/cpu/torch_stable.html | ||
- name: Cache kaldifeat | ||
id: my-cache | ||
uses: actions/cache@v2 | ||
with: | ||
path: | | ||
~/tmp/kaldifeat | ||
key: cache-tmp-${{ matrix.python-version }}-${{ matrix.os }} | ||
|
||
- name: Install kaldifeat | ||
if: steps.my-cache.outputs.cache-hit != 'true' | ||
shell: bash | ||
run: | | ||
.github/scripts/install-kaldifeat.sh | ||
- name: Install sherpa | ||
shell: bash | ||
run: | | ||
python3 setup.py install | ||
- name: Download pretrained model and test-data | ||
shell: bash | ||
run: | | ||
git lfs install | ||
git clone https://huggingface.co/csukuangfj/icefall-asr-librispeech-pruned-stateless-emformer-rnnt2-2022-06-01 | ||
- name: Start server | ||
shell: bash | ||
run: | | ||
export PYTHONPATH=~/tmp/kaldifeat/kaldifeat/python:$PYTHONPATH | ||
export PYTHONPATH=~/tmp/kaldifeat/build/lib:$PYTHONPATH | ||
./sherpa/bin/pruned_stateless_emformer_rnnt2/streaming_server.py \ | ||
--port 6006 \ | ||
--max-batch-size 50 \ | ||
--max-wait-ms 5 \ | ||
--nn-pool-size 1 \ | ||
--nn-model-filename ./icefall-asr-librispeech-pruned-stateless-emformer-rnnt2-2022-06-01/exp/cpu_jit-epoch-39-avg-6-use-averaged-model-1.pt \ | ||
--bpe-model-filename ./icefall-asr-librispeech-pruned-stateless-emformer-rnnt2-2022-06-01/data/lang_bpe_500/bpe.model & | ||
echo "Sleep 10 seconds to wait for the server startup" | ||
sleep 10 | ||
- name: Start client | ||
shell: bash | ||
run: | | ||
./sherpa/bin/pruned_stateless_emformer_rnnt2/streaming_client.py \ | ||
--server-addr localhost \ | ||
--server-port 6006 \ | ||
./icefall-asr-librispeech-pruned-stateless-emformer-rnnt2-2022-06-01/test_wavs/1221-135766-0001.wav |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# Copyright (c) 2022 Xiaomi Corporation (authors: Fangjun Kuang) | ||
# | ||
# See ../../LICENSE for clarification regarding multiple authors | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
name: style_check | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
pull_request: | ||
branches: | ||
- master | ||
|
||
jobs: | ||
style_check: | ||
runs-on: ubuntu-18.04 | ||
strategy: | ||
matrix: | ||
python-version: [3.8] | ||
fail-fast: false | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Setup Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v1 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
|
||
- name: Check style with cpplint | ||
shell: bash | ||
working-directory: ${{github.workspace}} | ||
run: ./scripts/check_style_cpplint.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.