code: def determine_utterance_segments(
      config, utt_begin_indices, char_probs, timings, text, char_list
  ):
      """Utterance-wise alignments from char-wise alignments.
      Adapted from https://github.com/lumaku/ctc-segmentation
  
      Args:
          config: an instance of CtcSegmentationParameters
          utt_begin_indices: list of time indices of utterance start
          char_probs:  character positioned probabilities obtained from backtracking
          timings: mapping of time indices to seconds
          text: list of utterances
      Return:
          segments, a list of: utterance start and end [s], and its confidence score
      """
      segments = []
      min_prob = np.float64(-10000000000.0)
      for i in tqdm(range(len(text))):
          start = _compute_time(utt_begin_indices[i], "begin", timings)
          end = _compute_time(utt_begin_indices[i + 1], "end", timings)
  
          start_t = start / config.index_duration_in_seconds
          start_t_floor = math.floor(start_t)
  
          # look for the left most blank symbol and split in the middle to fix start utterance segmentation
          if char_list[start_t_floor] == config.char_list[config.blank]:
              start_blank = None
              j = start_t_floor - 1
              while (
                  char_list[j] == config.char_list[config.blank]
                  and j > start_t_floor - 20
              ):
                  start_blank = j
                  j -= 1
              if start_blank:
                  start_t = int(
                      round(
                          start_blank
                          + (start_t_floor - start_blank) / 2
                      )
                  )
              else:
                  start_t = start_t_floor
              start = start_t * config.index_duration_in_seconds
  
          else:
              start_t = int(round(start_t))
  
          end_t = int(round(end / config.index_duration_in_seconds))
  
          # Compute confidence score by using the min mean probability after splitting into segments of L frames
          n = config.score_min_mean_over_L
          if end_t <= start_t:
              min_avg = min_prob
          elif end_t - start_t <= n:
              min_avg = char_probs[start_t:end_t].mean()
          else:
              min_avg = np.float64(0.0)
              for t in range(start_t, end_t - n):
                  min_avg = min(min_avg, char_probs[t : t + n].mean())
          segments.append((start, end, min_avg))
      return segments
  
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 6 for calling a global function with example usage: determine_utterance_segments(config, utt_begin_indices, char_probs, timings, text, char_list) and returns: segments