> 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 Go SDK.

# Audio

## Text-to-Speech

`client.Audio.Synthesize` sends `POST /v1/audio/speech` and returns `[]byte` of raw audio.

```go
import (
    "os"
    meshapi "github.com/aifiesta/meshapi-go-sdk"
)

model := "sarvam/bulbul:v2"
voice := "meera"

audioBytes, err := client.Audio.Synthesize(ctx, meshapi.SpeechParams{
    Input: "Hello from MeshAPI.",
    Model: &model,
    Voice: &voice,
})
if err != nil {
    log.Fatal(err)
}

os.WriteFile("output.wav", audioBytes, 0644)
```

### `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                    |
| `ResponseFormat` | `*string`  | Audio format, e.g. `"wav"`, `"mp3"` |
| `Speed`          | `*float64` | Playback speed multiplier           |

***

## Speech-to-Text (Transcription)

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

```go
import "os"

fileData, err := os.ReadFile("audio.wav")
if err != nil {
    log.Fatal(err)
}

lang := "en"
result, err := client.Audio.Transcribe(ctx, fileData, "audio.wav", meshapi.TranscriptionParams{
    Model:    "sarvam/saaras:v3",
    Language: &lang,
})
if err != nil {
    log.Fatal(err)
}

fmt.Println(result.Text)
```

With keyterms (sent as repeated form fields):

```go
result, err := client.Audio.Transcribe(ctx, fileData, "audio.wav", meshapi.TranscriptionParams{
    Model:    "sarvam/saaras:v3",
    Keyterms: []string{"MeshAPI", "transcription"},
})
```

### `TranscriptionParams` key fields

| Field            | Type       | Notes                                      |
| ---------------- | ---------- | ------------------------------------------ |
| `Model`          | `string`   | Required. e.g. `"sarvam/saaras:v3"`        |
| `Language`       | `*string`  | Language code, e.g. `"en"`                 |
| `Keyterms`       | `[]string` | Domain-specific terms to boost recognition |
| `Diarize`        | `*bool`    | Enable speaker diarization                 |
| `NumSpeakers`    | `*int`     | Expected number of speakers                |
| `WithTimestamps` | `*bool`    | Include word-level timestamps              |

***

## Translation

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

```go
result, err := client.Audio.Translate(ctx, fileData, "audio.wav", &meshapi.TranscriptionTranslateParams{
    Model: strPtr("sarvam/saaras:v3"),
})
if err != nil {
    log.Fatal(err)
}

fmt.Println(result.Text)
```

***

## List Voices

`client.Audio.ListVoices` sends `GET /v1/audio/voices`.

```go
pageSize := 10
voices, err := client.Audio.ListVoices(ctx, &meshapi.ListVoicesParams{
    PageSize: &pageSize,
})
if err != nil {
    log.Fatal(err)
}

fmt.Printf("%v\n", voices)
```

### `ListVoicesParams` fields

| Field           | Type      | Notes                          |
| --------------- | --------- | ------------------------------ |
| `PageSize`      | `*int`    | Results per page               |
| `NextPageToken` | `*string` | Pagination cursor              |
| `Search`        | `*string` | Filter by name                 |
| `VoiceType`     | `*string` | `"standard"`, `"cloned"`, etc. |
| `Category`      | `*string` | Voice category filter          |

***

## Get Voice

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

```go
voice, err := client.Audio.GetVoice(ctx, "voice-id")
if err != nil {
    log.Fatal(err)
}
fmt.Printf("%v\n", voice)
```