code: def get_asr_dataset_from_json(data_json_path, tgt_dict):
      """
      Parse data json and create dataset.
      See scripts/asr_prep_json.py which pack json from raw files
  
      Json example:
      {
      "utts": {
          "4771-29403-0025": {
              "input": {
                  "length_ms": 170,
                  "path": "/tmp/file1.flac"
              },
              "output": {
                  "text": "HELLO \n",
                  "token": "HE LLO",
                  "tokenid": "4815, 861"
              }
          },
          "1564-142299-0096": {
              ...
          }
      }
      """
      if not os.path.isfile(data_json_path):
          raise FileNotFoundError(
              "Dataset not found: {}".format(data_json_path)
          )
      with open(data_json_path, "rb") as f:
          data_samples = json.load(f)["utts"]
          assert len(data_samples) != 0
          sorted_samples = sorted(
              data_samples.items(),
              key=lambda sample: int(sample[1]["input"]["length_ms"]),
              reverse=True,
          )
          aud_paths = [s[1]["input"]["path"] for s in sorted_samples]
          ids = [s[0] for s in sorted_samples]
          speakers = []
          for s in sorted_samples:
              m = re.search("(.+?)-(.+?)-(.+?)", s[0])
              speakers.append(m.group(1) + "_" + m.group(2))
          frame_sizes = [
              s[1]["input"]["length_ms"] for s in sorted_samples
          ]
          tgt = [
              [int(i) for i in s[1]["output"]["tokenid"].split(", ")]
              for s in sorted_samples
          ]
          # append eos
          tgt = [[*t, tgt_dict.eos()] for t in tgt]
          return AsrDataset(
              aud_paths, frame_sizes, tgt, tgt_dict, ids, speakers
          )
  
file_path: fairseq/examples/speech_recognition/tasks/speech_recognition.py
imports: import json
  import os
  import re
  import sys
  import torch
  from examples.speech_recognition.data import AsrDataset
  from examples.speech_recognition.data.replabels import replabel_symbol
  from fairseq.data import Dictionary
  from fairseq.tasks import LegacyFairseqTask, register_task
label_desc: Use image node_id 1 for calling a global function with example usage: get_asr_dataset_from_json(data_json_path, tgt_dict) and returns: AsrDataset