code: def prepare_urban_sound_8k(
      data_folder,
      audio_data_folder,
      save_json_train,
      save_json_valid,
      save_json_test,
      train_fold_nums=[1, 2, 3, 4, 5, 6, 7, 8],
      valid_fold_nums=[9],
      test_fold_nums=[10],
      skip_manifest_creation=False,
  ):
      """
      Prepares the json files for the UrbanSound8k dataset.
      Prompts to download the dataset if it is not found in the `data_folder`.
      Arguments
      ---------
      data_folder : str
          Path to the folder where the UrbanSound8k dataset metadata is stored.
      audio_data_folder: str
          Path to the folder where the UrbanSound8k dataset audio files are stored.
      save_json_train : str
          Path where the train data specification file will be saved.
      save_json_valid : str
          Path where the validation data specification file will be saved.
      save_json_test : str
          Path where the test data specification file will be saved.
      train_folds: list or int (integers [1,10])
          A list of integers defining which pre-defined "folds" to use for training. Must be
          exclusive of valid_folds and test_folds.
      valid_folds: list or int (integers [1,10])
          A list of integers defining which pre-defined "folds" to use for validation. Must be
          exclusive of train_folds and test_folds.
      test_folds: list or int (integers [1,10])
          A list of integers defining which pre-defined "folds" to use for test. Must be
          exclusive of train_folds and valid_folds.
      Example
      -------
      >>> data_folder = '/path/to/UrbanSound8k'
      >>> prepare_urban_sound_8k(data_folder, 'train.json', 'valid.json', 'test.json', [1,2,3,4,5,6,7,8], [9], [10])
      """
  
      # Tease params to correct type if necessary
      if type(train_fold_nums) is int:
          train_fold_nums = [train_fold_nums]
      if type(valid_fold_nums) is int:
          valid_fold_nums = [valid_fold_nums]
      if type(test_fold_nums) is int:
          test_fold_nums = [test_fold_nums]
  
      # Validate passed fold params
      for fold_num in train_fold_nums:
          if fold_num not in ACCEPTABLE_FOLD_NUMS:
              print(
                  f"Train fold numbers {train_fold_nums}, contains an invalid value. Must be in {ACCEPTABLE_FOLD_NUMS}"
              )
              logger.info(
                  f"Train fold numbers {train_fold_nums}, contains an invalid value. Must be in {ACCEPTABLE_FOLD_NUMS}"
              )
              return
      for fold_num in valid_fold_nums:
          if fold_num not in ACCEPTABLE_FOLD_NUMS:
              print(
                  f"Validation fold numbers {valid_fold_nums}, contains an invalid value. Must be in {ACCEPTABLE_FOLD_NUMS}"
              )
              logger.info(
                  f"Validation fold numbers {valid_fold_nums}, contains an invalid value. Must be in {ACCEPTABLE_FOLD_NUMS}"
              )
              return
      for fold_num in test_fold_nums:
          if fold_num not in ACCEPTABLE_FOLD_NUMS:
              print(
                  f"Test fold numbers {test_fold_nums}, contains an invalid value. Must be in {ACCEPTABLE_FOLD_NUMS}"
              )
              logger.info(
                  f"Test fold numbers {test_fold_nums}, contains an invalid value. Must be in {ACCEPTABLE_FOLD_NUMS}"
              )
              return
  
      # Check if train, and valid and train and test folds are exclusive
      if folds_overlap(train_fold_nums, valid_fold_nums):
          print(
              f"Train {train_fold_nums}, and Valid {valid_fold_nums} folds must be mutually exclusive!"
          )
          logger.info(
              f"Train {train_fold_nums}, and Valid {valid_fold_nums} folds must be mutually exclusive!"
          )
          return
      if folds_overlap(train_fold_nums, test_fold_nums):
          print(
              f"Train {train_fold_nums} and Test {test_fold_nums} folds must be mutually exclusive!"
          )
          logger.info(
              f"Train {train_fold_nums} and Test {test_fold_nums} folds must be mutually exclusive!"
          )
          return
  
      # If the dataset doesn't exist yet, prompt the user to set or download it
      if not check_folders(audio_data_folder):
          prompt_download_urban_sound_8k(audio_data_folder)
          return
  
      # Don't need to do this every single time
      if skip_manifest_creation is True:
          return
  
      # If our modified metadata file does not exist, create it
      urban_sound_8k_speechbrain_metadata_csv_path = os.path.join(
          os.path.abspath(data_folder),
          "metadata/",
          MODIFIED_METADATA_FILE_NAME,
      )
      if not os.path.exists(
          urban_sound_8k_speechbrain_metadata_csv_path
      ):
          urban_sound_8k_speechbrain_metadata_csv_path = (
              create_metadata_speechbrain_file(data_folder)
          )
          # TODO: If it does not exist, we create it, but next step will certainly fail?
  
      # Read the metadata into a dictionary
      # Every key of this dictionary is now one of the sound filenames, without the ".wav" suffix
      metadata = load_data_csv(
          urban_sound_8k_speechbrain_metadata_csv_path
      )
  
      # List files and create manifest from list
      logger.info(
          f"Creating {save_json_train}, {save_json_valid}, and {save_json_test}"
      )
  
      # Creating json files
      create_json(
          metadata, audio_data_folder, train_fold_nums, save_json_train
      )
      create_json(
          metadata, audio_data_folder, valid_fold_nums, save_json_valid
      )
      create_json(
          metadata, audio_data_folder, test_fold_nums, save_json_test
      )
  
file_path: speechbrain/recipes/UrbanSound8k/urbansound8k_prepare.py
imports: import os
  import json
  import logging
  import ntpath
  import torchaudio
  from speechbrain.dataio.dataio import read_audio
  from speechbrain.dataio.dataio import load_data_csv
label_desc: Use image node_id 1 for calling a global function with example usage: prepare_urban_sound_8k(data_folder, audio_data_folder, save_json_train, save_json_valid, save_json_test, train_fold_nums, valid_fold_nums, test_fold_nums, skip_manifest_creation) without return types