From b9626f2e0684dd59d761c6bd6e9b6127a387d11c Mon Sep 17 00:00:00 2001 From: Yifan Yang <64255737+yfyeung@users.noreply.github.com> Date: Thu, 5 Jan 2023 17:18:43 +0800 Subject: [PATCH 1/3] fix typo for ctc-decode.py (#815) Co-authored-by: yifanyang --- .../ASR/pruned_transducer_stateless7_ctc/ctc_decode.py | 2 +- .../ASR/pruned_transducer_stateless7_ctc_bs/ctc_decode.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/egs/librispeech/ASR/pruned_transducer_stateless7_ctc/ctc_decode.py b/egs/librispeech/ASR/pruned_transducer_stateless7_ctc/ctc_decode.py index 9c23e7d66..4b373e4c7 100755 --- a/egs/librispeech/ASR/pruned_transducer_stateless7_ctc/ctc_decode.py +++ b/egs/librispeech/ASR/pruned_transducer_stateless7_ctc/ctc_decode.py @@ -44,7 +44,7 @@ Usage: --exp-dir ./pruned_transducer_stateless7_ctc/exp \ --max-duration 600 \ --hlg-scale 0.8 \ - --decoding-method 1best + --decoding-method nbest (4) nbest-rescoring ./pruned_transducer_stateless7_ctc/ctc_decode.py \ diff --git a/egs/librispeech/ASR/pruned_transducer_stateless7_ctc_bs/ctc_decode.py b/egs/librispeech/ASR/pruned_transducer_stateless7_ctc_bs/ctc_decode.py index 0ef733226..f137485b2 100755 --- a/egs/librispeech/ASR/pruned_transducer_stateless7_ctc_bs/ctc_decode.py +++ b/egs/librispeech/ASR/pruned_transducer_stateless7_ctc_bs/ctc_decode.py @@ -42,7 +42,7 @@ Usage: --exp-dir ./pruned_transducer_stateless7_ctc_bs/exp \ --max-duration 600 \ --hlg-scale 0.8 \ - --decoding-method 1best + --decoding-method nbest (4) nbest-rescoring ./pruned_transducer_stateless7_ctc_bs/ctc_decode.py \ --epoch 30 \ From 9a9c5a0f9b083a729ee00d439df1054f517e1b6d Mon Sep 17 00:00:00 2001 From: kobenaxie <572745565@qq.com> Date: Fri, 6 Jan 2023 11:16:22 +0800 Subject: [PATCH 2/3] remove unused codes. (#821) --- .../emformer2.py | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/egs/librispeech/ASR/conv_emformer_transducer_stateless2/emformer2.py b/egs/librispeech/ASR/conv_emformer_transducer_stateless2/emformer2.py index 188059044..f0c92a9b4 100644 --- a/egs/librispeech/ASR/conv_emformer_transducer_stateless2/emformer2.py +++ b/egs/librispeech/ASR/conv_emformer_transducer_stateless2/emformer2.py @@ -1512,24 +1512,6 @@ class EmformerEncoder(nn.Module): ) return states - attn_caches = [ - [ - torch.zeros(self.memory_size, self.d_model, device=device), - torch.zeros(self.left_context_length, self.d_model, device=device), - torch.zeros(self.left_context_length, self.d_model, device=device), - ] - for _ in range(self.num_encoder_layers) - ] - conv_caches = [ - torch.zeros(self.d_model, self.cnn_module_kernel - 1, device=device) - for _ in range(self.num_encoder_layers) - ] - states: Tuple[List[List[torch.Tensor]], List[torch.Tensor]] = ( - attn_caches, - conv_caches, - ) - return states - class Emformer(EncoderInterface): def __init__( From 9453eb1c709140becd3373666bb51e996e8f7260 Mon Sep 17 00:00:00 2001 From: Fangjun Kuang Date: Fri, 6 Jan 2023 17:00:27 +0800 Subject: [PATCH 3/3] Fix doc for building ncnn (#822) --- docs/README.md | 24 ++++++++++++++ .../lstm_pruned_stateless_transducer.rst | 31 ++++++++++++++++--- 2 files changed, 51 insertions(+), 4 deletions(-) create mode 100644 docs/README.md diff --git a/docs/README.md b/docs/README.md new file mode 100644 index 000000000..3abb38f8b --- /dev/null +++ b/docs/README.md @@ -0,0 +1,24 @@ + +## Usage + +```bash +cd /path/to/icefall/docs +pip install -r requirements.txt +make clean +make html +cd build/html +python3 -m http.server 8000 +``` + +It prints: + +``` +Serving HTTP on 0.0.0.0 port 8000 (http://0.0.0.0:8000/) ... +``` + +Open your browser and go to to view the generated +documentation. + +Done! + +**Hint**: You can change the port number when starting the server. diff --git a/docs/source/recipes/Streaming-ASR/librispeech/lstm_pruned_stateless_transducer.rst b/docs/source/recipes/Streaming-ASR/librispeech/lstm_pruned_stateless_transducer.rst index 643855cc2..d09421eb5 100644 --- a/docs/source/recipes/Streaming-ASR/librispeech/lstm_pruned_stateless_transducer.rst +++ b/docs/source/recipes/Streaming-ASR/librispeech/lstm_pruned_stateless_transducer.rst @@ -531,16 +531,36 @@ First, let us install a modified version of ``ncnn``: git clone https://github.com/csukuangfj/ncnn cd ncnn git submodule update --recursive --init - python3 setup.py bdist_wheel - ls -lh dist/ - pip install ./dist/*.whl + + # Note: We don't use "python setup.py install" or "pip install ." here + + mkdir -p build-wheel + cd build-wheel + + cmake \ + -DCMAKE_BUILD_TYPE=Release \ + -DNCNN_PYTHON=ON \ + -DNCNN_BUILD_BENCHMARK=OFF \ + -DNCNN_BUILD_EXAMPLES=OFF \ + -DNCNN_BUILD_TOOLS=OFF \ + .. + + make -j4 + + cd .. + + # Note: $PWD here is /path/to/ncnn + + export PYTHONPATH=$PWD/python:$PYTHONPATH + export PATH=$PWD/tools/pnnx/build/src:$PATH + export PATH=$PWD/build/tools/quantize:$PATH # now build pnnx cd tools/pnnx mkdir build cd build + cmake .. make -j4 - export PATH=$PWD/src:$PATH ./src/pnnx @@ -549,6 +569,9 @@ First, let us install a modified version of ``ncnn``: We assume that you have added the path to the binary ``pnnx`` to the environment variable ``PATH``. + We also assume that you have added ``build/tools/quantize`` to the environment + variable ``PATH`` so that you are able to use ``ncnn2int8`` later. + Second, let us export the model using ``torch.jit.trace()`` that is suitable for ``pnnx``: