class_docstr: Class for processing and loading text to speech training examples.
  
  Args:
      dataset_meta: Dict of dataset names (string) to dataset metadata.
      sample_rate: Sample rate to load audio as. If the audio is stored at a different sample rate, then it will
          be resampled.
      text_tokenizer: Tokenizer to apply to the text field.
      weighted_sampling_steps_per_epoch: Optional int, If provided, then data will be sampled (with replacement) based on
          the sample weights provided in the dataset metadata. If None, then sample weights will be ignored.
      speaker_path: Optional, path to JSON file with speaker indices, for multi-speaker training. Can be created with
          scripts.dataset_processing.tts.create_speaker_map.py
      featurizers: Optional, list of featurizers to load feature data from. Should be the same config provided
          when running scripts.dataset_processing.tts.compute_features.py before training.
      feature_processors: Optional, list of feature processors to run on training examples.
      align_prior_hop_length: Optional int, hop length of audio features.
          If provided alignment prior will be calculated and included in batch output. Must match hop length
          of audio features used for training.
      min_duration: Optional float, if provided audio files in the training manifest shorter than 'min_duration'
          will be ignored.
      max_duration: Optional float, if provided audio files in the training manifest longer than 'max_duration'
          will be ignored.
      volume_norm: Whether to apply volume normalization to loaded audio.
class_docstr_tok: ["Class","for","processing","and","loading","text","to","speech","training","examples",".","Args",":","dataset_meta",":","Dict","of","dataset","names","(","string",")","to","dataset","metadata",".","sample_rate",":","Sample","rate","to","load","audio","as",".","If","the","audio","is","stored","at","a","different","sample","rate",",","then","it","will","be","resampled",".","text_tokenizer",":","Tokenizer","to","apply","to","the","text","field",".","weighted_sampling_steps_per_epoch",":","Optional","int",",","If","provided",",","then","data","will","be","sampled","(","with","replacement",")","based","on","the","sample","weights","provided","in","the","dataset","metadata",".","If","None",",","then","sample","weights","will","be","ignored",".","speaker_path",":","Optional",",","path","to","JSON","file","with","speaker","indices",",","for","multi-speaker","training",".","Can","be","created","with","scripts.dataset_processing.tts.create_speaker_map.py","featurizers",":","Optional",",","list","of","featurizers","to","load","feature","data","from",".","Should","be","the","same","config","provided","when","running","scripts.dataset_processing.tts.compute_features.py","before","training",".","feature_processors",":","Optional",",","list","of","feature","processors","to","run","on","training","examples",".","align_prior_hop_length",":","Optional","int",",","hop","length","of","audio","features",".","If","provided","alignment","prior","will","be","calculated","and","included","in","batch","output",".","Must","match","hop","length","of","audio","features","used","for","training",".","min_duration",":","Optional","float",",","if","provided","audio","files","in","the","training","manifest","shorter","than","'min_duration'","will","be","ignored",".","max_duration",":","Optional","float",",","if","provided","audio","files","in","the","training","manifest","longer","than","'max_duration'","will","be","ignored",".","volume_norm",":","Whether","to","apply","volume","normalization","to","loaded","audio","."]
code: def __getitem__(self, index):
      data = self.data_samples[index]
  
      audio_array, _, audio_filepath_rel = load_audio(
          manifest_entry=data.manifest_entry,
          audio_dir=data.audio_dir,
          sample_rate=self.sample_rate,
          volume_norm=self.volume_norm,
      )
      audio = torch.tensor(audio_array, dtype=torch.float32)
      audio_len = audio.shape[0]
  
      tokens = self.text_tokenizer(data.text)
      tokens = torch.tensor(tokens, dtype=torch.int32)
      text_len = tokens.shape[0]
  
      example = {
          "dataset_name": data.dataset_name,
          "audio_filepath": audio_filepath_rel,
          "audio": audio,
          "audio_len": audio_len,
          "tokens": tokens,
          "text_len": text_len,
      }
  
      if data.speaker is not None:
          example["speaker"] = data.speaker
          example["speaker_index"] = data.speaker_index
  
      if self.include_align_prior:
          spec_len = 1 + librosa.core.samples_to_frames(
              audio_len, hop_length=self.align_prior_hop_length
          )
          align_prior = beta_binomial_prior_distribution(
              phoneme_count=text_len, mel_count=spec_len
          )
          align_prior = torch.tensor(align_prior, dtype=torch.float32)
          example["align_prior"] = align_prior
  
      for featurizer in self.featurizers:
          feature_dict = featurizer.load(
              manifest_entry=data.manifest_entry,
              audio_dir=data.audio_dir,
              feature_dir=data.feature_dir,
          )
          example.update(feature_dict)
  
      for processor in self.feature_processors:
          processor.process(example)
  
      return example
  
imports: import json
  from dataclasses import dataclass
  from pathlib import Path
  from typing import Any, Dict, List, Optional
  import librosa
  import torch.utils.data
  from nemo.collections.asr.parts.utils.manifest_utils import read_manifest
  from nemo.collections.common.tokenizers.text_to_speech.tts_tokenizers import BaseTokenizer
  from nemo.collections.tts.parts.preprocessing.feature_processors import FeatureProcessor
  from nemo.collections.tts.parts.preprocessing.features import Featurizer
  from nemo.collections.tts.parts.utils.tts_dataset_utils import beta_binomial_prior_distribution, filter_dataset_by_duration, get_weighted_sampler, load_audio, stack_tensors
  from nemo.core.classes import Dataset
  from nemo.utils import logging
  from nemo.utils.decorators import experimental
label_desc: Use image node_id 5 for calling the TextToSpeechDataset obj's underlying member method code with example usage: obj.__getitem__(index) and returns: example