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: Generate json output files and transcripts from the ASR and diarization results.
  
  Args:
      uniq_id (str):
          A unique ID (key) that identifies each input audio file.
      diar_labels (list):
          List containing the diarization hypothesis timestamps
  
          Example:
          >>>  diar_hyp['my_audio_01'] = ['0.0 4.375 speaker_1', '4.375 5.125 speaker_0', ...]
  
      word_dict_seq_list (list):
          List containing words and corresponding word timestamps in dictionary format.
  
          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'},  
               ...]
  
  Returns:
      session_result_dict (dict):
          A dictionary containing overall results of diarization and ASR inference.
          `session_result_dict` has following keys: `status`, `session_id`, `transcription`, `speaker_count`,
          `words`, `sentences`.
  
          Example:
          >>> session_trans_dict =                     {
                  'status': 'Success',
                  'session_id': 'my_audio_01',
                  'transcription': 'right and i really think ...',
                  'speaker_count': 2,
                  'words': [{'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'},  
                            ...
                            ]
                  'sentences': [{'sentence': 'right',  'start_time': 0.0, 'end_time': 0.04, 'speaker': 'speaker_0'},
                                {'sentence': 'and i really think ...', 
                                 'start_time': 0.92, 'end_time': 4.12, 'speaker': 'speaker_0'},
                                ...
                                ]
              }
docstr_tok: ["Generate","json","output","files","and","transcripts","from","the","ASR","and","diarization","results",".","Args",":","uniq_id","(","str",")",":","A","unique","ID","(","key",")","that","identifies","each","input","audio","file",".","diar_labels","(","list",")",":","List","containing","the","diarization","hypothesis","timestamps","Example",":",">",">",">","diar_hyp","[","'my_audio_01","'","]","=","[","'","0.0","4.375","speaker_1","'",",","'","4.375","5.125","speaker_0","'",",","...","]","word_dict_seq_list","(","list",")",":","List","containing","words","and","corresponding","word","timestamps","in","dictionary","format",".","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","'","}",",","...","]","Returns",":","session_result_dict","(","dict",")",":","A","dictionary","containing","overall","results","of","diarization","and","ASR","inference",".","`","session_result_dict","`","has","following","keys",":","`","status","`",",","`","session_id","`",",","`","transcription","`",",","`","speaker_count","`",",","`","words","`",",","`","sentences","`",".","Example",":",">",">",">","session_trans_dict","=","{","'status","'",":","'Success","'",",","'session_id","'",":","'my_audio_01","'",",","'transcription","'",":","'right","and","i","really","think","...","'",",","'speaker_count","'",":","2",",","'words","'",":","[","{","'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","'","}",",","...","]","'sentences","'",":","[","{","'sentence","'",":","'right","'",",","'start_time","'",":","0.0",",","'end_time","'",":","0.04",",","'speaker","'",":","'speaker_0","'","}",",","{","'sentence","'",":","'and","i","really","think","...","'",",","'start_time","'",":","0.92",",","'end_time","'",":","4.12",",","'speaker","'",":","'speaker_0","'","}",",","...","]","}"]
code: def _make_json_output(
      self,
      uniq_id: str,
      diar_labels: List[str],
      word_dict_seq_list: List[Dict[str, float]],
  ) -> Dict[str, Dict[str, str]]:
      """
          Generate json output files and transcripts from the ASR and diarization results.
  
          Args:
              uniq_id (str):
                  A unique ID (key) that identifies each input audio file.
              diar_labels (list):
                  List containing the diarization hypothesis timestamps
  
                  Example:
                  >>>  diar_hyp['my_audio_01'] = ['0.0 4.375 speaker_1', '4.375 5.125 speaker_0', ...]
  
              word_dict_seq_list (list):
                  List containing words and corresponding word timestamps in dictionary format.
  
                  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'},  
                       ...]
  
          Returns:
              session_result_dict (dict):
                  A dictionary containing overall results of diarization and ASR inference.
                  `session_result_dict` has following keys: `status`, `session_id`, `transcription`, `speaker_count`,
                  `words`, `sentences`.
  
                  Example:
                  >>> session_trans_dict = \
                      {
                          'status': 'Success',
                          'session_id': 'my_audio_01',
                          'transcription': 'right and i really think ...',
                          'speaker_count': 2,
                          'words': [{'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'},  
                                    ...
                                    ]
                          'sentences': [{'sentence': 'right',  'start_time': 0.0, 'end_time': 0.04, 'speaker': 'speaker_0'},
                                        {'sentence': 'and i really think ...', 
                                         'start_time': 0.92, 'end_time': 4.12, 'speaker': 'speaker_0'},
                                        ...
                                        ]
                      }
          """
      word_seq_list, audacity_label_words = [], []
      start_point, end_point, speaker = diar_labels[0].split()
      prev_speaker = speaker
  
      sentences, terms_list = [], []
      sentence = {
          "speaker": speaker,
          "start_time": start_point,
          "end_time": end_point,
          "text": "",
      }
  
      n_spk = get_num_of_spk_from_labels(diar_labels)
      logging.info(
          f"Creating results for Session: {uniq_id} n_spk: {n_spk} "
      )
      session_trans_dict = self._init_session_trans_dict(
          uniq_id=uniq_id, n_spk=n_spk
      )
      gecko_dict = self._init_session_gecko_dict()
  
      for k, word_dict in enumerate(word_dict_seq_list):
          word, speaker = word_dict["word"], word_dict["speaker"]
          word_seq_list.append(word)
          start_point, end_point = (
              word_dict["start_time"],
              word_dict["end_time"],
          )
          if speaker != prev_speaker:
              if len(terms_list) != 0:
                  gecko_dict["monologues"].append(
                      {
                          "speaker": {"name": None, "id": prev_speaker},
                          "terms": terms_list,
                      }
                  )
                  terms_list = []
  
              # remove trailing space in text
              sentence["text"] = sentence["text"].strip()
  
              # store last sentence
              sentences.append(sentence)
  
              # start construction of a new sentence
              sentence = {
                  "speaker": speaker,
                  "start_time": start_point,
                  "end_time": end_point,
                  "text": "",
              }
          else:
              # correct the ending time
              sentence["end_time"] = end_point
  
          stt_sec, end_sec = start_point, end_point
          terms_list.append(
              {
                  "start": stt_sec,
                  "end": end_sec,
                  "text": word,
                  "type": "WORD",
              }
          )
  
          # add current word to sentence
          sentence["text"] += word.strip() + " "
  
          audacity_label_words.append(
              get_audacity_label(word, stt_sec, end_sec, speaker)
          )
          prev_speaker = speaker
  
      session_trans_dict["words"] = word_dict_seq_list
  
      # note that we need to add the very last sentence.
      sentence["text"] = sentence["text"].strip()
      sentences.append(sentence)
      gecko_dict["monologues"].append(
          {
              "speaker": {"name": None, "id": speaker},
              "terms": terms_list,
          }
      )
  
      # Speaker independent transcription
      session_trans_dict["transcription"] = " ".join(word_seq_list)
      # add sentences to transcription information dict
      session_trans_dict["sentences"] = sentences
      self._write_and_log(
          uniq_id,
          session_trans_dict,
          audacity_label_words,
          gecko_dict,
          sentences,
      )
      return session_trans_dict
  
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 17 for calling the OfflineDiarWithASR obj's underlying member method code with example usage: obj._make_json_output(uniq_id, diar_labels, word_dict_seq_list) and returns: session_trans_dict