class_docstr: `tfds.features.FeatureConnector` for audio.
  
  In `_generate_examples`, Audio accept:
  
  * A `np.ndarray` of shape `(length,)` or `(length, channels)`
  * A path to a `.mp3`, `.wav`,... file.
  * A file-object (e.g. `with path.open('rb') as fobj:`)
  
  By default, Audio features are decoded as the raw integer wave form
  `tf.Tensor(shape=(None,), dtype=tf.int64)`.
  
  When encoding an audio with a different number of channels than expected by
  the feature, TFDS automatically tries to correct the number of channels.
class_docstr_tok: ["`","tfds.features.FeatureConnector","`","for","audio",".","In","`","_generate_examples","`",",","Audio","accept",":","*","A","`","np.ndarray","`","of","shape","`","(","length",",",")","`","or","`","(","length",",","channels",")","`","*","A","path","to","a","`",".mp3","`",",","`",".wav","`",",","...","file",".","*","A","file-object","(","e.g",".","`","with","path.open","(","'rb","'",")","as","fobj",":","`",")","By","default",",","Audio","features","are","decoded","as","the","raw","integer","wave","form","`","tf.Tensor","(","shape=","(","None",",",")",",","dtype=tf.int64",")","`",".","When","encoding","an","audio","with","a","different","number","of","channels","than","expected","by","the","feature",",","TFDS","automatically","tries","to","correct","the","number","of","channels","."]
docstr: Constructs the connector.
  
  Args:
    file_format: `str`, the audio file format. Can be any format ffmpeg
      understands. If `None`, will attempt to infer from the file extension.
    shape: `tuple`, shape of the data.
    dtype: The dtype of the data.
    sample_rate: `int`, additional metadata exposed to the user through
      `info.features['audio'].sample_rate`. This value isn't used neither in
      encoding nor decoding.
    encoding: Internal encoding. See `tfds.features.Encoding` for available
      values.
    doc: Documentation of this feature (e.g. description).
    lazy_decode: `bool`, if set `True` then stores audio as is and decodes it
      to numpy array when loaded. Otherwise saves decoded audio.
docstr_tok: ["Constructs","the","connector",".","Args",":","file_format",":","`","str","`",",","the","audio","file","format",".","Can","be","any","format","ffmpeg","understands",".","If","`","None","`",",","will","attempt","to","infer","from","the","file","extension",".","shape",":","`","tuple","`",",","shape","of","the","data",".","dtype",":","The","dtype","of","the","data",".","sample_rate",":","`","int","`",",","additional","metadata","exposed","to","the","user","through","`","info.features","[","'audio","'","]",".sample_rate","`",".","This","value","is","n't","used","neither","in","encoding","nor","decoding",".","encoding",":","Internal","encoding",".","See","`","tfds.features.Encoding","`","for","available","values",".","doc",":","Documentation","of","this","feature","(","e.g",".","description",")",".","lazy_decode",":","`","bool","`",",","if","set","`","True","`","then","stores","audio","as","is","and","decodes","it","to","numpy","array","when","loaded",".","Otherwise","saves","decoded","audio","."]
code: def __init__(
      self,
      *,
      file_format: Optional[str] = None,
      shape: utils.Shape = (None,),
      dtype: type_utils.TfdsDType = np.int64,
      sample_rate: Optional[int] = None,
      encoding: Union[str, Encoding] = Encoding.NONE,
      doc: feature_lib.DocArg = None,
      lazy_decode: bool = False,
  ):
      """Constructs the connector.
  
      Args:
        file_format: `str`, the audio file format. Can be any format ffmpeg
          understands. If `None`, will attempt to infer from the file extension.
        shape: `tuple`, shape of the data.
        dtype: The dtype of the data.
        sample_rate: `int`, additional metadata exposed to the user through
          `info.features['audio'].sample_rate`. This value isn't used neither in
          encoding nor decoding.
        encoding: Internal encoding. See `tfds.features.Encoding` for available
          values.
        doc: Documentation of this feature (e.g. description).
        lazy_decode: `bool`, if set `True` then stores audio as is and decodes it
          to numpy array when loaded. Otherwise saves decoded audio.
      """  # fmt:skip
      self._file_format = file_format
      self._sample_rate = sample_rate
      self._lazy_decode = lazy_decode
      if len(shape) > 2:
          raise ValueError(
              "Audio shape should be either (length,) or "
              f"(length, num_channels), got {shape}."
          )
  
      if self._lazy_decode:
          serialized_dtype = tf.string
          serialized_shape = ()
          _Decoder = _LazyDecoder
      else:
          serialized_dtype = None
          serialized_shape = None
          _Decoder = _EagerDecoder
  
      super().__init__(
          shape=shape,
          dtype=dtype,
          encoding=encoding,
          doc=doc,
          serialized_dtype=serialized_dtype,
          serialized_shape=serialized_shape,
      )
  
      self._audio_decoder = _Decoder(
          file_format=self._file_format,
          np_dtype=self._dtype,
          shape=self._shape,
      )
  
imports: from __future__ import annotations
  import abc
  import enum
  import functools
  import io
  import os
  from typing import BinaryIO, Optional, Union
  import wave
  from absl import logging
  from etils import epath
  import numpy
  from tensorflow_datasets.core import lazy_imports_lib
  from tensorflow_datasets.core import utils
  from tensorflow_datasets.core.features import feature
  from tensorflow_datasets.core.features import tensor_feature
  from tensorflow_datasets.core.proto import feature_pb2
  from tensorflow_datasets.core.utils import type_utils
  from tensorflow_datasets.core.utils.lazy_imports_utils import tensorflow
label_desc: Use image node_id 1 to create a new Audio object from inherited base classes: tensor_feature with example: obj = Audio()