code: def get_segments(
      log_probs: np.ndarray,
      path_wav: Union[PosixPath, str],
      transcript_file: Union[PosixPath, str],
      output_file: str,
      vocabulary: List[str],
      tokenizer: SentencePieceTokenizer,
      bpe_model: bool,
      index_duration: float,
      window_size: int = 8000,
      log_file: str = "log.log",
      debug: bool = False,
  ) -> None:
      """
      Segments the audio into segments and saves segments timings to a file
  
      Args:
          log_probs: Log probabilities for the original audio from an ASR model, shape T * |vocabulary|.
                     values for blank should be at position 0
          path_wav: path to the audio .wav file
          transcript_file: path to
          output_file: path to the file to save timings for segments
          vocabulary: vocabulary used to train the ASR model, note blank is at position len(vocabulary) - 1
          tokenizer: ASR model tokenizer (for BPE models, None for char-based models)
          bpe_model: Indicates whether the model uses BPE
          window_size: the length of each utterance (in terms of frames of the CTC outputs) fits into that window.
          index_duration: corresponding time duration of one CTC output index (in seconds)
      """
      level = "DEBUG" if debug else "INFO"
      file_handler = logging.FileHandler(filename=log_file)
      stdout_handler = logging.StreamHandler(sys.stdout)
      handlers = [file_handler, stdout_handler]
      logging.basicConfig(handlers=handlers, level=level)
  
      try:
          with open(transcript_file, "r") as f:
              text = f.readlines()
              text = [t.strip() for t in text if t.strip()]
  
          # add corresponding original text without pre-processing
          transcript_file_no_preprocessing = transcript_file.replace(
              ".txt", "_with_punct.txt"
          )
          if not os.path.exists(transcript_file_no_preprocessing):
              raise ValueError(
                  f"{transcript_file_no_preprocessing} not found."
              )
  
          with open(transcript_file_no_preprocessing, "r") as f:
              text_no_preprocessing = f.readlines()
              text_no_preprocessing = [
                  t.strip() for t in text_no_preprocessing if t.strip()
              ]
  
          # add corresponding normalized original text
          transcript_file_normalized = transcript_file.replace(
              ".txt", "_with_punct_normalized.txt"
          )
          if not os.path.exists(transcript_file_normalized):
              raise ValueError(
                  f"{transcript_file_normalized} not found."
              )
  
          with open(transcript_file_normalized, "r") as f:
              text_normalized = f.readlines()
              text_normalized = [
                  t.strip() for t in text_normalized if t.strip()
              ]
  
          if len(text_no_preprocessing) != len(text):
              raise ValueError(
                  f"{transcript_file} and {transcript_file_no_preprocessing} do not match"
              )
  
          if len(text_normalized) != len(text):
              raise ValueError(
                  f"{transcript_file} and {transcript_file_normalized} do not match"
              )
  
          config = cs.CtcSegmentationParameters()
          config.char_list = vocabulary
          config.min_window_size = window_size
          config.index_duration = index_duration
  
          if bpe_model:
              (
                  ground_truth_mat,
                  utt_begin_indices,
              ) = _prepare_tokenized_text_for_bpe_model(
                  text, tokenizer, vocabulary, 0
              )
          else:
              config.excluded_characters = ".,-?!:»«;'›‹()"
              config.blank = vocabulary.index(" ")
              ground_truth_mat, utt_begin_indices = cs.prepare_text(
                  config, text
              )
  
          _print(ground_truth_mat, config.char_list)
  
          # set this after text prepare_text()
          config.blank = 0
          logging.debug(f"Syncing {transcript_file}")
          logging.debug(
              f"Audio length {os.path.basename(path_wav)}: {log_probs.shape[0]}. "
              f"Text length {os.path.basename(transcript_file)}: {len(ground_truth_mat)}"
          )
  
          timings, char_probs, char_list = cs.ctc_segmentation(
              config, log_probs, ground_truth_mat
          )
          _print(ground_truth_mat, vocabulary)
          segments = determine_utterance_segments(
              config,
              utt_begin_indices,
              char_probs,
              timings,
              text,
              char_list,
          )
  
          write_output(
              output_file,
              path_wav,
              segments,
              text,
              text_no_preprocessing,
              text_normalized,
          )
  
          # Also writes labels in audacity format
          output_file_audacity = output_file[:-4] + "_audacity.txt"
          write_labels_for_audacity(
              output_file_audacity, segments, text_no_preprocessing
          )
          logging.info(
              f"Label file for Audacity written to {output_file_audacity}."
          )
  
          for i, (word, segment) in enumerate(zip(text, segments)):
              if i < 5:
                  logging.debug(
                      f"{segment[0]:.2f} {segment[1]:.2f} {segment[2]:3.4f} {word}"
                  )
          logging.info(f"segmentation of {transcript_file} complete.")
  
      except Exception as e:
          logging.info(
              f"{e} -- segmentation of {transcript_file} failed"
          )
  
file_path: NeMo/tools/ctc_segmentation/scripts/utils.py
imports: import logging
  import logging.handlers
  import math
  import os
  import sys
  from pathlib import PosixPath
  from typing import List, Tuple, Union
  import ctc_segmentation
  import numpy
  from tqdm import tqdm
  from nemo.collections.common.tokenizers.sentencepiece_tokenizer import SentencePieceTokenizer
label_desc: Use image node_id 1 for calling a global function with example usage: get_segments(log_probs, path_wav, transcript_file, output_file, vocabulary, tokenizer, bpe_model, index_duration, window_size, log_file, debug) without return types