> ## Documentation Index
> Fetch the complete documentation index at: https://docs.runanywhere.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# synthesize()

> Turn text into audio

```ts theme={"theme":"css-variables"}
// Get the audio back
const audio = await RunAnywhere.tts.synthesize('Hello from RunAnywhere')

// Play it
await RunAnywhere.tts.speak('Hello from RunAnywhere')
```

## Signatures

```ts theme={"theme":"css-variables"}
synthesize(text: string, options?: TtsOptions): Promise<Audio>
synthesizeStream(text: string, options?: TtsOptions): AsyncIterable<AudioChunk>
speak(text: string, options?: TtsOptions): Promise<SpeechHandle>
stop(): void
voices(): Promise<Voice[]>
```

`stop()` is synchronous on Web, unlike the native SDKs where it is async.

## Options

```ts theme={"theme":"css-variables"}
const audio = await RunAnywhere.tts.synthesize('Hello', {
  voice: 'en_US-amy-medium',
  speed: 1.1,
})
```

| Field | Type | Default |
| - | - | - |
| `voice` | `string` | none, model default |
| `language` | `string` | proto default |
| `speed` | `number` | proto default |
| `pitch` | `number` | proto default |
| `format` | `AudioFormat` | proto default |
| `sampleRate` | `number` | proto default |

## Autoplay

Browsers block audio that starts without a user gesture. `speak()` called on page load is
silently suppressed by the browser, not by the SDK. Trigger it from a click, or prime an
`AudioContext` on the first interaction and reuse it.

## Playing it yourself

```ts theme={"theme":"css-variables"}
import { AudioPlayback } from '@runanywhere/web/browser'

const audio = await RunAnywhere.tts.synthesize('Hello')
const player = new AudioPlayback()
await player.play(audio)
```

## Saving to a file

```ts theme={"theme":"css-variables"}
const audio = await RunAnywhere.tts.synthesize('Save me')
const blob = new Blob([audio.samples], { type: 'audio/wav' })
const url = URL.createObjectURL(blob)
```

Revoke the object URL when you are finished with it.

## Stopping

```ts theme={"theme":"css-variables"}
RunAnywhere.tts.stop()
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.