code: def process_sample(aud_path, lable, utt_id, sp, tgt_dict):
      import torchaudio
  
      input = {}
      output = {}
      si, ei = torchaudio.info(aud_path)
      input["length_ms"] = int(
          si.length / si.channels / si.rate / MILLISECONDS_TO_SECONDS
      )
      input["path"] = aud_path
  
      token = " ".join(sp.EncodeAsPieces(lable))
      ids = tgt_dict.encode_line(token, append_eos=False)
      output["text"] = lable
      output["token"] = token
      output["tokenid"] = ", ".join(map(str, [t.tolist() for t in ids]))
      return {utt_id: {"input": input, "output": output}}
  
file_path: fairseq/examples/speech_recognition/datasets/asr_prep_json.py
imports: from __future__ import absolute_import, division, print_function, unicode_literals
  import argparse
  import concurrent.futures
  import json
  import multiprocessing
  import os
  from collections import namedtuple
  from itertools import chain
  import sentencepiece
  from fairseq.data import Dictionary
label_desc: Use image node_id 1 for calling a global function with example usage: process_sample(aud_path, lable, utt_id, sp, tgt_dict) and returns: dict