> ## 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.

# Voices

> Available TTS voices and voice management

<Note>**Early Beta** -- The Web SDK is in early beta. APIs may change between releases.</Note>

## Overview

The Web SDK supports multiple TTS voice models via Piper TTS (VITS architecture) compiled to WebAssembly through sherpa-onnx. This page covers available voices, switching voices, and managing multiple voice models.

## Available Voices

The Web SDK uses [Piper TTS](https://github.com/rhasspy/piper) voice models in ONNX format. These are neural voices that produce natural-sounding speech.

### Recommended Voices

| Voice                   | Language     | Quality | Size   | Speed |
| ----------------------- | ------------ | ------- | ------ | ----- |
| `en_US-lessac-medium`   | English (US) | High    | \~65MB | Fast  |
| `en_US-amy-medium`      | English (US) | High    | \~65MB | Fast  |
| `en_GB-alba-medium`     | English (UK) | High    | \~65MB | Fast  |
| `de_DE-thorsten-medium` | German       | High    | \~65MB | Fast  |
| `fr_FR-siwis-medium`    | French       | High    | \~65MB | Fast  |
| `es_ES-davefx-medium`   | Spanish      | High    | \~65MB | Fast  |

<Tip>
  Piper TTS has hundreds of voices in many languages. Browse the full catalog at [Piper
  Samples](https://rhasspy.github.io/piper-samples/).
</Tip>

## Loading a Voice

```typescript theme={null}
import { TTS } from '@runanywhere/web'

await TTS.loadVoice({
  voiceId: 'piper-en-lessac',
  modelPath: '/models/en_US-lessac-medium.onnx',
  tokensPath: '/models/tokens.txt',
  dataDir: '/models/espeak-ng-data',
})
```

## Switching Voices

Unload the current voice before loading a new one:

```typescript theme={null}
// Unload current voice
await TTS.unloadVoice()

// Load a different voice
await TTS.loadVoice({
  voiceId: 'piper-de-thorsten',
  modelPath: '/models/de_DE-thorsten-medium.onnx',
  tokensPath: '/models/tokens.txt',
  dataDir: '/models/espeak-ng-data',
})

// Synthesize in German
const result = await TTS.synthesize('Hallo, willkommen bei RunAnywhere!')
```

## Voice Properties

Check the currently loaded voice:

```typescript theme={null}
console.log('Voice loaded:', TTS.isVoiceLoaded)
console.log('Voice ID:', TTS.voiceId)
console.log('Sample rate:', TTS.sampleRate) // typically 22050
console.log('Number of speakers:', TTS.numSpeakers)
```

## Multi-Speaker Models

Some Piper voice models include multiple speakers. Select a speaker by ID:

```typescript theme={null}
// Check available speakers
console.log('Speakers:', TTS.numSpeakers)

// Synthesize with different speakers
const speaker0 = await TTS.synthesize('Hello!', { speakerId: 0 })
const speaker1 = await TTS.synthesize('Hello!', { speakerId: 1 })
```

## Voice Configuration Options

```typescript theme={null}
interface TTSVoiceConfig {
  /** Unique voice identifier */
  voiceId: string

  /** Path to VITS/Piper ONNX model file */
  modelPath: string

  /** Path to tokens.txt file */
  tokensPath: string

  /** Path to espeak-ng-data directory */
  dataDir?: string

  /** Path to custom lexicon file */
  lexicon?: string

  /** Number of inference threads (default: 1) */
  numThreads?: number
}
```

## Clean Up

Release TTS resources when no longer needed:

```typescript theme={null}
await TTS.unloadVoice()
TTS.cleanup()
```

## Related

<CardGroup cols={2}>
  <Card title="Synthesize" icon="volume-high" href="/web/tts/synthesize">
    Text-to-Speech synthesis
  </Card>

  <Card title="TTS Output" icon="play" href="/web/tts/stream">
    Working with audio output
  </Card>

  <Card title="Voice Agent" icon="robot" href="/web/voice-agent">
    Full voice pipeline
  </Card>
</CardGroup>
