class_docstr: A class designed for performing ASR and diarization together.
  
  Attributes:
      cfg_diarizer (OmegaConf):
          Hydra config for diarizer key
      params (OmegaConf):
          Parameters config in diarizer.asr
      ctc_decoder_params (OmegaConf)
          Hydra config for beam search decoder
      realigning_lm_params (OmegaConf):
          Hydra config for realigning language model
      manifest_filepath (str):
          Path to the input manifest path
      nonspeech_threshold (float):
          Threshold for VAD logits that are used for creating speech segments
      fix_word_ts_with_VAD (bool):
          Choose whether to fix word timestamps by using VAD results
      root_path (str):
          Path to the folder where diarization results are saved
      vad_threshold_for_word_ts (float):
          Threshold used for compensating word timestamps with VAD output
      max_word_ts_length_in_sec (float):
          Maximum limit for the duration of each word timestamp
      word_ts_anchor_offset (float):
          Offset for word timestamps from ASR decoders
      run_ASR:
          Placeholder variable for an ASR launcher function
      realigning_lm:
          Placeholder variable for a loaded ARPA Language model
      ctm_exists (bool):
          Boolean that indicates whether all files have the corresponding reference CTM file
      frame_VAD (dict):
          Dictionary containing frame-level VAD logits
      AUDIO_RTTM_MAP:
          Dictionary containing the input manifest information
      color_palette (dict):
          Dictionary containing the ANSI color escape codes for each speaker label (speaker index)
class_docstr_tok: ["A","class","designed","for","performing","ASR","and","diarization","together",".","Attributes",":","cfg_diarizer","(","OmegaConf",")",":","Hydra","config","for","diarizer","key","params","(","OmegaConf",")",":","Parameters","config","in","diarizer.asr","ctc_decoder_params","(","OmegaConf",")","Hydra","config","for","beam","search","decoder","realigning_lm_params","(","OmegaConf",")",":","Hydra","config","for","realigning","language","model","manifest_filepath","(","str",")",":","Path","to","the","input","manifest","path","nonspeech_threshold","(","float",")",":","Threshold","for","VAD","logits","that","are","used","for","creating","speech","segments","fix_word_ts_with_VAD","(","bool",")",":","Choose","whether","to","fix","word","timestamps","by","using","VAD","results","root_path","(","str",")",":","Path","to","the","folder","where","diarization","results","are","saved","vad_threshold_for_word_ts","(","float",")",":","Threshold","used","for","compensating","word","timestamps","with","VAD","output","max_word_ts_length_in_sec","(","float",")",":","Maximum","limit","for","the","duration","of","each","word","timestamp","word_ts_anchor_offset","(","float",")",":","Offset","for","word","timestamps","from","ASR","decoders","run_ASR",":","Placeholder","variable","for","an","ASR","launcher","function","realigning_lm",":","Placeholder","variable","for","a","loaded","ARPA","Language","model","ctm_exists","(","bool",")",":","Boolean","that","indicates","whether","all","files","have","the","corresponding","reference","CTM","file","frame_VAD","(","dict",")",":","Dictionary","containing","frame-level","VAD","logits","AUDIO_RTTM_MAP",":","Dictionary","containing","the","input","manifest","information","color_palette","(","dict",")",":","Dictionary","containing","the","ANSI","color","escape","codes","for","each","speaker","label","(","speaker","index",")"]
docstr: Assign speaker labels to each word and save the hypothesis words and speaker labels to
  a dictionary variable for future use.
  
  Args:
      uniq_id (str):
          A unique ID (key) that identifies each input audio file.
      diar_labels (list):
          List containing the Diarization output labels in str. Indexed by unique IDs.
  
          Example:
          >>>  diar_labels = ['0.0 4.375 speaker_1', '4.375 5.125 speaker_0', ...]
  
      words (list):
          Dictionary of words from ASR inference. Indexed by unique IDs.
  
          Example:
          >>> words = ['hi', 'how', 'are', ...]
  
      word_ts (list):
          Dictionary containing the start time and the end time of each word.
          Indexed by unique IDs.
  
          Example:
          >>> word_ts = [[0.0, 0.04], [0.64, 0.68], [0.84, 0.88], ...]
      
      word_ts_refined (list):
          Dictionary containing the refined (end point fixed) word timestamps based on hypothesis
          word timestamps. Indexed by unique IDs.
  
          Example:
          >>> word_rfnd_ts = [[0.0, 0.60], [0.64, 0.80], [0.84, 0.92], ...]
  
  Returns:
      word_dict_seq_list (list):
          List containing word by word dictionary containing word, timestamps and speaker labels.
  
          Example:
          >>> [{'word': 'right', 'start_time': 0.0, 'end_time': 0.04, 'speaker': 'speaker_0'},  
               {'word': 'and', 'start_time': 0.64, 'end_time': 0.68, 'speaker': 'speaker_1'},  
               {'word': 'i', 'start_time': 0.84, 'end_time': 0.88, 'speaker': 'speaker_1'},  
               ...]
