code: def get_mfa_alignment_by_sample_id(
      textgrid_zip_path: str,
      sample_id: str,
      sample_rate: int,
      hop_length: int,
      silence_phones: List[str] = ("sil", "sp", "spn"),
  ) -> ForceAlignmentInfo:
      try:
          import tgt
      except ImportError:
          raise ImportError(
              "Please install TextGridTools: pip install tgt"
          )
  
      filename = f"{sample_id}.TextGrid"
      out_root = Path(tempfile.gettempdir())
      tgt_path = out_root / filename
      with zipfile.ZipFile(textgrid_zip_path) as f_zip:
          f_zip.extract(filename, path=out_root)
      textgrid = tgt.io.read_textgrid(tgt_path.as_posix())
      os.remove(tgt_path)
  
      phones, frame_durations = [], []
      start_sec, end_sec, end_idx = 0, 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 len(phones) == 0:
              if p in silence_phones:
                  continue
              else:
                  start_sec = s
          phones.append(p)
          if p not in silence_phones:
              end_sec = e
              end_idx = len(phones)
          r = sample_rate / hop_length
          frame_durations.append(int(np.round(e * r) - np.round(s * r)))
      # Trim tailing silences
      phones = phones[:end_idx]
      frame_durations = frame_durations[:end_idx]
  
      return ForceAlignmentInfo(
          tokens=phones,
          frame_durations=frame_durations,
          start_sec=start_sec,
          end_sec=end_sec,
      )
  
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 1 for calling a global function with example usage: get_mfa_alignment_by_sample_id(textgrid_zip_path, sample_id, sample_rate, hop_length, silence_phones) and returns: ForceAlignmentInfo