<br />

|---|
| [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/google-ai-edge/mediapipe/blob/master/mediapipe/tasks/python/audio/audio_transcriber.py#L199-L340) |

Performs streaming and unary speech-to-text transcription.

```python
mp.tasks.audio.AudioTranscriber(
    handle: ctypes.c_void_p
)
```

<br />

<br />

<br />

| ## Args ||
|---|---|
| `handle` | Opaque C pointer created by `MpAudioTranscriberCreate`. |

<br />

## Methods

### `close`

[View source](https://github.com/google-ai-edge/mediapipe/blob/master/mediapipe/tasks/python/audio/audio_transcriber.py#L326-L334)

```python
close() -> None
```

Closes the transcriber and releases native C++ resources.

### `create_from_model_path`

[View source](https://github.com/google-ai-edge/mediapipe/blob/master/mediapipe/tasks/python/audio/audio_transcriber.py#L238-L252)

```python
@classmethod
create_from_model_path(
    model_path: str,
    delegate: `mp.tasks.BaseOptions.Delegate` = _BaseOptions.Delegate.CPU,
    sample_rate_hz: int = 16000
) -> `mp.tasks.audio.AudioTranscriber`
```

Creates an AudioTranscriber from a `.litertlm` model path.

### `create_from_options`

[View source](https://github.com/google-ai-edge/mediapipe/blob/master/mediapipe/tasks/python/audio/audio_transcriber.py#L211-L236)

```python
@classmethod
create_from_options(
    options: `mp.tasks.audio.AudioTranscriberOptions`
) -> `mp.tasks.audio.AudioTranscriber`
```

Creates an AudioTranscriber instance from `AudioTranscriberOptions`.

### `finish_stream`

[View source](https://github.com/google-ai-edge/mediapipe/blob/master/mediapipe/tasks/python/audio/audio_transcriber.py#L291-L299)

```python
finish_stream() -> `mp.tasks.audio.AudioTranscriberResult`
```

Flushes any buffered audio and finalizes the current stream.

### `prewarm`

[View source](https://github.com/google-ai-edge/mediapipe/blob/master/mediapipe/tasks/python/audio/audio_transcriber.py#L254-L260)

```python
prewarm() -> None
```

Runs a dummy warm-up pass to initialize execution kernels.

### `transcribe`

[View source](https://github.com/google-ai-edge/mediapipe/blob/master/mediapipe/tasks/python/audio/audio_transcriber.py#L262-L289)

```python
transcribe(
    audio_samples: Union[Sequence[float], np.ndarray],
    end_of_stream: bool = True
) -> `mp.tasks.audio.AudioTranscriberResult`
```

Transcribes mono PCM float32 audio samples in `[-1.0, 1.0]`.

<br />

<br />

<br />

| Args ||
|---|---|
| `audio_samples` | Sequence or 1D NumPy array of mono float32 PCM samples. |
| `end_of_stream` | Whether this audio chunk concludes the current stream. |

<br />

<br />

<br />

<br />

| Returns ||
|---|---|
| An `AudioTranscriberResult` containing recognized segments. ||

<br />

### `__enter__`

[View source](https://github.com/google-ai-edge/mediapipe/blob/master/mediapipe/tasks/python/audio/audio_transcriber.py#L336-L337)

```python
__enter__() -> `mp.tasks.audio.AudioTranscriber`
```

### `__exit__`

[View source](https://github.com/google-ai-edge/mediapipe/blob/master/mediapipe/tasks/python/audio/audio_transcriber.py#L339-L340)

```python
__exit__(
    exc_type, exc_val, exc_tb
) -> None
```