docstr_tok: ["Assign","speaker","labels","to","each","word","and","save","the","hypothesis","words","and","speaker","labels","to","a","dictionary","variable","for","future","use",".","Args",":","uniq_id","(","str",")",":","A","unique","ID","(","key",")","that","identifies","each","input","audio","file",".","diar_labels","(","list",")",":","List","containing","the","Diarization","output","labels","in","str",".","Indexed","by","unique","IDs",".","Example",":",">",">",">","diar_labels","=","[","'","0.0","4.375","speaker_1","'",",","'","4.375","5.125","speaker_0","'",",","...","]","words","(","list",")",":","Dictionary","of","words","from","ASR","inference",".","Indexed","by","unique","IDs",".","Example",":",">",">",">","words","=","[","'hi","'",",","'how","'",",","'are","'",",","...","]","word_ts","(","list",")",":","Dictionary","containing","the","start","time","and","the","end","time","of","each","word",".","Indexed","by","unique","IDs",".","Example",":",">",">",">","word_ts","=","[","[","0.0",",","0.04","]",",","[","0.64",",","0.68","]",",","[","0.84",",","0.88","]",",","...","]","word_ts_refined","(","list",")",":","Dictionary","containing","the","refined","(","end","point","fixed",")","word","timestamps","based","on","hypothesis","word","timestamps",".","Indexed","by","unique","IDs",".","Example",":",">",">",">","word_rfnd_ts","=","[","[","0.0",",","0.60","]",",","[","0.64",",","0.80","]",",","[","0.84",",","0.92","]",",","...","]","Returns",":","word_dict_seq_list","(","list",")",":","List","containing","word","by","word","dictionary","containing","word",",","timestamps","and","speaker","labels",".","Example",":",">",">",">","[","{","'word","'",":","'right","'",",","'start_time","'",":","0.0",",","'end_time","'",":","0.04",",","'speaker","'",":","'speaker_0","'","}",",","{","'word","'",":","'and","'",",","'start_time","'",":","0.64",",","'end_time","'",":","0.68",",","'speaker","'",":","'speaker_1","'","}",",","{","'word","'",":","'","i","'",",","'start_time","'",":","0.84",",","'end_time","'",":","0.88",",","'speaker","'",":","'speaker_1","'","}",",","...","]"]
code: def get_word_level_json_list(
      self,
      words: List[str],
      diar_labels: List[str],
      word_ts: List[List[float]],
      word_rfnd_ts: List[List[float]] = None,
      decimals: int = 2,
  ) -> Dict[str, Dict[str, str]]:
      """
      Assign speaker labels to each word and save the hypothesis words and speaker labels to
      a dictionary variable for future use.
  
      Args:
          uniq_id (str):
              A unique ID (key) that identifies each input audio file.
          diar_labels (list):
              List containing the Diarization output labels in str. Indexed by unique IDs.
  
              Example:
              >>>  diar_labels = ['0.0 4.375 speaker_1', '4.375 5.125 speaker_0', ...]
  
          words (list):
              Dictionary of words from ASR inference. Indexed by unique IDs.
  
              Example:
              >>> words = ['hi', 'how', 'are', ...]
  
          word_ts (list):
              Dictionary containing the start time and the end time of each word.
              Indexed by unique IDs.
  
              Example:
              >>> word_ts = [[0.0, 0.04], [0.64, 0.68], [0.84, 0.88], ...]
  
          word_ts_refined (list):
              Dictionary containing the refined (end point fixed) word timestamps based on hypothesis
              word timestamps. Indexed by unique IDs.
  
              Example:
              >>> word_rfnd_ts = [[0.0, 0.60], [0.64, 0.80], [0.84, 0.92], ...]
  
      Returns:
          word_dict_seq_list (list):
              List containing word by word dictionary containing word, timestamps and speaker labels.
  
              Example:
              >>> [{'word': 'right', 'start_time': 0.0, 'end_time': 0.04, 'speaker': 'speaker_0'},
                   {'word': 'and', 'start_time': 0.64, 'end_time': 0.68, 'speaker': 'speaker_1'},
                   {'word': 'i', 'start_time': 0.84, 'end_time': 0.88, 'speaker': 'speaker_1'},
                   ...]
      """
      if word_rfnd_ts is None:
          word_rfnd_ts = word_ts
      start_point, end_point, speaker = diar_labels[0].split()
      word_pos, turn_idx = 0, 0
      word_dict_seq_list = []
      for word_idx, (
          word,
          word_ts_stt_end,
          refined_word_ts_stt_end,
      ) in enumerate(zip(words, word_ts, word_rfnd_ts)):
          word_pos = self._get_word_timestamp_anchor(word_ts_stt_end)
          if word_pos > float(end_point):
              turn_idx += 1
              turn_idx = min(turn_idx, len(diar_labels) - 1)
              start_point, end_point, speaker = diar_labels[
                  turn_idx
              ].split()
          stt_sec = round(refined_word_ts_stt_end[0], decimals)
          end_sec = round(refined_word_ts_stt_end[1], decimals)
          word_dict_seq_list.append(
              {
                  "word": word,
                  "start_time": stt_sec,
                  "end_time": end_sec,
                  "speaker": speaker,
              }
          )
      return word_dict_seq_list
  
imports: import copy
  import csv
  import json
  import os
  from collections import OrderedDict
  from datetime import datetime
  from typing import Dict, List, Tuple
  import numpy
  from nemo.collections.asr.metrics.der import concat_perm_word_error_rate
  from nemo.collections.asr.metrics.wer import word_error_rate
  from nemo.collections.asr.models import ClusteringDiarizer
  from nemo.collections.asr.parts.utils.speaker_utils import audio_rttm_map, get_uniqname_from_filepath, labels_to_rttmfile, rttm_to_labels, write_rttm2manifest
  from nemo.utils import logging
label_desc: Use image node_id 16 for calling the OfflineDiarWithASR obj's underlying member method code with example usage: obj.get_word_level_json_list(words, diar_labels, word_ts, word_rfnd_ts, decimals) and returns: word_dict_seq_list