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

# Text-to-Speech

> Generate natural-sounding speech from text

Multiple voices, streaming support, multilingual.

```bash title="Endpoint" theme={"theme":{"light":"github-light","dark":"one-dark-pro"}}
POST /voice/v1/speak
```

<CodeGroup>
  ```bash title="cURL" theme={"theme":{"light":"github-light","dark":"one-dark-pro"}}
  curl -X POST https://api.case.dev/voice/v1/speak \
    -H "Authorization: Bearer sk_case_YOUR_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "text": "The court finds in favor of the plaintiff.",
      "voice_id": "EXAVITQu4vr4xnSDxMaL"
    }' \
    --output ruling.mp3
  ```

  ```typescript title="Typescript" theme={"theme":{"light":"github-light","dark":"one-dark-pro"}}
  import Casedev from 'casedev';

  const client = new Casedev({ apiKey: 'sk_case_YOUR_API_KEY' });

  const audio = await client.voice.v1.speak.create({
    text: 'The court finds in favor of the plaintiff.',
    voice_id: 'EXAVITQu4vr4xnSDxMaL'
  });

  // Save to file
  fs.writeFileSync('ruling.mp3', Buffer.from(audio));
  ```

  ```python title="Python" theme={"theme":{"light":"github-light","dark":"one-dark-pro"}}
  import casedev

  client = casedev.Casedev(api_key='sk_case_YOUR_API_KEY')

  audio = client.voice.v1.speak.create(
      text='The court finds in favor of the plaintiff.',
      voice_id='EXAVITQu4vr4xnSDxMaL'
  )

  with open('ruling.mp3', 'wb') as f:
      f.write(audio)
  ```

  ```go title="Go" theme={"theme":{"light":"github-light","dark":"one-dark-pro"}}
  audioResp, _ := client.Voice.V1.Speak.New(ctx, casedev.VoiceV1SpeakNewParams{
  	Text: casedev.F("The court finds in favor of the plaintiff."),
  })
  // audioResp is *http.Response with audio body
  ```

  <Info>
    The `casedev` CLI does not yet expose a text-to-speech command. Use cURL or one of the supported SDKs above.
  </Info>
</CodeGroup>

## Parameters

| Parameter       | Type   | Required | Description                             |
| --------------- | ------ | -------- | --------------------------------------- |
| `text`          | string | **Yes**  | Text to convert to speech               |
| `voice_id`      | string | No       | Voice ID (default: Rachel)              |
| `output_format` | string | No       | Audio format (default: `mp3_44100_128`) |
| `language_code` | string | No       | Language for multilingual voices        |

## List voices

Get available voices:

<CodeGroup>
  ```bash title="cURL" theme={"theme":{"light":"github-light","dark":"one-dark-pro"}}
  curl https://api.case.dev/voice/v1/voices \
    -H "Authorization: Bearer sk_case_YOUR_API_KEY"
  ```

  ```bash title="CLI" theme={"theme":{"light":"github-light","dark":"one-dark-pro"}}
  casedev voice:v1 list-voices
  ```

  ```typescript title="Typescript" theme={"theme":{"light":"github-light","dark":"one-dark-pro"}}
  const { voices } = await client.voice.v1.listVoices();

  for (const voice of voices) {
    console.log(`${voice.name} (${voice.voice_id}): ${voice.labels.description}`);
  }
  ```

  ```python title="Python" theme={"theme":{"light":"github-light","dark":"one-dark-pro"}}
  result = client.voice.v1.list_voices()

  for voice in result.voices:
      print(f'{voice.name} ({voice.voice_id}): {voice.labels.description}')
  ```

  ```go title="Go" theme={"theme":{"light":"github-light","dark":"one-dark-pro"}}
  result, _ := client.Voice.V1.ListVoices(ctx, casedev.VoiceV1ListVoicesParams{})
  for _, voice := range result.Voices {
  	fmt.Printf("%s (%s): %s\n", voice.Name, voice.VoiceID, voice.Labels.Description)
  }
  ```
</CodeGroup>

## Popular voices

| Voice  | ID                     | Description                   |
| ------ | ---------------------- | ----------------------------- |
| Rachel | `EXAVITQu4vr4xnSDxMaL` | Professional, clear (default) |
| Adam   | `21m00Tcm4TlvDq8ikWAM` | Deep, authoritative           |
| Antoni | `ErXwobaYiN019PkySvjV` | Well-rounded, calm            |
| Josh   | `TxGEqnHWrfWFTfGW9XjX` | Deep, narrative               |

## Streaming

For lower latency, stream audio as it's generated:

```bash title="Endpoint" theme={"theme":{"light":"github-light","dark":"one-dark-pro"}}
POST /voice/v1/speak/stream
```

