class_docstr: Speech2Text class
  
  Examples:
      >>> import soundfile
      >>> speech2text = Speech2Text("asr_config.yml", "asr.pth")
      >>> audio, rate = soundfile.read("speech.wav")
      >>> speech2text(audio)
      [(text, token, token_int, hypothesis object), ...]
class_docstr_tok: ["Speech2Text","class","Examples",":",">",">",">","import","soundfile",">",">",">","speech2text","=","Speech2Text","(","``","asr_config.yml","''",",","``","asr.pth","''",")",">",">",">","audio",",","rate","=","soundfile.read","(","``","speech.wav","''",")",">",">",">","speech2text","(","audio",")","[","(","text",",","token",",","token_int",",","hypothesis","object",")",",","...","]"]
code: def __init__(
      self,
      asr_train_config: Union[Path, str],
      asr_model_file: Union[Path, str] = None,
      token_type: str = None,
      bpemodel: str = None,
      device: str = "cpu",
      batch_size: int = 1,
      dtype: str = "float32",
      maskctc_n_iterations: int = 10,
      maskctc_threshold_probability: float = 0.99,
  ):
      assert check_argument_types()
  
      # 1. Build ASR model
      asr_model, asr_train_args = ASRTask.build_model_from_file(
          asr_train_config, asr_model_file, device
      )
      asr_model.to(dtype=getattr(torch, dtype)).eval()
      token_list = asr_model.token_list
  
      s2t = MaskCTCInference(
          asr_model=asr_model,
          n_iterations=maskctc_n_iterations,
          threshold_probability=maskctc_threshold_probability,
      )
      s2t.to(device=device, dtype=getattr(torch, dtype)).eval()
  
      # 2. [Optional] Build Text converter: e.g. bpe-sym -> Text
      if token_type is None:
          token_type = asr_train_args.token_type
      if bpemodel is None:
          bpemodel = asr_train_args.bpemodel
  
      if token_type is None:
          tokenizer = None
      elif token_type == "bpe":
          if bpemodel is not None:
              tokenizer = build_tokenizer(
                  token_type=token_type, bpemodel=bpemodel
              )
          else:
              tokenizer = None
      else:
          tokenizer = build_tokenizer(token_type=token_type)
      converter = TokenIDConverter(token_list=token_list)
      logging.info(f"Text tokenizer: {tokenizer}")
  
      self.asr_model = asr_model
      self.asr_train_args = asr_train_args
      self.s2t = s2t
      self.converter = converter
      self.tokenizer = tokenizer
      self.device = device
      self.dtype = dtype
  
imports: import argparse
  import logging
  import sys
  from pathlib import Path
  from typing import Any, List, Optional, Sequence, Tuple, Union
  import numpy
  import torch
  from typeguard import check_argument_types, check_return_type
  from espnet2.asr.maskctc_model import MaskCTCInference
  from espnet2.fileio.datadir_writer import DatadirWriter
  from espnet2.tasks.asr import ASRTask
  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.beam_search import Hypothesis
  from espnet.nets.pytorch_backend.transformer.subsampling import TooShortUttError
  from espnet.utils.cli_utils import get_commandline_args
label_desc: Use image node_id 1 to create a new Speech2Text object  with example: obj = Speech2Text(asr_train_config, asr_model_file, token_type, bpemodel, device, batch_size, dtype, maskctc_n_iterations, maskctc_threshold_probability)