# Sound tools

Tools that make, split, find and delete sounds in the library, plus `search_docs`. A sound in a result carries an
absolute `path` to a WAV on the server's machine, a `url` under `/files/`, and its `id`, `name`, `model`, `prompt`,
`duration_s`, `sample_rate`, `channels`, `seed`, `tags` and `parent_id`.

| Tool | Description |
|---|---|
| [`soundbox.generate`](#soundboxgenerate) | Render sounds from a text description |
| [`soundbox.separate`](#soundboxseparate) | Split a sound into stems |
| [`soundbox.enhance_prompt`](#soundboxenhance_prompt) | Rewrite a prompt for a sound model |
| [`soundbox.list_models`](#soundboxlist_models) | List models with licence and capabilities |
| [`soundbox.list_sounds`](#soundboxlist_sounds) | Search the library |
| [`soundbox.get_sound`](#soundboxget_sound) | Get one sound |
| [`soundbox.delete_sound`](#soundboxdelete_sound) | Delete a sound and its file |
| [`soundbox.search_docs`](#soundboxsearch_docs) | Search Mirli's documentation |

## Sounds

### `soundbox.generate`

Renders one or more sounds from a text description, saves them to the library, and blocks until the audio is on disk.

| Argument | Type | Required | Description |
|---|---|---|---|
| `prompt` | string | Yes | Material, action and space. With `lyrics`, genre and instrumentation instead |
| `duration_s` | number | No | 0.5–300. Default `5.0` |
| `model` | string | No | Model id. Default: the loaded model, else the first installed one. A model that bills per render is used only when named |
| `negative_prompt` | string | No | What to avoid. Ignored by models without `supports.negative_prompt` |
| `seed` | integer | No | ≥ 0. Default random |
| `variations` | integer | No | 1–4 takes. Default `1` |
| `tags` | string[] | No | Library tags |
| `lyrics` | string | No | Up to 4,000 characters to sing, e.g. `[verse]\nGame over`. Ignored by models without `supports.lyrics` |
| `track_name` | string | No | Track title, used only with `lyrics` |
| `source_sound_id` | string | No | Edit this sound instead of rendering fresh. The result's `parent_id` is this id |
| `edit` | `extend`, `cover`, `repaint` | No | The edit to apply to `source_sound_id` |
| `edit_options` | object | No | Options for the edit |

| `edit` | Result | `edit_options` |
|---|---|---|
| `extend` | The source continued to `duration_s`, which must exceed the source's length. The original stays intact at the start | None |
| `cover` | The source re-rendered in the style of `prompt` and `lyrics`, at the source's length | `cover_strength` 0–1; 1 stays close to the source |
| `repaint` | The span from `repaint_start_s` to `repaint_end_s` regenerated | `repaint_start_s` and `repaint_end_s` required; `repaint_mode` (`balanced`, `conservative`, `aggressive`) and `repaint_strength` 0–1 optional |

Example arguments:

```json title="soundbox.generate arguments"
{
  "prompt": "heavy wooden door slamming in a stone corridor",
  "duration_s": 3,
  "variations": 2
}
```

**Result:** `sounds` (one per variation), `model` (the id used) and `elapsed_s`.

**Errors:**

- `duration_s` greater than the model's `max_duration_s`.
- A model whose `task` is not `gen`.
- An `edit` the model does not support. In the shipped catalogue the ACE-Step models support all three edits and
  lyrics; MiniMax Music 3 supports lyrics only.
- No model installed, or only models that bill per render and none named.
- The job failed, was cancelled, or ran past 15 minutes.

### `soundbox.separate`

Splits a library sound into stems (vocals, drums, bass, other), saves each as its own sound, and blocks until the audio
is on disk.

| Argument | Type | Required | Description |
|---|---|---|---|
| `sound_id` | string | Yes | The sound to split |
| `model` | string | No | A model with `task: "sep"`. Default: an installed separator, preferring a loaded one |
| `stems` | string[] | No | Stems to keep, e.g. `["vocals"]`. Default all. A name no stem answers to is reported in the result |
| `rest` | `discard`, `merge` | No | What happens to the stems not named. `merge` sums them into one "rest" sound. Default `discard`; ignored without `stems` |

**Result:** `sounds` (the stems, each with `stem_name`), `model` and `elapsed_s`.

**Errors:** no separation model installed; no sound with that id; the job failed or was cancelled.

### `soundbox.enhance_prompt`

Rewrites a vague prompt into one or more concrete ones for a sound model.

| Argument | Type | Required | Description |
|---|---|---|---|
| `prompt` | string | Yes | 1–2,000 characters |
| `n` | integer | No | 1–5 variations. Default `1` |
| `category` | `sfx`, `music` | No | Default `sfx` |
| `lyrics` | boolean | No | True when the prompt sets genre for a model that will sing lyrics |
| `model` | string | No | The id to generate with. The rewrite follows that model's prompting conventions |

**Result:** `variations` (the rewritten prompts) and `tags` (suggested library tags, for `generate`'s `tags`).

**Errors:** none. When the prompt assistant is off, or it fails, the tool returns a plain-text explanation instead of
JSON.

### `soundbox.list_models`

Lists every model, generation and otherwise, with its status and licence. Takes no arguments.

**Result:** an array of models:

| Field | Description |
|---|---|
| `id`, `name`, `vendor`, `description` | Identity |
| `task` | `gen` (`generate`), `tts` (speech tools) or `sep` (`separate`) |
| `status` | Install and load state |
| `license`, `commercial_use` | Licence name, and `yes`, `no` or `conditional` |
| `max_duration_s`, `sample_rate` | Limits of the output |
| `gated` | Whether the download needs an access token |
| `supports` | Booleans: `negative_prompt`, `seed`, `lyrics`, `extend`, `cover`, `repaint` |
| `delivery` | Text-to-speech models only: each parameter's name, group, default, range or choices |

`delivery` is read from audio.cpp's own parameter table. audio.cpp accepts unknown options without an error, so only
these names have an effect. The stdio bridge returns `supports` but not `task`, `description`, `gated` or `delivery`.

**Errors:** none.

### `soundbox.list_sounds`

Searches the library.

| Argument | Type | Required | Description |
|---|---|---|---|
| `q` | string | No | Text to match in the prompt or name |
| `tag` | string | No | A library tag |
| `voice_id` | string | No | Only sounds read in this saved voice. A multi-voice dialogue is filed under no single voice |
| `limit` | integer | No | 1–100. Default `20` |

**Result:** an array of sounds.

**Errors:** none.

### `soundbox.get_sound`

Gets one sound by id.

| Argument | Type | Required | Description |
|---|---|---|---|
| `sound_id` | string | Yes | The sound |

**Result:** the sound, with its absolute `path`.

**Errors:** `No sound with id <SOUND_ID>`.

### `soundbox.delete_sound`

Permanently deletes a sound's row and its file on disk. Sounds derived from it are kept and lose the link.

| Argument | Type | Required | Description |
|---|---|---|---|
| `sound_id` | string | Yes | The sound |

**Result:** the text `Deleted <SOUND_ID>`.

**Errors:** `No sound with id <SOUND_ID>`; the sound is on a story's timeline (the error names the story).

## Documentation

### `soundbox.search_docs`

Finds the sections of Mirli's README and `docs/` that match a question. Needs no studio open.

| Argument | Type | Required | Description |
|---|---|---|---|
| `query` | string | Yes | 1–500 characters |
| `limit` | integer | No | 1–8. Default `4` |

**Result:** `sections`, each with `source` (the file), `heading` and `text` (cut at 4,000 characters). With no match,
an empty list and a `note`.

**Errors:** none.
