code: def get_phoneme_lists(phn_file, phn_set):
      """
      Reads the phn file and gets the phoneme list & ground truth ends list.
      """
  
      phonemes = []
      ends = []
  
      for line in open(phn_file):
          end, phoneme = (
              line.rstrip("\n").replace("h#", "sil").split(" ")[1:]
          )
  
          # Getting dictionaries for phoneme conversion
          from_60_to_48_phn, from_60_to_39_phn = _get_phonemes()
  
          # Removing end corresponding to q if phn set is not 61
          if phn_set != 60:
              if phoneme == "q":
                  end = ""
  
          # Converting phns if necessary
          if phn_set == 48:
              phoneme = from_60_to_48_phn[phoneme]
          if phn_set == 39:
              phoneme = from_60_to_39_phn[phoneme]
  
          # Appending arrays
          if len(phoneme) > 0:
              phonemes.append(phoneme)
          if len(end) > 0:
              ends.append(end)
  
      if phn_set != 60:
          # Filtering out consecutive silences by applying a mask with `True` marking
          # which sils to remove
          # e.g.
          # phonemes          [  "a", "sil", "sil",  "sil",   "b"]
          # ends              [   1 ,    2 ,    3 ,     4 ,    5 ]
          # ---
          # create:
          # remove_sil_mask   [False,  True,  True,  False,  False]
          # ---
          # so end result is:
          # phonemes ["a", "sil", "b"]
          # ends     [  1,     4,   5]
  
          remove_sil_mask = [
              True if x == "sil" else False for x in phonemes
          ]
  
          for i, val in enumerate(remove_sil_mask):
              if val is True:
                  if i == len(remove_sil_mask) - 1:
                      remove_sil_mask[i] = False
                  elif remove_sil_mask[i + 1] is False:
                      remove_sil_mask[i] = False
  
          phonemes = [
              phon
              for i, phon in enumerate(phonemes)
              if not remove_sil_mask[i]
          ]
          ends = [
              end
              for i, end in enumerate(ends)
              if not remove_sil_mask[i]
          ]
  
      # Convert to e.g. "a sil b", "1 4 5"
      phonemes = " ".join(phonemes)
      ends = " ".join(ends)
  
      return phonemes, ends
  
file_path: speechbrain/recipes/TIMIT/ASR/transducer/timit_prepare.py
imports: import os
  import json
  import logging
  from speechbrain.utils.data_utils import get_all_files
  from speechbrain.dataio.dataio import read_audio
label_desc: Use image node_id 6 for calling a global function with example usage: get_phoneme_lists(phn_file, phn_set) and returns: phonemes,  ends