class_docstr: Emulating kaldi extract-segments.cc
  
      Args:
          segments (str): The file format is
              "<segment-id> <recording-id> <start-time> <end-time>
  "
              "e.g. call-861225-A-0050-0065 call-861225-A 5.0 6.5
  "
      
class_docstr_tok: ["Emulating","kaldi","extract-segments.cc","Args",":","segments","(","str",")",":","The","file","format","is","``","<","segment-id",">","<","recording-id",">","<","start-time",">","<","end-time",">","''","``","e.g",".","call-861225-A-0050-0065","call-861225-A","5.0","6.5","''"]
code: def __init__(
      self,
      fname: str,
      segments: str = None,
      multi_columns: bool = False,
  ):
      assert check_argument_types()
      self.wav_scp = fname
      self.multi_columns = multi_columns
      self.wav_dict = {}
      with open(self.wav_scp, "r") as f:
          for line in f:
              recodeid, wavpath = line.strip().split(None, 1)
              if recodeid in self.wav_dict:
                  raise RuntimeError(f"{recodeid} is duplicated")
              self.wav_dict[recodeid] = wavpath
  
      self.segments = segments
      self.segments_dict = {}
      with open(self.segments, "r") as f:
          for line in f:
              sps = line.rstrip().split(None)
              if len(sps) != 4:
                  raise RuntimeError(
                      "Format is invalid: {}".format(line)
                  )
              uttid, recodeid, st, et = sps
              self.segments_dict[uttid] = (
                  recodeid,
                  float(st),
                  float(et),
              )
  
              if recodeid not in self.wav_dict:
                  raise RuntimeError(
                      'Not found "{}" in {}'.format(
                          recodeid, self.wav_scp
                      )
                  )
  
imports: import argparse
  import logging
  from io import BytesIO
  from pathlib import Path
  from typing import Optional, Tuple
  import humanfriendly
  import kaldiio
  import numpy
  import resampy
  import soundfile
  from tqdm import tqdm
  from typeguard import check_argument_types
  from espnet2.fileio.read_text import read_2columns_text
  from espnet2.fileio.sound_scp import SoundScpWriter, soundfile_read
  from espnet2.fileio.vad_scp import VADScpReader
  from espnet2.utils.types import str2bool
  from espnet.utils.cli_utils import get_commandline_args
label_desc: Use image node_id 1 to create a new SegmentsExtractor object  with example: obj = SegmentsExtractor(fname, segments, multi_columns)