code: def prepare_media(
      data_folder,
      save_folder,
      channels_path,
      concepts_path,
      skip_wav=True,
      method="slu",
      task="full",
      skip_prep=False,
      process_test2=False,
  ):
      """
      Prepares the csv files for the MEDIA dataset.
      Both following repositories are necessary for transcriptions
      and annotations (S0272) and audio (E0024).
      https://catalogue.elra.info/en-us/repository/browse/ELRA-S0272/
      https://catalogue.elra.info/en-us/repository/browse/ELRA-E0024/
  
      Arguments
      ---------
      data_folder: str
          Path where folders S0272 and E0024 are stored.
      save_folder: str
          Path where the csvs and preprocessed wavs will be stored.
      channels_path: str
          Path of the channels.csv file downloaded via https://www.dropbox.com/sh/y7ab0lktbylz647/AADMsowYHmNYwaoL_hQt7NMha?dl=0
      concepts_path: str
          Path of the concepts_full_relax.csv file downloaded via https://www.dropbox.com/sh/y7ab0lktbylz647/AADMsowYHmNYwaoL_hQt7NMha?dl=0
      skip_wav: bool, optional
          Skip the wav files storing if already done before.
      method: str, optional
          Used only for 'slu' task.
          Either 'full' or 'relax'.
          'full' Keep specifiers in concepts.
          'relax' Remove specifiers from concepts.
      task: str, optional
          Either 'slu' or 'asr'.
          'slu' Parse SLU data.
          'asr' Parse ASR data.
      skip_prep: bool, optional
          If True, skip data preparation.
      process_test2: bool, optional
          It True, process test2 corpus
      """
  
      if skip_prep:
          return
  
      if not os.path.exists(save_folder):
          os.makedirs(save_folder)
      if not os.path.exists(save_folder + "/wav"):
          os.makedirs(save_folder + "/wav")
      if not os.path.exists(save_folder + "/csv"):
          os.makedirs(save_folder + "/csv")
  
      if skip(
          save_folder + "/csv/train.csv",
          save_folder + "/csv/dev.csv",
          save_folder + "/csv/test.csv",
      ):
          logger.info(
              "Csv files already exist, skipping data preparation!"
          )
          return
  
      if task == "slu":
          if method == "relax" or method == "full":
              logger.info("Processing SLU " + method + " Media Dataset")
          else:
              raise ValueError(
                  "Parameter method must be 'full' or 'relax'"
              )
      elif task == "asr":
          logger.info("Processing ASR Media Dataset")
      else:
          raise ValueError("Parameter task must be 'asr' or 'slu'")
  
      xmls = {
          "media_lot1.xml": "train",
          "media_lot2.xml": "train",
          "media_lot3.xml": "train",
          "media_lot4.xml": "train",
          "media_testHC.xml": "test",
          "media_testHC_a_blanc.xml": "dev",
      }
  
      train_data = []
      dev_data = []
      test_data = []
      test2_data = []
  
      wav_paths = glob.glob(
          data_folder + "/S0272/**/*.wav", recursive=True
      )
      channels, filenames = get_channels(channels_path)
  
      # Wavs.
      if not (skip_wav):
          logger.info("Processing wavs")
          for wav_path in tqdm(wav_paths):
              filename = wav_path.split("/")[-1][:-4]
              channel = get_channel(filename, channels, filenames)
              split_audio_channels(
                  wav_path, filename, channel, save_folder
              )
  
      # Train, Dev, Test.
      for xml in xmls:
          logger.info(
              "Processing xml file "
              + str(list(xmls.keys()).index(xml) + 1)
              + "/"
              + str(len(xmls))
          )
          root = get_root(
              data_folder + "/E0024/MEDIA1FR_00/MEDIA1FR/DATA/" + xml,
              0,
          )
          data = parse(
              root,
              channels,
              filenames,
              save_folder,
              method,
              task,
              xmls[xml],
          )
          if xmls[xml] == "train":
              train_data.extend(data)
          elif xmls[xml] == "dev":
              dev_data.extend(data)
          elif xmls[xml] == "test":
              test_data.extend(data)
  
      # Test2.
      if process_test2:
          unused_dialogs = get_unused_dialogs(data_folder)
          concepts_full, concepts_relax = get_concepts_full_relax(
              concepts_path
          )
          logger.info("Processing xml files for test2")
          for filename in unused_dialogs:
              root = get_root(
                  data_folder
                  + "/E0024/MEDIA1FR_00/MEDIA1FR/DATA/semantizer_files/"
                  + filename
                  + "_HC.xml",
                  1,
              )
              test2_data.extend(
                  parse_test2(
                      root,
                      channels,
                      filenames,
                      save_folder,
                      method,
                      task,
                      filename,
                      concepts_full,
                      concepts_relax,
                  )
              )
  
      append_data(save_folder, train_data, "train")
      append_data(save_folder, dev_data, "dev")
      append_data(save_folder, test_data, "test")
      if process_test2:
          append_data(save_folder, test2_data, "test2")
  
imports: import xml.dom.minidom
  from tqdm import tqdm
  import logging
  import subprocess
  import csv
  import os
  import glob
  import re
label_desc: Use image node_id 1 for calling a global function with example usage: prepare_media(data_folder, save_folder, channels_path, concepts_path, skip_wav, method, task, skip_prep, process_test2) without return types