> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://developers.meshapi.ai/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://developers.meshapi.ai/_mcp/server.

# Audio (TTS & STT)

> Text-to-speech, speech-to-text, and voice management with the Node.js SDK.

# Audio

## Text-to-Speech

`client.audio.synthesize` sends `POST /v1/audio/speech` and returns a `Uint8Array` of raw audio bytes.

```ts
import { MeshAPI } from "meshapi-node-sdk";
import { writeFileSync } from "fs";

const client = new MeshAPI({ baseUrl: "https://api.meshapi.ai", token: "rsk_..." });

const audio = await client.audio.synthesize({
  input: "Hello from MeshAPI.",
  model: "sarvam/bulbul:v2",
  voice: "meera",
});

writeFileSync("output.wav", Buffer.from(audio));
```

### `SpeechParams` fields

| Field             | Type      | Notes                               |
| ----------------- | --------- | ----------------------------------- |
| `input`           | `string`  | Required. Text to synthesize.       |
| `model`           | `string`  | Required. e.g. `"sarvam/bulbul:v2"` |
| `voice`           | `string?` | Voice ID or name                    |
| `response_format` | `string?` | Audio format, e.g. `"wav"`, `"mp3"` |
| `speed`           | `number?` | Playback speed multiplier           |

***

## Speech-to-Text (Transcription)

`client.audio.transcribe` sends `POST /v1/audio/transcriptions` as a multipart upload and returns a `TranscriptionResponse`.

```ts
import { readFileSync } from "fs";

const fileBytes = readFileSync("audio.wav");

const result = await client.audio.transcribe({
  model: "sarvam/saaras:v3",
  file: fileBytes,
  file_name: "audio.wav",
  language: "en",
});

console.log(result.text);
```

### `TranscriptionParams` key fields

| Field             | Type                   | Notes                                      |
| ----------------- | ---------------------- | ------------------------------------------ |
| `model`           | `string`               | Required. e.g. `"sarvam/saaras:v3"`        |
| `file`            | `Uint8Array \| Buffer` | Required. Audio file bytes.                |
| `file_name`       | `string`               | Required. Filename with extension.         |
| `language`        | `string?`              | Language code, e.g. `"en"`                 |
| `keyterms`        | `string[]?`            | Domain-specific terms to boost recognition |
| `diarize`         | `boolean?`             | Enable speaker diarization                 |
| `num_speakers`    | `number?`              | Expected number of speakers                |
| `with_timestamps` | `boolean?`             | Include word-level timestamps              |

***

## Translation

`client.audio.translate` sends `POST /v1/audio/transcriptions/translate` and returns the audio transcribed and translated to English.

```ts
const result = await client.audio.translate({
  model: "sarvam/saaras:v3",
  file: fileBytes,
  file_name: "audio.wav",
});

console.log(result.text);
```

***

## List Voices

`client.audio.listVoices` sends `GET /v1/audio/voices`.

```ts
const voices = await client.audio.listVoices({ page_size: 10 });
console.log(voices);
```

### `ListVoicesParams` fields

| Field             | Type      | Notes                          |
| ----------------- | --------- | ------------------------------ |
| `page_size`       | `number?` | Results per page               |
| `next_page_token` | `string?` | Pagination cursor              |
| `search`          | `string?` | Filter by name                 |
| `voice_type`      | `string?` | `"standard"`, `"cloned"`, etc. |
| `category`        | `string?` | Voice category filter          |

***

## Get Voice

`client.audio.getVoice` sends `GET /v1/audio/voices/{voice_id}`.

```ts
const voice = await client.audio.getVoice("voice-id");
console.log(voice);
```