code: def ctc_align(
      log_level: Union[int, str],
      asr_train_config: str,
      asr_model_file: str,
      audio: Path,
      text: TextIO,
      output: TextIO,
      print_utt_text: bool = True,
      print_utt_score: bool = True,
      **kwargs,
  ):
      """Provide the scripting interface to align text to audio."""
      assert check_argument_types()
      logging.basicConfig(
          level=log_level,
          format="%(asctime)s (%(module)s:%(lineno)d) %(levelname)s: %(message)s",
      )
  
      # Ignore configuration values that are set to None (from parser).
      kwargs = {k: v for (k, v) in kwargs.items() if v is not None}
  
      # Prepare CTC segmentation module
      model = {
          "asr_train_config": asr_train_config,
          "asr_model_file": asr_model_file,
      }
      aligner = CTCSegmentation(**model, **kwargs)
  
      # load audio file
      assert audio.name != ""
      name = audio.stem
      speech, fs = soundfile.read(str(audio))
      # load text file
      transcripts = text.read()
  
      # perform inference and CTC segmentation
      segments = aligner(
          speech=speech, text=transcripts, fs=fs, name=name
      )
  
      # Write to "segments" file or stdout
      segments.print_utterance_text = print_utt_text
      segments.print_confidence_score = print_utt_score
      segments_str = str(segments)
      output.write(segments_str)
  
imports: import argparse
  import logging
  import sys
  from pathlib import Path
  from typing import List, Optional, TextIO, Union
  import numpy
  import soundfile
  import torch
  from ctc_segmentation import CtcSegmentationParameters, ctc_segmentation, determine_utterance_segments, prepare_text, prepare_token_list
  from typeguard import check_argument_types, check_return_type
  from espnet2.tasks.asr import ASRTask
  from espnet2.torch_utils.device_funcs import to_device
  from espnet2.utils import config_argparse
  from espnet2.utils.types import str2bool, str_or_none
  from espnet.utils.cli_utils import get_commandline_args
label_desc: Use image node_id 1 for calling a global function with example usage: ctc_align(log_level, asr_train_config, asr_model_file, audio, text, output, print_utt_text, print_utt_score) without return types