# client.audio_assets

> The audio_assets methods of the morevoice Python SDK: Uploaded prompts and hold music.

Uploaded prompts and hold music. These methods are on `client.audio_assets`, where `client` is a `MoreVoice` client (see [the Python SDK](https://docs.morevoice.ai/sdk/python/#connect)). On `AsyncMoreVoice` the same methods are awaited. Each one returns the response object and raises an exception when the API answers with an error.

## `create()`

**Upload an audio asset.** Uploads a WAV (mono or stereo PCM 8–48 kHz, 8/16/24/32-bit or float, or G.711 μ-law / A-law), up to 20 MB and 10 minutes, as multipart/form-data (a `file` part) or as JSON with the file base64. It is stored as mono 16-bit PCM at up to 16 kHz. MP3 is not accepted: convert it to WAV first.

```python
# client.audio_assets
def create(self, body: _m.AudioAssetsCreateJsonBody | _m.AudioAssetsCreateFilesBody | Mapping[str, Any] | Unset = UNSET, *, more_voice_version: str | Unset = UNSET, idempotency_key: str | Unset = UNSET) -> _m.AudioAsset
```

`client.audio_assets.create()` · `await async_client.audio_assets.create()` · `POST /audio_assets` · [API reference](https://docs.morevoice.ai/api/operations/audio_assets_create/)

### Request body

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `file` | `object` | yes | The recording. JSON uploads send it base64; multipart/form-data uploads send a `file` part. |
| `kind` | `"prompt" \| "music"` | no | Default prompt. |
| `name` | `string` | no | Default: “Prompt” / “Music” with the time. |
| `text` | `string` | no | What the recording says. |

### Returns

`AudioAsset`:

| Field | Type | Description |
| --- | --- | --- |
| `object` | `"audio_asset"` | Always `audio_asset`. |
| `id` | `string` | A audio asset ID (prefix `aud_`). |
| `livemode` | `boolean` | `true` in live mode, `false` in test mode. |
| `name` | `string` | — |
| `kind` | `"prompt" \| "music"` | `prompt` (an IVR / flow prompt) or `music` (queue hold music). |
| `sample_rate` | `integer` | The stored rate (mono PCM16, up to 16 kHz). |
| `duration_ms` | `integer` | — |
| `text` | `string` | What the recording says (shown in the flow editor and the transcript). |
| `created` | `string` | An ISO-8601 timestamp in UTC. |

### Example

```python
from morevoice import MoreVoice

client = MoreVoice()  # MOREVOICE_API_KEY from the environment

audio_asset = client.audio_assets.create({
    "file": {
        "content_base64": "UklGRiQAAABXQVZFZm10IBAAAAABAAEAgD4AAAB9AAACABAAZGF0YQAAAAA=",
        "filename": "welcome.wav",
    },
    "kind": "prompt",
    "name": "Welcome (Hebrew)",
    "text": "שלום, הגעתם ל…",
})
print(audio_asset)
```

## `delete()`

**Delete an audio asset.** Refused (409) while a flow (draft or a published version) or a queue's hold audio uses it; `details.used_by` lists them.

```python
# client.audio_assets
def delete(self, id: str, *, more_voice_version: str | Unset = UNSET, idempotency_key: str | Unset = UNSET) -> _m.DeletedAudioAsset
```

`client.audio_assets.delete()` · `await async_client.audio_assets.delete()` · `DELETE /audio_assets/{id}` · [API reference](https://docs.morevoice.ai/api/operations/audio_assets_delete/)

### Parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | `str` | yes | A audio asset ID (`aud_…`). |

### Returns

`DeletedAudioAsset`:

| Field | Type | Description |
| --- | --- | --- |
| `object` | `"audio_asset"` | Always `audio_asset`. |
| `id` | `string` | A audio asset ID (prefix `aud_`). |
| `deleted` | `true` | — |

### Example

```python
from morevoice import MoreVoice

client = MoreVoice()  # MOREVOICE_API_KEY from the environment

deleted_audio_asset = client.audio_assets.delete("aud_7Hk2Lm9Qp")
print(deleted_audio_asset)
```

## `list()`

**List audio assets.** Returns a page of `AudioAsset` objects, newest first. Pass `next_cursor` as `starting_after` for the next page; the SDKs iterate every page for you.

```python
# client.audio_assets
def list(self, *, limit: int | Unset = 20, starting_after: str | Unset = UNSET, ending_before: str | Unset = UNSET, kind: _m.AudioAssetsListKind | Unset = UNSET, more_voice_version: str | Unset = UNSET) -> AsyncPage[_m.AudioAsset]
```

`client.audio_assets.list()` · `await async_client.audio_assets.list()` · `GET /audio_assets` · [API reference](https://docs.morevoice.ai/api/operations/audio_assets_list/)

### Parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `limit` | `integer` | no | How many objects to return, 1–100 (default 20). |
| `starting_after` | `string` | no | A cursor (`next_cursor`) or object ID: return the objects after it (older). |
| `ending_before` | `string` | no | A cursor or object ID: return the objects before it (newer). |
| `kind` | `"prompt" \| "music"` | no | Only prompts or only music. |

### Returns

A page of results (`AudioAssetList`): `data`, `has_more` and `next_cursor`.

### Example

```python
from morevoice import MoreVoice

client = MoreVoice()  # MOREVOICE_API_KEY from the environment

for audio_asset in client.audio_assets.list():
    print(audio_asset)
```

## `retrieve()`

**Retrieve an audio asset.** Returns the `AudioAsset` object. Answers `404` with the code `resource_missing` when nothing has this ID in this organisation and mode.

```python
# client.audio_assets
def retrieve(self, id: str, *, more_voice_version: str | Unset = UNSET) -> _m.AudioAsset
```

`client.audio_assets.retrieve()` · `await async_client.audio_assets.retrieve()` · `GET /audio_assets/{id}` · [API reference](https://docs.morevoice.ai/api/operations/audio_assets_retrieve/)

### Parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | `str` | yes | A audio asset ID (`aud_…`). |

### Returns

`AudioAsset`:

| Field | Type | Description |
| --- | --- | --- |
| `object` | `"audio_asset"` | Always `audio_asset`. |
| `id` | `string` | A audio asset ID (prefix `aud_`). |
| `livemode` | `boolean` | `true` in live mode, `false` in test mode. |
| `name` | `string` | — |
| `kind` | `"prompt" \| "music"` | `prompt` (an IVR / flow prompt) or `music` (queue hold music). |
| `sample_rate` | `integer` | The stored rate (mono PCM16, up to 16 kHz). |
| `duration_ms` | `integer` | — |
| `text` | `string` | What the recording says (shown in the flow editor and the transcript). |
| `created` | `string` | An ISO-8601 timestamp in UTC. |

### Example

```python
from morevoice import MoreVoice

client = MoreVoice()  # MOREVOICE_API_KEY from the environment

audio_asset = client.audio_assets.retrieve("aud_7Hk2Lm9Qp")
print(audio_asset)
```

## `retrieve_content()`

**Download an audio asset.** The recording as a WAV file (mono 16-bit PCM at its stored rate).

```python
# client.audio_assets
def retrieve_content(self, id: str, *, more_voice_version: str | Unset = UNSET) -> bytes
```

`client.audio_assets.retrieve_content()` · `await async_client.audio_assets.retrieve_content()` · `GET /audio_assets/{id}/content` · [API reference](https://docs.morevoice.ai/api/operations/audio_assets_retrieve_content/)

### Parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | `str` | yes | A audio asset ID (`aud_…`). |

### Returns

Nothing, on success.

### Example

```python
from morevoice import MoreVoice

client = MoreVoice()  # MOREVOICE_API_KEY from the environment

data = client.audio_assets.retrieve_content("aud_7Hk2Lm9Qp")
print(len(data), "bytes")
```

## `update()`

**Rename an audio asset.** Changes the name or the text (what it says). To replace the audio, upload a new asset.

```python
# client.audio_assets
def update(self, id: str, body: _m.AudioAssetsUpdateBody | Mapping[str, Any] | Unset = UNSET, *, more_voice_version: str | Unset = UNSET) -> _m.AudioAsset
```

`client.audio_assets.update()` · `await async_client.audio_assets.update()` · `PATCH /audio_assets/{id}` · [API reference](https://docs.morevoice.ai/api/operations/audio_assets_update/)

### Parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | `str` | yes | A audio asset ID (`aud_…`). |

### Request body

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `name` | `string` | no | — |
| `text` | `string` | no | — |

### Returns

`AudioAsset`:

| Field | Type | Description |
| --- | --- | --- |
| `object` | `"audio_asset"` | Always `audio_asset`. |
| `id` | `string` | A audio asset ID (prefix `aud_`). |
| `livemode` | `boolean` | `true` in live mode, `false` in test mode. |
| `name` | `string` | — |
| `kind` | `"prompt" \| "music"` | `prompt` (an IVR / flow prompt) or `music` (queue hold music). |
| `sample_rate` | `integer` | The stored rate (mono PCM16, up to 16 kHz). |
| `duration_ms` | `integer` | — |
| `text` | `string` | What the recording says (shown in the flow editor and the transcript). |
| `created` | `string` | An ISO-8601 timestamp in UTC. |

### Example

```python
from morevoice import MoreVoice

client = MoreVoice()  # MOREVOICE_API_KEY from the environment

audio_asset = client.audio_assets.update("aud_7Hk2Lm9Qp", {
    "name": "Welcome (Hebrew, v2)",
})
print(audio_asset)
```
