class_docstr: Audio segment abstraction.
  :param samples: Audio samples [num_samples x num_channels].
  :type samples: ndarray.float32
  :param sample_rate: Audio sample rate.
  :type sample_rate: int
  :raises TypeError: If the sample data type is not float or int.
docstr: Create audio segment from samples.
  Samples are convert float32 internally, with int scaled to [-1, 1].
docstr_tok: ["Create","audio","segment","from","samples",".","Samples","are","convert","float32","internally",",","with","int","scaled","to","[","-1",",","1","]","."]
code: def __init__(
      self,
      samples,
      sample_rate,
      target_sr=None,
      trim=False,
      trim_ref=np.max,
      trim_top_db=60,
      trim_frame_length=2048,
      trim_hop_length=512,
      orig_sr=None,
      channel_selector=None,
      normalize_db: Optional[float] = None,
      ref_channel: Optional[int] = None,
  ):
      """Create audio segment from samples.
      Samples are convert float32 internally, with int scaled to [-1, 1].
      """
      samples = self._convert_samples_to_float32(samples)
  
      # Check if channel selector is necessary
      if samples.ndim == 1 and channel_selector not in [
          None,
          0,
          "average",
      ]:
          raise ValueError(
              "Input signal is one-dimensional, channel selector (%s) cannot not be used.",
              str(channel_selector),
          )
      elif samples.ndim == 2:
          samples = select_channels(samples, channel_selector)
      elif samples.ndim >= 3:
          raise NotImplementedError(
              "Signals with more than two dimensions (sample, channel) are currently not supported."
          )
  
      if target_sr is not None and target_sr != sample_rate:
          # resample along the temporal dimension (axis=0) will be in librosa 0.10.0 (#1561)
          samples = samples.transpose()
          samples = librosa.core.resample(
              samples, orig_sr=sample_rate, target_sr=target_sr
          )
          samples = samples.transpose()
          sample_rate = target_sr
      if trim:
          # librosa is using channels-first layout (num_channels, num_samples), which is transpose of AudioSegment's layout
          samples = samples.transpose()
          samples, _ = librosa.effects.trim(
              samples,
              top_db=trim_top_db,
              ref=trim_ref,
              frame_length=trim_frame_length,
              hop_length=trim_hop_length,
          )
          samples = samples.transpose()
      self._samples = samples
      self._sample_rate = sample_rate
      self._orig_sr = orig_sr if orig_sr is not None else sample_rate
      self._ref_channel = ref_channel
      self._normalize_db = normalize_db
  
      if normalize_db is not None:
          self.normalize_db(normalize_db, ref_channel)
  
imports: import math
  import os
  import random
  from typing import Optional
  import librosa
  import numpy
  import soundfile
  from nemo.collections.asr.parts.utils.audio_utils import select_channels
  from nemo.utils import logging
label_desc: Use image node_id 1 to create a new AudioSegment object from inherited base classes: object with example: obj = AudioSegment(samples, sample_rate, target_sr, trim, trim_ref, trim_top_db, trim_frame_length, trim_hop_length, orig_sr, channel_selector, normalize_db, ref_channel)