<br />

|---|
| [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/tensorflow/tflite-support/blob/v0.4.4/tensorflow_lite_support/python/task/audio/audio_classifier.py#L48-L150) |

Class that performs classification on audio.

    tflite_support.task.audio.AudioClassifier(
        options: https://developers.google.com/edge/api/tflite/python/tflite_support/task/audio/AudioClassifierOptions,
        classifier: _CppAudioClassifier
    ) -> None

<br />

<br />

<br />

| ## Attributes ||
|---|---|
| `required_audio_format` | Gets the required audio format for the model. |
| `required_input_buffer_size` | Gets the required input buffer size for the model. |

<br />

## Methods

### `classify`

[View source](https://github.com/tensorflow/tflite-support/blob/v0.4.4/tensorflow_lite_support/python/task/audio/audio_classifier.py#L117-L136)

    classify(
        audio: https://developers.google.com/edge/api/tflite/python/tflite_support/task/audio/TensorAudio
    ) -> https://developers.google.com/edge/api/tflite/python/tflite_support/task/processor/ClassificationResult

Performs classification on the provided TensorAudio.

<br />

<br />

<br />

| Args ||
|---|---|
| `audio` | Tensor audio, used to extract the feature vectors. |

<br />

<br />

<br />

<br />

| Returns ||
|---|---|
| classification result. ||

<br />

<br />

<br />

<br />

| Raises ||
|---|---|
| `ValueError` | If any of the input arguments is invalid. |
| `RuntimeError` | If failed to run audio classification. |

<br />

### `create_audio_record`

[View source](https://github.com/tensorflow/tflite-support/blob/v0.4.4/tensorflow_lite_support/python/task/audio/audio_classifier.py#L107-L115)

    create_audio_record() -> https://developers.google.com/edge/api/tflite/python/tflite_support/task/audio/AudioRecord

Creates an AudioRecord instance to record audio.

<br />

<br />

<br />

| Returns ||
|---|---|
| An AudioRecord instance. ||

<br />

### `create_from_file`

[View source](https://github.com/tensorflow/tflite-support/blob/v0.4.4/tensorflow_lite_support/python/task/audio/audio_classifier.py#L58-L75)

    @classmethod
    create_from_file(
        file_path: str
    ) -> 'AudioClassifier'

Creates the `AudioClassifier` object from a TensorFlow Lite model.

<br />

<br />

<br />

| Args ||
|---|---|
| `file_path` | Path to the model. |

<br />

<br />

<br />

<br />

| Returns ||
|---|---|
| `AudioClassifier` object that's created from `options`. ||

<br />

<br />

<br />

<br />

| Raises ||
|---|---|
| `ValueError` | If failed to create `AudioClassifier` object from the provided file such as invalid file. |
| `RuntimeError` | If other types of error occurred. |

<br />

### `create_from_options`

[View source](https://github.com/tensorflow/tflite-support/blob/v0.4.4/tensorflow_lite_support/python/task/audio/audio_classifier.py#L77-L95)

    @classmethod
    create_from_options(
        options: https://developers.google.com/edge/api/tflite/python/tflite_support/task/audio/AudioClassifierOptions
    ) -> 'AudioClassifier'

Creates the `AudioClassifier` object from audio classifier options.

<br />

<br />

<br />

| Args ||
|---|---|
| `options` | Options for the audio classifier task. |

<br />

<br />

<br />

<br />

| Returns ||
|---|---|
| `AudioClassifier` object that's created from `options`. ||

<br />

<br />

<br />

<br />

| Raises ||
|---|---|
| `ValueError` | If failed to create `AudioClassifier` object from `AudioClassifierOptions` such as missing the model. |
| `RuntimeError` | If other types of error occurred. |

<br />

### `create_input_tensor_audio`

[View source](https://github.com/tensorflow/tflite-support/blob/v0.4.4/tensorflow_lite_support/python/task/audio/audio_classifier.py#L97-L105)

    create_input_tensor_audio() -> https://developers.google.com/edge/api/tflite/python/tflite_support/task/audio/TensorAudio

Creates a TensorAudio instance to store the audio input.

<br />

<br />

<br />

| Returns ||
|---|---|
| A TensorAudio instance. ||

<br />