> ## 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={null}
// Get the audio back
const audio = await RunAnywhere.tts.synthesize('Hello from RunAnywhere')

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

## Signatures

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

Both `speak` and `stop` are async here, unlike React Native and Flutter where `speak` is
synchronous, and unlike Web where `stop` is.

## Options

```ts theme={null}
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       |

## Playback lives in the renderer

The utility host produces samples; the renderer plays them. `speak()` handles the common case
for you, but when you want control over routing or mixing, synthesize and hand the samples to
a `Web Audio` graph in the window.

## Saving to a file

```ts theme={null}
import { writeFile } from 'node:fs/promises'

const audio = await RunAnywhere.tts.synthesize('Save me')
await writeFile(path, audio.samples)
```

A desktop app can write straight to a path the user picked, which is the main thing this has
over the browser.

## Stopping

```ts theme={null}
await RunAnywhere.tts.stop()
```

Stops whatever is speaking, without needing the handle.
