code: def get_songs_by_category(
      client: freesound.FreesoundClient,
      category: str,
      data_dir: str,
      max_num_samples=100,
      page_size=100,
      min_filesize_in_mb=0,
      max_filesize_in_mb=10,
      n_jobs=None,
  ):
      """
      Download songs of a category with restrictions
  
      Args:
          client: FreesoundAPI client
          category: category to be downloaded
          data_dir: directory of downloaded songs
          max_num_samples: maximum number of samples of this category
          page_size: samples per page returned
          min_filesize_in_mb: minimum filesize of the song in MB
          max_filesize_in_mb: maximum filesize of the song in MB
          n_jobs: number of jobs for parallel processing
  
      Returns:
  
      """
      # quote string to force exact match
      query = f'"{category}"'
      print(f"Query : {query}")
  
      page_size = min(page_size, 150)
      max_filesize = int(max_filesize_in_mb * (2**20))
  
      if min_filesize_in_mb == 0:
          min_filesize_in_mb = 1
      else:
          min_filesize_in_mb = int(min_filesize_in_mb * (2**20))
  
      if max_num_samples < 0:
          max_num_samples = int(1e6)
  
      filters = [
          "type:(wav OR flac)",
          'license:("Attribution" OR "Creative Commons 0")',
          f"filesize:[{min_filesize_in_mb} TO {max_filesize}]",
      ]
  
      fields = "id,name,download,license"
  
      client, pages = get_text_query_with_resource_limit_checks(
          client,
          query=query,
          filters=filters,
          fields=fields,
          page_size=page_size,
      )
  
      if pages is None:
          print(
              f"Number of attempts exceeded limit, skipping query {query}"
          )
          return
  
      num_pages = pages.count
  
      # Check if returned empty result; if so, fallback to inexact category search
      if num_pages == 0:
          print(f"Found 0 samples of results for query '{query}'")
          print(f"Trying less restricted query : {category}")
  
          client, pages = get_text_query_with_resource_limit_checks(
              client,
              query=category,
              filters=filters,
              fields=fields,
              page_size=page_size,
          )
  
          if pages is None:
              print(
                  f"Number of attempts exceeded limit, skipping query {query}"
              )
              return
  
          num_pages = pages.count
  
      print(f"Found {num_pages} samples of results for query '{query}'")
  
      category = category.replace(" ", "_")
      basepath = os.path.join(data_dir, category)
  
      if not os.path.exists(basepath):
          os.makedirs(basepath)
  
      sounds = []
      sample_count = 0
  
      # Retrieve sound license information
      with open(os.path.join(basepath, "licenses.txt"), "w") as f:
          f.write("ID,LICENSE\n")
          f.flush()
  
          while True:
              for sound in pages:
                  if sample_count >= max_num_samples:
                      print(
                          f"Collected {sample_count} samples, which is >= max number of samples requested "
                          f"{max_num_samples}. Stopping for this category : {category}"
                      )
                      break
  
                  sounds.append(sound)
                  sample_count += 1
  
                  f.write(f"{sound.id},{sound.license}\n")
                  f.flush()
  
              if sample_count >= max_num_samples:
                  break
  
              try:
                  pages = pages.next_page()
              except ValueError:
                  break
  
      if n_jobs is None:
          n_jobs = max(1, len(sounds))
  
      # Parallel download all songs
      with Parallel(n_jobs=n_jobs, verbose=10) as parallel:
          _ = parallel(
              delayed(download_song)(
                  basepath, sound.id, sound.name, sound.download
              )
              for sound in sounds
          )
  
file_path: NeMo/scripts/freesound_download_resample/freesound_download.py
imports: import argparse
  import os
  import pickle
  import time
label_desc: Use image node_id 11 for calling a global function with example usage: get_songs_by_category(client, category, data_dir, max_num_samples, page_size, min_filesize_in_mb, max_filesize_in_mb, n_jobs) without return types