code: def main():
      try:
          import tgt
      except ImportError:
          raise ImportError(
              "Please install TextGridTools: pip install tgt"
          )
      args = sys.argv
      silence_phones: List[str] = ("sil", "sp", "spn", "")
      alignment_path = args[1]
      wav_scp_path = args[2]
  
      output_wav_scp_path = f"{wav_scp_path}.out"
  
      wav_scp = open(wav_scp_path, "r")
      output_wav_scp = open(output_wav_scp_path, "w")
      for line in wav_scp.readlines():
          id, path = line.strip().split(maxsplit=1)
          filename = f"{id}.TextGrid"
          tgt_path = f"{alignment_path}/{filename}"
          if not os.path.exists(path):
              print(f"{path} does not exist. Omitting...")
              continue
          try:
              textgrid = tgt.io.read_textgrid(tgt_path)
          except FileNotFoundError:
              print(
                  f"{tgt_path} does not have an alignment! Omitting..."
              )
              continue
          firstPhoneDone = False
          start_sec, end_sec = 0, 0
          for t in textgrid.get_tier_by_name("phones")._objects:
              s, e, p = t.start_time, t.end_time, t.text
              # Trim leading silences
              if not firstPhoneDone:
                  if p in silence_phones:
                      continue
                  else:
                      start_sec = s
              firstPhoneDone = True
              if p not in silence_phones:
                  end_sec = e
          sox_cmd = f"sox {path} -t wav - trim {start_sec} {end_sec-start_sec} | "
          output_line = " ".join([id, sox_cmd]) + "\n"
          output_wav_scp.write(output_line)
      os.rename(output_wav_scp_path, wav_scp_path)
  
file_path: espnet/egs2/talromur2/tts1/local/data_utils.py
imports: import os
  import sys
  import tempfile
  import zipfile
  from dataclasses import dataclass
  from pathlib import Path
  from typing import Dict, List, Optional
  import numpy
label_desc: Use image node_id 2 for calling a global function with example usage: main() without return types