# `examples.mic_transcribe`

Live Microphone Transcription with Whisper - vllm-mlx Records audio from your Mac's microphone and transcribes it using Whisper.

[View the complete module source at #L1-L221](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/examples/mic_transcribe.py#L1-L221).

## API details

Each callable below includes its exact signature, type annotations, inputs, defaults, return contract, documented exceptions, implementation source, and parsed docstring sections when the source provides them.

::: examples.mic_transcribe
    options:
      members:
        - MODEL_ALIASES
        - record_audio
        - save_audio
        - main
      filters: []
      show_if_no_docstring: true

## Complete contract reference

Expand any definition for its exact inputs, annotations, defaults, return contract, directly raised exceptions, source-grounded behavior, and immutable line link. This section includes private and nested definitions that ordinary API generators omit.

<details class="api-contract" id="contract-examples.mic_transcribe.record_audio" markdown="1">
<summary><code>examples.mic_transcribe.record_audio</code> · function</summary>

```python
examples.mic_transcribe.record_audio(duration = None, sample_rate = 16000) -> not annotated
```

Record audio from microphone.

**Parameters**

| Name | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `duration` | `not annotated` | `no` | `None` | Recording duration in seconds. If None, records until Enter. |
| `sample_rate` | `not annotated` | `no` | `16000` | Audio sample rate (16000 Hz for Whisper) |

**Returns**

- Type: `not annotated`
- Direct return expressions: `(audio.flatten(), sample_rate)`

**Exceptions and behavior**

Function `record_audio` calls `print`, `sd.rec`, `int`, `sd.wait`; returns `(audio.flatten(), sample_rate)`.
No direct `raise` statement appears in this definition.

[View source #L39-L93](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/examples/mic_transcribe.py#L39-L93).

</details>

<details class="api-contract" id="contract-examples.mic_transcribe.record_audio.wait_for_enter" markdown="1">
<summary><code>examples.mic_transcribe.record_audio.wait_for_enter</code> · nested function</summary>

```python
examples.mic_transcribe.record_audio.wait_for_enter() -> not annotated
```

Nested Function `record_audio.wait_for_enter` calls `input`, `stop_recording.set`.

**Parameters**

This callable has no explicit inputs.

**Returns**

- Type: `not annotated`

**Exceptions and behavior**

Nested Function `record_audio.wait_for_enter` calls `input`, `stop_recording.set`.
No direct `raise` statement appears in this definition.

[View source #L71-L73](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/examples/mic_transcribe.py#L71-L73).

</details>

<details class="api-contract" id="contract-examples.mic_transcribe.save_audio" markdown="1">
<summary><code>examples.mic_transcribe.save_audio</code> · function</summary>

```python
examples.mic_transcribe.save_audio(audio, sample_rate, path) -> not annotated
```

Save audio to WAV file.

**Parameters**

| Name | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `audio` | `not annotated` | `yes` | `none` | Required positional or keyword input. |
| `sample_rate` | `not annotated` | `yes` | `none` | Required positional or keyword input. |
| `path` | `not annotated` | `yes` | `none` | Required positional or keyword input. |

**Returns**

- Type: `not annotated`

**Exceptions and behavior**

Function `save_audio` calls `sf.write`.
No direct `raise` statement appears in this definition.

[View source #L96-L99](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/examples/mic_transcribe.py#L96-L99).

</details>

<details class="api-contract" id="contract-examples.mic_transcribe.main" markdown="1">
<summary><code>examples.mic_transcribe.main</code> · function</summary>

```python
examples.mic_transcribe.main() -> not annotated
```

Function `main` calls `argparse.ArgumentParser`, `parser.add_argument`, `parser.parse_args`, `print`; returns `None`.

**Parameters**

This callable has no explicit inputs.

**Returns**

- Type: `not annotated`
- Direct return expressions: `None`

**Exceptions and behavior**

Function `main` calls `argparse.ArgumentParser`, `parser.add_argument`, `parser.parse_args`, `print`; returns `None`.
No direct `raise` statement appears in this definition.

[View source #L102-L217](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/examples/mic_transcribe.py#L102-L217).

</details>

## Complete symbol map

This map also includes private definitions and nested helpers. The signature column exposes every explicit input even when an internal helper has no dedicated parameter prose.

| Symbol | Kind | Signature and inputs | What it does | Source |
| --- | --- | --- | --- | --- |
| [`record_audio`](#contract-examples.mic_transcribe.record_audio) | function | `record_audio(duration = None, sample_rate = 16000) -> not annotated` | Record audio from microphone. | [#L39-L93](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/examples/mic_transcribe.py#L39-L93) |
| [`record_audio.wait_for_enter`](#contract-examples.mic_transcribe.record_audio.wait_for_enter) | nested function | `record_audio.wait_for_enter() -> not annotated` | Nested Function `record_audio.wait_for_enter` calls `input`, `stop_recording.set`. | [#L71-L73](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/examples/mic_transcribe.py#L71-L73) |
| [`save_audio`](#contract-examples.mic_transcribe.save_audio) | function | `save_audio(audio, sample_rate, path) -> not annotated` | Save audio to WAV file. | [#L96-L99](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/examples/mic_transcribe.py#L96-L99) |
| [`main`](#contract-examples.mic_transcribe.main) | function | `main() -> not annotated` | Function `main` calls `argparse.ArgumentParser`, `parser.add_argument`, `parser.parse_args`, `print`; returns `None`. | [#L102-L217](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/examples/mic_transcribe.py#L102-L217) |
