From e011812bab975977bada58bfcc3888520c7efd44 Mon Sep 17 00:00:00 2001 From: yaozengwei Date: Sat, 11 Jun 2022 22:31:55 +0800 Subject: [PATCH] minor fix doc --- .../stream.py | 23 +++---------------- .../streaming_decode.py | 17 ++++++++++++++ 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/egs/librispeech/ASR/conv_emformer_transducer_stateless/stream.py b/egs/librispeech/ASR/conv_emformer_transducer_stateless/stream.py index 100353766..814bbb49f 100644 --- a/egs/librispeech/ASR/conv_emformer_transducer_stateless/stream.py +++ b/egs/librispeech/ASR/conv_emformer_transducer_stateless/stream.py @@ -21,30 +21,10 @@ from typing import List, Optional, Tuple import k2 import torch from beam_search import Hypothesis, HypothesisList -from kaldifeat import FbankOptions, OnlineFbank, OnlineFeature from icefall.utils import AttributeDict -def _create_streaming_feature_extractor() -> OnlineFeature: - """Create a CPU streaming feature extractor. - - At present, we assume it returns a fbank feature extractor with - fixed options. In the future, we will support passing in the options - from outside. - - Returns: - Return a CPU streaming feature extractor. - """ - opts = FbankOptions() - opts.device = "cpu" - opts.frame_opts.dither = 0 - opts.frame_opts.snip_edges = False - opts.frame_opts.samp_freq = 16000 - opts.mel_opts.num_bins = 80 - return OnlineFbank(opts) - - class Stream(object): def __init__( self, @@ -57,6 +37,9 @@ class Stream(object): Args: params: It's the return value of :func:`get_params`. + decoding_graph: + The decoding graph. Can be either a `k2.trivial_graph` or HLG, Used + only when --decoding_method is fast_beam_search. device: The device to run this stream. """ diff --git a/egs/librispeech/ASR/conv_emformer_transducer_stateless/streaming_decode.py b/egs/librispeech/ASR/conv_emformer_transducer_stateless/streaming_decode.py index d00e0e8d7..52cb4abf5 100755 --- a/egs/librispeech/ASR/conv_emformer_transducer_stateless/streaming_decode.py +++ b/egs/librispeech/ASR/conv_emformer_transducer_stateless/streaming_decode.py @@ -466,6 +466,21 @@ def decode_one_chunk( params: AttributeDict, decoding_graph: Optional[k2.Fsa] = None, ) -> List[int]: + """ + Args: + model: + The Transducer model. + streams: + A list of Stream objects. + params: + It is returned by :func:`get_params`. + decoding_graph: + The decoding graph. Can be either a `k2.trivial_graph` or HLG, Used + only when --decoding_method is fast_beam_search. + + Returns: + A list of indexes indicating the finished streams. + """ device = next(model.parameters()).device feature_list = [] @@ -529,6 +544,8 @@ def decode_one_chunk( beam=params.beam_size, ) elif params.decoding_method == "fast_beam_search": + # feature_len is needed to get partial results. + # The rnnt_decoding_stream for fast_beam_search. fast_beam_search_one_best( model=model, streams=streams,