mirror of
https://github.com/k2-fsa/icefall.git
synced 2025-09-18 21:44:18 +00:00
minor fix doc
This commit is contained in:
parent
f2974e0df5
commit
e011812bab
@ -21,30 +21,10 @@ from typing import List, Optional, Tuple
|
|||||||
import k2
|
import k2
|
||||||
import torch
|
import torch
|
||||||
from beam_search import Hypothesis, HypothesisList
|
from beam_search import Hypothesis, HypothesisList
|
||||||
from kaldifeat import FbankOptions, OnlineFbank, OnlineFeature
|
|
||||||
|
|
||||||
from icefall.utils import AttributeDict
|
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):
|
class Stream(object):
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
@ -57,6 +37,9 @@ class Stream(object):
|
|||||||
Args:
|
Args:
|
||||||
params:
|
params:
|
||||||
It's the return value of :func:`get_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:
|
device:
|
||||||
The device to run this stream.
|
The device to run this stream.
|
||||||
"""
|
"""
|
||||||
|
@ -466,6 +466,21 @@ def decode_one_chunk(
|
|||||||
params: AttributeDict,
|
params: AttributeDict,
|
||||||
decoding_graph: Optional[k2.Fsa] = None,
|
decoding_graph: Optional[k2.Fsa] = None,
|
||||||
) -> List[int]:
|
) -> 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
|
device = next(model.parameters()).device
|
||||||
|
|
||||||
feature_list = []
|
feature_list = []
|
||||||
@ -529,6 +544,8 @@ def decode_one_chunk(
|
|||||||
beam=params.beam_size,
|
beam=params.beam_size,
|
||||||
)
|
)
|
||||||
elif params.decoding_method == "fast_beam_search":
|
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(
|
fast_beam_search_one_best(
|
||||||
model=model,
|
model=model,
|
||||||
streams=streams,
|
streams=streams,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user