class_docstr: Speech2TextStreaming class
  
  Details in "Streaming Transformer ASR with Blockwise Synchronous Beam Search"
  (https://arxiv.org/abs/2006.14941)
  
  Examples:
      >>> import soundfile
      >>> speech2text = Speech2TextStreaming("asr_config.yml", "asr.pth")
      >>> audio, rate = soundfile.read("speech.wav")
      >>> speech2text(audio)
      [(text, token, token_int, hypothesis object), ...]
class_docstr_tok: ["Speech2TextStreaming","class","Details","in","``","Streaming","Transformer","ASR","with","Blockwise","Synchronous","Beam","Search","''","(","https",":","\/\/arxiv.org\/abs\/2006.14941",")","Examples",":",">",">",">","import","soundfile",">",">",">","speech2text","=","Speech2TextStreaming","(","``","asr_config.yml","''",",","``","asr.pth","''",")",">",">",">","audio",",","rate","=","soundfile.read","(","``","speech.wav","''",")",">",">",">","speech2text","(","audio",")","[","(","text",",","token",",","token_int",",","hypothesis","object",")",",","...","]"]
docstr: Inference
  
  Args:
      data: Input speech data
  Returns:
      text, token, token_int, hyp
docstr_tok: ["Inference","Args",":","data",":","Input","speech","data","Returns",":","text",",","token",",","token_int",",","hyp"]
code: def __call__(
      self,
      speech: Union[torch.Tensor, np.ndarray],
      is_final: bool = True,
  ) -> List[Tuple[Optional[str], List[str], List[int], Hypothesis]]:
      """Inference
  
      Args:
          data: Input speech data
      Returns:
          text, token, token_int, hyp
  
      """
      assert check_argument_types()
  
      # Input as audio signal
      if isinstance(speech, np.ndarray):
          speech = torch.tensor(speech)
  
      feats, feats_lengths, self.frontend_states = self.apply_frontend(
          speech, self.frontend_states, is_final=is_final
      )
  
      if feats is not None:
          enc, _, self.encoder_states = self.asr_model.encoder(
              feats,
              feats_lengths,
              self.encoder_states,
              is_final=is_final,
              infer_mode=True,
          )
          nbest_hyps = self.beam_search(
              x=enc[0],
              maxlenratio=self.maxlenratio,
              minlenratio=self.minlenratio,
              is_final=is_final,
          )
          ret = self.assemble_hyps(nbest_hyps)
      else:
          ret = []
  
      if is_final:
          self.reset()
      return ret
  
imports: import argparse
  import logging
  import math
  import sys
  from pathlib import Path
  from typing import List, Optional, Sequence, Tuple, Union
  import numpy
  import torch
  from typeguard import check_argument_types, check_return_type
  from espnet2.asr.encoder.contextual_block_conformer_encoder import ContextualBlockConformerEncoder
  from espnet2.asr.encoder.contextual_block_transformer_encoder import ContextualBlockTransformerEncoder
  from espnet2.fileio.datadir_writer import DatadirWriter
  from espnet2.tasks.asr import ASRTask
  from espnet2.tasks.lm import LMTask
  from espnet2.text.build_tokenizer import build_tokenizer
  from espnet2.text.token_id_converter import TokenIDConverter
  from espnet2.torch_utils.device_funcs import to_device
  from espnet2.torch_utils.set_all_random_seed import set_all_random_seed
  from espnet2.utils import config_argparse
  from espnet2.utils.types import str2bool, str2triple_str, str_or_none
  from espnet.nets.batch_beam_search_online import BatchBeamSearchOnline
  from espnet.nets.beam_search import Hypothesis
  from espnet.nets.pytorch_backend.transformer.subsampling import TooShortUttError
  from espnet.nets.scorer_interface import BatchScorerInterface
  from espnet.nets.scorers.ctc import CTCPrefixScorer
  from espnet.nets.scorers.length_bonus import LengthBonus
  from espnet.utils.cli_utils import get_commandline_args
label_desc: Use image node_id 4 for calling the Speech2TextStreaming obj's underlying member method code with example usage: obj.__call__(speech, is_final) and returns: ret