# mv.voices

> The voices methods of @morevoice/sdk: Voices assistants can speak with.

Voices assistants can speak with. These methods are on `mv.voices`, where `mv` is your client (see [the Node.js SDK](https://docs.morevoice.ai/sdk/node/#connect)). Each one returns the response object and throws when the API answers with an error.

## `list()`

**List voices.** The voices assistants can speak with: your custom voices first, then the provider's library by name (the dashboard's order).

```ts
mv.voices.list(query?: NonNullable<VoicesListData["query"]>, options?: RequestOptions): PagedList<VoicesListResponse["data"][number], NonNullable<VoicesListData["query"]>>
```

`GET /voices` · [API reference](https://docs.morevoice.ai/api/operations/voices_list/)

### Parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `query.limit` | `integer` | no | How many objects to return, 1–100 (default 20). |
| `query.starting_after` | `string` | no | A cursor (`next_cursor`) or object ID: return the objects after it (older). |
| `query.ending_before` | `string` | no | A cursor or object ID: return the objects before it (newer). |
| `query.type` | `string` | no | Only prebuilt or only custom voices. |
| `query.language` | `string` | no | Only voices listing this language (`en` matches `en-US`). |
| `options.headers["MoreVoice-Version"]` | `string` | no | The API version to use for this request. Defaults to the version the API key is pinned to. |
| `options` | `RequestOptions` | no | `idempotencyKey`, extra `headers` and an abort `signal`: see [retries and idempotency](https://docs.morevoice.ai/sdk/typescript/retries/). |

### Returns

A [`PagedList`](https://docs.morevoice.ai/sdk/typescript/pagination/): `await` it for the first page, `for await` it for every item.

### Example

```ts
import MoreVoice from "@morevoice/sdk";

const mv = new MoreVoice(); // MOREVOICE_API_KEY from the environment

for await (const voice of mv.voices.list()) {
	console.log(voice);
}
```

## `preview()`

**Preview a voice.** Speaks up to 300 characters in a voice and returns a WAV file. Test-mode keys get a synthetic tone of the same length instead, and no speech provider is called; the `Audio-Source` response header says which you got (`speech` or `synthetic`).

```ts
mv.voices.preview(body: VoicesPreviewData["body"], options?: RequestOptions): Promise<VoicesPreviewResponse>
```

`POST /voices/preview` · [API reference](https://docs.morevoice.ai/api/operations/voices_preview/)

### Parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `body.voice_id` | `string` | yes | The voice to hear (`voice_id` from `GET /v1/voices`). |
| `body.language` | `string` | no | The language of `text` (default `he`). |
| `body.model` | `string` | no | The TTS model (default: the assistants' default). |
| `body.style` | `string` | no | Delivery direction, e.g. `calm and reassuring`. |
| `body.text` | `string` | no | What to say, up to 300 characters (default: a short greeting in `language`). |
| `options.headers["MoreVoice-Version"]` | `string` | no | The API version to use for this request. Defaults to the version the API key is pinned to. |
| `options.headers["Idempotency-Key"]` | `string` | no | A unique key (for example a UUID) that makes this request safe to retry: for 24 hours, a retry with the same key and parameters returns the first response instead of acting twice. |
| `options` | `RequestOptions` | no | `idempotencyKey`, extra `headers` and an abort `signal`: see [retries and idempotency](https://docs.morevoice.ai/sdk/typescript/retries/). |

### Returns

Nothing, on success.

### Example

```ts
import MoreVoice from "@morevoice/sdk";

const mv = new MoreVoice(); // MOREVOICE_API_KEY from the environment

const data = await mv.voices.preview({
	language: "he",
	style: "warm and friendly",
	text: "שלום! ככה אני נשמעת.",
	voice_id: "Kore",
});
console.log(data);
```
