code: def ELANProcess(afile, spk_info, spk_details, text_format):
      try:
          elan_content = parse(afile).documentElement
      except Exception:
          print("encoding failed  %s" % afile)
          return None
      time_order = TimeOrderProcess(
          elan_content.getElementsByTagName("TIME_ORDER")[0]
      )
      tiers = elan_content.getElementsByTagName("TIER")
      channels = ([], [])
      for tier in tiers:
          if tier.getAttribute("LINGUISTIC_TYPE_REF") not in [
              "UtteranceType",
              "Transcription",
          ]:
              # only consider pure caption
              continue
          try:
              spk_name = " ".join(
                  tier.getAttribute("TIER_ID").strip().split()
              )
              if text_format == "surface":
                  if "SURFACE" not in spk_name:
                      continue
                  code = spk_details[spk_name[:-9]]
              else:
                  if "SURFACE" in spk_name:
                      continue
                  code = spk_details[spk_name]
          except Exception:
              print(
                  "error speaker: %s"
                  % tier.getAttribute("TIER_ID").strip()
              )
              continue
          if code not in spk_info:
              continue
          channel = channels[spk_info.index(code)]
          annotations = tier.getElementsByTagName("ANNOTATION")
          for anno in annotations:
              info = anno.getElementsByTagName("ALIGNABLE_ANNOTATION")[
                  0
              ]
              start = time_order[info.getAttribute("TIME_SLOT_REF1")]
              end = time_order[info.getAttribute("TIME_SLOT_REF2")]
              text = ""
              childs = info.getElementsByTagName("ANNOTATION_VALUE")[
                  0
              ].childNodes
              for child in childs:
                  if child.firstChild is not None:
                      continue
                      text += child.firstChild.data
                  else:
                      text += child.data
              text = TextRefine(text, text_format)
              text = text.translate(trantab)
              if len(text) < 1:
                  continue
              if start == end:
                  continue
              channel.append([start, end, text])
      return channels
  
file_path: espnet/egs2/yoloxochitl_mixtec/asr1/local/data_prep.py
imports: import os
  import re
  import shutil
  import string
  import sys
  from argparse import ArgumentParser
  from xml.dom.minidom import parse
  import soundfile
label_desc: Use image node_id 9 for calling a global function with example usage: ELANProcess(afile, spk_info, spk_details, text_format) and returns: channels, None