# tfio.audio.AudioIOTensor

<br />

|---|
| [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/tensorflow/io/blob/v0.24.0/tensorflow_io/python/ops/audio_ops.py#L654-L747) |

AudioIOTensor

    tfio.audio.AudioIOTensor(
        filename, dtype=None
    )

### Used in the notebooks

| Used in the tutorials |
|---|
| - [Audio Data Preparation and Augmentation](https://www.tensorflow.org/io/tutorials/audio) |

<br />

<br />

<br />

| ## Attributes ||
|---|---|
| `dtype` | Returns the `dtype` of elements in the tensor. |
| `rate` | The sample `rate` of the audio stream |
| `shape` | Returns the `TensorShape` that represents the shape of the tensor. |

<br />

## Methods

### `to_tensor`

[View source](https://github.com/tensorflow/io/blob/v0.24.0/tensorflow_io/python/ops/audio_ops.py#L707-L716)

    to_tensor()

Converts this `IOTensor` into a [`tf.Tensor`](https://www.tensorflow.org/api_docs/python/tf/Tensor).

<br />

<br />

<br />

| Args ||
|---|---|
| `name` | A name prefix for the returned tensors (optional). |

<br />

<br />

<br />

<br />

| Returns ||
|---|---|
| A `Tensor` with value obtained from this `IOTensor`. ||

<br />

### `__getitem__`

[View source](https://github.com/tensorflow/io/blob/v0.24.0/tensorflow_io/python/ops/audio_ops.py#L721-L743)

    __getitem__(
        key
    )

Returns the specified piece of this IOTensor.

### `__len__`

[View source](https://github.com/tensorflow/io/blob/v0.24.0/tensorflow_io/python/ops/audio_ops.py#L745-L747)

    __len__()

Returns the total number of items of this IOTensor.