class_docstr: Extended CSV compatibility for DynamicItemDataset.
  
  Uses the SpeechBrain Extended CSV data format, where the CSV must have an
  'ID' and 'duration' fields.
  
  The rest of the fields come in triplets:
  ``<name>, <name>_format, <name>_opts``
  
  These add a <name>_sb_data item in the dict. Additionally, a basic
  DynamicItem (see DynamicItemDataset) is created, which loads the _sb_data
  item.
  
  Bash-like string replacements with $to_replace are supported.
  
  NOTE
  ----
  Mapping from legacy interface:
  
  - csv_file -> csvpath
  - sentence_sorting -> sorting, and "random" is not supported, use e.g.
    ``make_dataloader(..., shuffle = (sorting=="random"))``
  - avoid_if_shorter_than -> min_duration
  - avoid_if_longer_than -> max_duration
  - csv_read -> output_keys, and if you want IDs add "id" as key
  
  Arguments
  ---------
  csvpath : str, path
      Path to extended CSV.
  replacements : dict
      Used for Bash-like $-prefixed substitution,
      e.g. ``{"data_folder": "/home/speechbrain/data"}``, which would
      transform `$data_folder/utt1.wav` into `/home/speechbain/data/utt1.wav`
  sorting : {"original", "ascending", "descending"}
      Keep CSV order, or sort ascending or descending by duration.
  min_duration : float, int
      Minimum duration in seconds. Discards other entries.
  max_duration : float, int
      Maximum duration in seconds. Discards other entries.
  dynamic_items : list
      Configuration for extra dynamic items produced when fetching an
      example. List of DynamicItems or dicts with keys::
          func: <callable> # To be called
          takes: <list> # key or list of keys of args this takes
          provides: key # key or list of keys that this provides
      NOTE: A dynamic item is automatically added for each CSV data-triplet
  output_keys : list, None
      The list of output keys to produce. You can refer to the names of the
      CSV data-triplets. E.G. if the CSV has: wav,wav_format,wav_opts,
      then the Dataset has a dynamic item output available with key ``"wav"``
      NOTE: If None, read all existing.
class_docstr_tok: ["Extended","CSV","compatibility","for","DynamicItemDataset",".","Uses","the","SpeechBrain","Extended","CSV","data","format",",","where","the","CSV","must","have","an","'ID","'","and","'duration","'","fields",".","The","rest","of","the","fields","come","in","triplets",":","``","<","name",">",",","<","name",">","_format",",","<","name",">","_opts","``","These","add","a","<","name",">","_sb_data","item","in","the","dict",".","Additionally",",","a","basic","DynamicItem","(","see","DynamicItemDataset",")","is","created",",","which","loads","the","_sb_data","item",".","Bash-like","string","replacements","with","$","to_replace","are","supported",".","NOTE","--","--","Mapping","from","legacy","interface",":","-","csv_file","-",">","csvpath","-","sentence_sorting","-",">","sorting",",","and","``","random","''","is","not","supported",",","use","e.g",".","``","make_dataloader","(","...",",","shuffle","=","(","sorting==","''","random","''",")",")","``","-","avoid_if_shorter_than","-",">","min_duration","-","avoid_if_longer_than","-",">","max_duration","-","csv_read","-",">","output_keys",",","and","if","you","want","IDs","add","``","id","''","as","key","Arguments","--","--","--","--","-","csvpath",":","str",",","path","Path","to","extended","CSV",".","replacements",":","dict","Used","for","Bash-like","$","-prefixed","substitution",",","e.g",".","``","{","``","data_folder","''",":","``","\/home\/speechbrain\/data","''","}","``",",","which","would","transform","`","$","data_folder\/utt1.wav","`","into","`","\/home\/speechbain\/data\/utt1.wav","`","sorting",":","{","``","original","''",",","``","ascending","''",",","``","descending","''","}","Keep","CSV","order",",","or","sort","ascending","or","descending","by","duration",".","min_duration",":","float",",","int","Minimum","duration","in","seconds",".","Discards","other","entries",".","max_duration",":","float",",","int","Maximum","duration","in","seconds",".","Discards","other","entries",".","dynamic_items",":","list","Configuration","for","extra","dynamic","items","produced","when","fetching","an","example",".","List","of","DynamicItems","or","dicts","with","keys",":",":","func",":","<","callable",">","#","To","be","called","takes",":","<","list",">","#","key","or","list","of","keys","of","args","this","takes","provides",":","key","#","key","or","list","of","keys","that","this","provides","NOTE",":","A","dynamic","item","is","automatically","added","for","each","CSV","data-triplet","output_keys",":","list",",","None","The","list","of","output","keys","to","produce",".","You","can","refer","to","the","names","of","the","CSV","data-triplets",".","E.G",".","if","the","CSV","has",":","wav",",","wav_format",",","wav_opts",",","then","the","Dataset","has","a","dynamic","item","output","available","with","key","``","``","wav","''","``","NOTE",":","If","None",",","read","all","existing","."]
code: def __init__(
      self,
      csvpath,
      replacements={},
      sorting="original",
      min_duration=0,
      max_duration=36000,
      dynamic_items=[],
      output_keys=[],
  ):
      if sorting not in ["original", "ascending", "descending"]:
          clsname = self.__class__.__name__
          raise ValueError(
              f"{clsname} doesn't support {sorting} sorting"
          )
      # Load the CSV, init class
      data, di_to_add, data_names = load_sb_extended_csv(
          csvpath, replacements
      )
      super().__init__(data, dynamic_items, output_keys)
      self.pipeline.add_dynamic_items(di_to_add)
      # Handle filtering, sorting:
      reverse = False
      sort_key = None
      if sorting == "ascending" or "descending":
          sort_key = "duration"
      if sorting == "descending":
          reverse = True
      filtered_sorted_ids = self._filtered_sorted_ids(
          key_min_value={"duration": min_duration},
          key_max_value={"duration": max_duration},
          sort_key=sort_key,
          reverse=reverse,
      )
      self.data_ids = filtered_sorted_ids
      # Handle None output_keys (differently than Base)
      if not output_keys:
          self.set_output_keys(data_names)
  
file_path: speechbrain/speechbrain/dataio/legacy.py
imports: from speechbrain.dataio.dataset import DynamicItemDataset
  import collections
  import csv
  import pickle
  import logging
  import torch
  import torchaudio
  import re
label_desc: Use image node_id 1 to create a new ExtendedCSVDataset object from inherited base classes: DynamicItemDataset with example: obj = ExtendedCSVDataset(csvpath, replacements, sorting, min_duration, max_duration, dynamic_items, output_keys)