Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reazon speech - add streaming #1707

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions egs/librispeech/ASR/zipformer/decode.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@
modified_beam_search_LODR,
)
from lhotse import set_caching_enabled
from tokenizer import Tokenizer
from train import add_model_arguments, get_model, get_params

from icefall import ContextGraph, LmScorer, NgramLm
Expand Down Expand Up @@ -377,6 +378,17 @@ def get_parser():
default=False,
help="""Skip scoring, but still save the ASR output (for eval sets).""",
)
parser.add_argument(
"--blank-penalty",
type=float,
default=0.0,
help="""
The penalty applied on blank symbol during decoding.
Note: It is a positive value that would be applied to logits like
this `logits[:, 0] -= blank_penalty` (suppose logits.shape is
[batch_size, vocab] and blank id is 0).
""",
)

add_model_arguments(parser)

Expand Down Expand Up @@ -601,6 +613,7 @@ def decode_one_batch(

# prefix = ( "greedy_search" | "fast_beam_search_nbest" | "modified_beam_search" )
prefix = f"{params.decoding_method}"
key = f"blank_penalty_{params.blank_penalty}"
if params.decoding_method == "greedy_search":
return {"greedy_search": hyps}
elif "fast_beam_search" in params.decoding_method:
Expand Down
2 changes: 1 addition & 1 deletion egs/librispeech/ASR/zipformer/zipformer.py
Original file line number Diff line number Diff line change
Expand Up @@ -2434,4 +2434,4 @@ def _test_zipformer_main(causal: bool = False):
torch.set_num_threads(1)
torch.set_num_interop_threads(1)
_test_zipformer_main(False)
_test_zipformer_main(True)
_test_zipformer_main(True)
38 changes: 38 additions & 0 deletions egs/reazonspeech/ASR/RESULTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,41 @@ The decoding command is:
--blank-penalty 0
```

#### Streaming

We have not completed evaluation of our models yet and will add evaluation results here once it's completed.

The training command is:
```shell
./zipformer/train.py \
--world-size 8 \
--num-epochs 40 \
--start-epoch 1 \
--use-fp16 1 \
--exp-dir zipformer/exp-large \
--causal 1 \
--num-encoder-layers 2,2,4,5,4,2 \
--feedforward-dim 512,768,1536,2048,1536,768 \
--encoder-dim 192,256,512,768,512,256 \
--encoder-unmasked-dim 192,192,256,320,256,192 \
--lang data/lang_char \
--max-duration 1600
```

The decoding command is:

```shell
./zipformer/streaming_decode.py \
--epoch 28 \
--avg 15 \
--causal 1 \
--chunk-size 32 \
--left-context-frames 256 \
--exp-dir ./zipformer/exp-large \
--lang data/lang_char \
--num-encoder-layers 2,2,4,5,4,2 \
--feedforward-dim 512,768,1536,2048,1536,768 \
--encoder-dim 192,256,512,768,512,256 \
--encoder-unmasked-dim 192,192,256,320,256,192
```

1 change: 0 additions & 1 deletion egs/reazonspeech/ASR/local/utils/tokenizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ class Tokenizer:
@staticmethod
def add_arguments(parser: argparse.ArgumentParser):
group = parser.add_argument_group(title="Lang related options")

group.add_argument("--lang", type=Path, help="Path to lang directory.")

group.add_argument(
Expand Down
Loading
Loading