<CodeGroup>
  ```bash title="cURL" theme={"theme":{"light":"github-light","dark":"one-dark-pro"}}
  curl -X POST https://api.case.dev/voice/v1/speak \
    -H "Authorization: Bearer $CASEDEV_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{}'
  ```

  ```typescript title="Typescript" theme={"theme":{"light":"github-light","dark":"one-dark-pro"}}
  const stream = await client.voice.v1.speak.stream({
    text: 'This audio starts playing immediately.',
    voice_id: 'EXAVITQu4vr4xnSDxMaL'
  });

  // Pipe to file or audio player
  const writeStream = fs.createWriteStream('streamed.mp3');
  stream.pipe(writeStream);
  ```

  ```python title="Python" theme={"theme":{"light":"github-light","dark":"one-dark-pro"}}
  audio = client.voice.v1.speak.create(
      text='This audio starts playing immediately.',
      voice_id='EXAVITQu4vr4xnSDxMaL'
  )

  with open('streamed.mp3', 'wb') as f:
      f.write(audio)
  ```

  ```go title="Go" theme={"theme":{"light":"github-light","dark":"one-dark-pro"}}
  audioResp, _ := client.Voice.V1.Speak.New(ctx, casedev.VoiceV1SpeakNewParams{
  	Text: casedev.F("The court finds in favor of the plaintiff."),
  })
  // audioResp is *http.Response with audio body
  ```

  <Info>
    The `casedev` CLI does not yet expose a text-to-speech command. Use cURL or one of the supported SDKs above.
  </Info>
</CodeGroup>

## Output formats

| Format          | Description                     |
| --------------- | ------------------------------- |
| `mp3_44100_128` | MP3, 44.1kHz, 128kbps (default) |
| `mp3_44100_192` | MP3, 44.1kHz, 192kbps           |
| `pcm_16000`     | PCM, 16kHz                      |
| `pcm_44100`     | PCM, 44.1kHz                    |

## Examples

### Narrate a document summary

<CodeGroup>
  ```typescript title="Typescript" theme={"theme":{"light":"github-light","dark":"one-dark-pro"}}
  const audio = await client.voice.v1.speak.create({
    text: `Summary of Smith v. Hospital: The plaintiff alleges medical
           malpractice during a surgical procedure on March 15, 2024...`,
    voice_id: 'EXAVITQu4vr4xnSDxMaL'
  });
  ```

  ```python title="Python" theme={"theme":{"light":"github-light","dark":"one-dark-pro"}}
  audio = client.voice.v1.speak.create(
      text='Summary of Smith v. Hospital: The plaintiff alleges medical '
           'malpractice during a surgical procedure on March 15, 2024...',
      voice_id='EXAVITQu4vr4xnSDxMaL'
  )
  ```

  ```go title="Go" theme={"theme":{"light":"github-light","dark":"one-dark-pro"}}
  resp, _ := client.Voice.V1.Speak.New(ctx, casedev.VoiceV1SpeakNewParams{
  	Text:    casedev.F("Summary of Smith v. Hospital: The plaintiff alleges medical malpractice during a surgical procedure on March 15, 2024..."),
  	VoiceID: casedev.F("EXAVITQu4vr4xnSDxMaL"),
  })
  // resp is *http.Response with audio stream
  ```
</CodeGroup>

<Info>
  The `casedev` CLI does not yet expose a text-to-speech command — use cURL or an SDK. You can still browse the voice catalog with `casedev voice:v1 list-voices`.
</Info>

### Multilingual

<CodeGroup>
  ```typescript title="Typescript" theme={"theme":{"light":"github-light","dark":"one-dark-pro"}}
  const audio = await client.voice.v1.speak.create({
    text: 'El tribunal falla a favor del demandante.',
    language_code: 'es'
  });
  ```

  ```python title="Python" theme={"theme":{"light":"github-light","dark":"one-dark-pro"}}
  audio = client.voice.v1.speak.create(
      text='El tribunal falla a favor del demandante.',
      language_code='es'
  )
  ```

  ```go title="Go" theme={"theme":{"light":"github-light","dark":"one-dark-pro"}}
  resp, _ := client.Voice.V1.Speak.New(ctx, casedev.VoiceV1SpeakNewParams{
  	Text:     casedev.F("El tribunal falla a favor del demandante."),
  	ModelID:  casedev.F(casedev.VoiceV1SpeakNewParamsModelIDElevenMultilingualV2),
  })
  // resp is *http.Response with audio stream
  ```
</CodeGroup>

<Info>
  **Pricing:** $0.30 per 1,000 characters. A 5,000 character document costs $1.50.
</Info>
