mirror of
https://github.com/k2-fsa/icefall.git
synced 2025-08-12 03:22:19 +00:00
add ctc_decode.py
This commit is contained in:
parent
251ff62880
commit
dace53b125
1065
egs/librispeech/ASR/pruned_transducer_stateless4_ctc/ctc_decode.py
Executable file
1065
egs/librispeech/ASR/pruned_transducer_stateless4_ctc/ctc_decode.py
Executable file
File diff suppressed because it is too large
Load Diff
@ -19,36 +19,36 @@
|
|||||||
"""
|
"""
|
||||||
Usage:
|
Usage:
|
||||||
(1) greedy search
|
(1) greedy search
|
||||||
./pruned_transducer_stateless4/decode.py \
|
./pruned_transducer_stateless4_ctc/decode.py \
|
||||||
--epoch 30 \
|
--epoch 30 \
|
||||||
--avg 15 \
|
--avg 15 \
|
||||||
--exp-dir ./pruned_transducer_stateless4/exp \
|
--exp-dir ./pruned_transducer_stateless4_ctc/exp \
|
||||||
--max-duration 600 \
|
--max-duration 600 \
|
||||||
--decoding-method greedy_search
|
--decoding-method greedy_search
|
||||||
|
|
||||||
(2) beam search (not recommended)
|
(2) beam search (not recommended)
|
||||||
./pruned_transducer_stateless4/decode.py \
|
./pruned_transducer_stateless4_ctc/decode.py \
|
||||||
--epoch 30 \
|
--epoch 30 \
|
||||||
--avg 15 \
|
--avg 15 \
|
||||||
--exp-dir ./pruned_transducer_stateless4/exp \
|
--exp-dir ./pruned_transducer_stateless4_ctc/exp \
|
||||||
--max-duration 600 \
|
--max-duration 600 \
|
||||||
--decoding-method beam_search \
|
--decoding-method beam_search \
|
||||||
--beam-size 4
|
--beam-size 4
|
||||||
|
|
||||||
(3) modified beam search
|
(3) modified beam search
|
||||||
./pruned_transducer_stateless4/decode.py \
|
./pruned_transducer_stateless4_ctc/decode.py \
|
||||||
--epoch 30 \
|
--epoch 30 \
|
||||||
--avg 15 \
|
--avg 15 \
|
||||||
--exp-dir ./pruned_transducer_stateless4/exp \
|
--exp-dir ./pruned_transducer_stateless4_ctc/exp \
|
||||||
--max-duration 600 \
|
--max-duration 600 \
|
||||||
--decoding-method modified_beam_search \
|
--decoding-method modified_beam_search \
|
||||||
--beam-size 4
|
--beam-size 4
|
||||||
|
|
||||||
(4) fast beam search (one best)
|
(4) fast beam search (one best)
|
||||||
./pruned_transducer_stateless4/decode.py \
|
./pruned_transducer_stateless4_ctc/decode.py \
|
||||||
--epoch 30 \
|
--epoch 30 \
|
||||||
--avg 15 \
|
--avg 15 \
|
||||||
--exp-dir ./pruned_transducer_stateless4/exp \
|
--exp-dir ./pruned_transducer_stateless4_ctc/exp \
|
||||||
--max-duration 600 \
|
--max-duration 600 \
|
||||||
--decoding-method fast_beam_search \
|
--decoding-method fast_beam_search \
|
||||||
--beam 20.0 \
|
--beam 20.0 \
|
||||||
@ -56,7 +56,7 @@ Usage:
|
|||||||
--max-states 64
|
--max-states 64
|
||||||
|
|
||||||
(5) fast beam search (nbest)
|
(5) fast beam search (nbest)
|
||||||
./pruned_transducer_stateless4/decode.py \
|
./pruned_transducer_stateless4_ctc/decode.py \
|
||||||
--epoch 30 \
|
--epoch 30 \
|
||||||
--avg 15 \
|
--avg 15 \
|
||||||
--exp-dir ./pruned_transducer_stateless3/exp \
|
--exp-dir ./pruned_transducer_stateless3/exp \
|
||||||
@ -69,10 +69,10 @@ Usage:
|
|||||||
--nbest-scale 0.5
|
--nbest-scale 0.5
|
||||||
|
|
||||||
(6) fast beam search (nbest oracle WER)
|
(6) fast beam search (nbest oracle WER)
|
||||||
./pruned_transducer_stateless4/decode.py \
|
./pruned_transducer_stateless4_ctc/decode.py \
|
||||||
--epoch 30 \
|
--epoch 30 \
|
||||||
--avg 15 \
|
--avg 15 \
|
||||||
--exp-dir ./pruned_transducer_stateless4/exp \
|
--exp-dir ./pruned_transducer_stateless4_ctc/exp \
|
||||||
--max-duration 600 \
|
--max-duration 600 \
|
||||||
--decoding-method fast_beam_search_nbest_oracle \
|
--decoding-method fast_beam_search_nbest_oracle \
|
||||||
--beam 20.0 \
|
--beam 20.0 \
|
||||||
@ -82,10 +82,10 @@ Usage:
|
|||||||
--nbest-scale 0.5
|
--nbest-scale 0.5
|
||||||
|
|
||||||
(7) fast beam search (with LG)
|
(7) fast beam search (with LG)
|
||||||
./pruned_transducer_stateless4/decode.py \
|
./pruned_transducer_stateless4_ctc/decode.py \
|
||||||
--epoch 28 \
|
--epoch 28 \
|
||||||
--avg 15 \
|
--avg 15 \
|
||||||
--exp-dir ./pruned_transducer_stateless4/exp \
|
--exp-dir ./pruned_transducer_stateless4_ctc/exp \
|
||||||
--max-duration 600 \
|
--max-duration 600 \
|
||||||
--decoding-method fast_beam_search_nbest_LG \
|
--decoding-method fast_beam_search_nbest_LG \
|
||||||
--beam 20.0 \
|
--beam 20.0 \
|
||||||
@ -93,14 +93,14 @@ Usage:
|
|||||||
--max-states 64
|
--max-states 64
|
||||||
|
|
||||||
(8) decode in streaming mode (take greedy search as an example)
|
(8) decode in streaming mode (take greedy search as an example)
|
||||||
./pruned_transducer_stateless4/decode.py \
|
./pruned_transducer_stateless4_ctc/decode.py \
|
||||||
--epoch 30 \
|
--epoch 30 \
|
||||||
--avg 15 \
|
--avg 15 \
|
||||||
--simulate-streaming 1 \
|
--simulate-streaming 1 \
|
||||||
--causal-convolution 1 \
|
--causal-convolution 1 \
|
||||||
--decode-chunk-size 16 \
|
--decode-chunk-size 16 \
|
||||||
--left-context 64 \
|
--left-context 64 \
|
||||||
--exp-dir ./pruned_transducer_stateless4/exp \
|
--exp-dir ./pruned_transducer_stateless4_ctc/exp \
|
||||||
--max-duration 600 \
|
--max-duration 600 \
|
||||||
--decoding-method greedy_search
|
--decoding-method greedy_search
|
||||||
--beam 20.0 \
|
--beam 20.0 \
|
||||||
@ -109,16 +109,13 @@ Usage:
|
|||||||
|
|
||||||
To evaluate symbol delay, you should:
|
To evaluate symbol delay, you should:
|
||||||
(1) Generate cuts with word-time alignments:
|
(1) Generate cuts with word-time alignments:
|
||||||
./local/add_alignment_librispeech.py \
|
./add_alignments.sh
|
||||||
--alignments-dir data/alignment \
|
|
||||||
--cuts-in-dir data/fbank \
|
|
||||||
--cuts-out-dir data/fbank_ali
|
|
||||||
(2) Set the argument "--manifest-dir data/fbank_ali" while decoding.
|
(2) Set the argument "--manifest-dir data/fbank_ali" while decoding.
|
||||||
For example:
|
For example:
|
||||||
./pruned_transducer_stateless4/decode.py \
|
./pruned_transducer_stateless4_ctc/decode.py \
|
||||||
--epoch 40 \
|
--epoch 40 \
|
||||||
--avg 20 \
|
--avg 20 \
|
||||||
--exp-dir ./pruned_transducer_stateless4/exp \
|
--exp-dir ./pruned_transducer_stateless4_ctc/exp \
|
||||||
--max-duration 600 \
|
--max-duration 600 \
|
||||||
--decoding-method greedy_search \
|
--decoding-method greedy_search \
|
||||||
--manifest-dir data/fbank_ali
|
--manifest-dir data/fbank_ali
|
||||||
@ -216,7 +213,7 @@ def get_parser():
|
|||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--exp-dir",
|
"--exp-dir",
|
||||||
type=str,
|
type=str,
|
||||||
default="pruned_transducer_stateless4/exp",
|
default="pruned_transducer_stateless4_ctc/exp",
|
||||||
help="The experiment dir",
|
help="The experiment dir",
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -528,7 +525,6 @@ def decode_one_batch(
|
|||||||
res = DecodingResults(hyps=tokens, timestamps=timestamps)
|
res = DecodingResults(hyps=tokens, timestamps=timestamps)
|
||||||
|
|
||||||
hyps, timestamps = parse_hyp_and_timestamp(
|
hyps, timestamps = parse_hyp_and_timestamp(
|
||||||
decoding_method=params.decoding_method,
|
|
||||||
res=res,
|
res=res,
|
||||||
sp=sp,
|
sp=sp,
|
||||||
subsampling_factor=params.subsampling_factor,
|
subsampling_factor=params.subsampling_factor,
|
||||||
|
@ -22,31 +22,31 @@ Usage:
|
|||||||
|
|
||||||
export CUDA_VISIBLE_DEVICES="0,1,2,3"
|
export CUDA_VISIBLE_DEVICES="0,1,2,3"
|
||||||
|
|
||||||
./pruned_transducer_stateless4/train.py \
|
./pruned_transducer_stateless4_ctc/train.py \
|
||||||
--world-size 4 \
|
--world-size 4 \
|
||||||
--num-epochs 30 \
|
--num-epochs 30 \
|
||||||
--start-epoch 1 \
|
--start-epoch 1 \
|
||||||
--exp-dir pruned_transducer_stateless2/exp \
|
--exp-dir pruned_transducer_stateless4_ctc/exp \
|
||||||
--full-libri 1 \
|
--full-libri 1 \
|
||||||
--max-duration 300
|
--max-duration 300
|
||||||
|
|
||||||
# For mix precision training:
|
# For mix precision training:
|
||||||
|
|
||||||
./pruned_transducer_stateless4/train.py \
|
./pruned_transducer_stateless4_ctc/train.py \
|
||||||
--world-size 4 \
|
--world-size 4 \
|
||||||
--num-epochs 30 \
|
--num-epochs 30 \
|
||||||
--start-epoch 1 \
|
--start-epoch 1 \
|
||||||
--use-fp16 1 \
|
--use-fp16 1 \
|
||||||
--exp-dir pruned_transducer_stateless2/exp \
|
--exp-dir pruned_transducer_stateless4_ctc/exp \
|
||||||
--full-libri 1 \
|
--full-libri 1 \
|
||||||
--max-duration 550
|
--max-duration 550
|
||||||
|
|
||||||
# train a streaming model
|
# train a streaming model
|
||||||
./pruned_transducer_stateless4/train.py \
|
./pruned_transducer_stateless4_ctc/train.py \
|
||||||
--world-size 4 \
|
--world-size 4 \
|
||||||
--num-epochs 30 \
|
--num-epochs 30 \
|
||||||
--start-epoch 1 \
|
--start-epoch 1 \
|
||||||
--exp-dir pruned_transducer_stateless4/exp \
|
--exp-dir pruned_transducer_stateless4_ctc/exp \
|
||||||
--full-libri 1 \
|
--full-libri 1 \
|
||||||
--dynamic-chunk-training 1 \
|
--dynamic-chunk-training 1 \
|
||||||
--causal-convolution 1 \
|
--causal-convolution 1 \
|
||||||
@ -196,7 +196,7 @@ def get_parser():
|
|||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--exp-dir",
|
"--exp-dir",
|
||||||
type=str,
|
type=str,
|
||||||
default="pruned_transducer_stateless2/exp",
|
default="pruned_transducer_stateless4_ctc/exp",
|
||||||
help="""The experiment dir.
|
help="""The experiment dir.
|
||||||
It specifies the directory where all training related
|
It specifies the directory where all training related
|
||||||
files, e.g., checkpoints, log, etc, are saved
|
files, e.g., checkpoints, log, etc, are saved
|
||||||
|
Loading…
x
Reference in New Issue
Block a user