> ## Documentation Index
> Fetch the complete documentation index at: https://60db.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Text to Speech

> Convert text to natural-sounding speech

## Request

### Headers

<ParamField header="Authorization" type="string" required>
  Bearer token with your API key
</ParamField>

<ParamField header="Content-Type" type="string" required>
  application/json
</ParamField>

### Body

<ParamField body="text" type="string" required>
  The text to convert to speech (max 5000 characters)
</ParamField>

<ParamField body="voice_id" type="string">
  ID of the voice to use (default: system default voice)
</ParamField>

<ParamField body="voice" type="string">
  Alternative way to specify voice name
</ParamField>

<ParamField body="enhance" type="boolean" default="true">
  Enable audio enhancement for better quality
</ParamField>

<ParamField body="speed" type="number" default="1.0">
  Speech speed multiplier (0.5 to 2.0)
</ParamField>

<ParamField body="pitch" type="number" default="1.0">
  Voice pitch multiplier (0.5 to 2.0)
</ParamField>

<ParamField body="output_format" type="string" default="mp3">
  Audio output format: mp3, wav, ogg, flac
</ParamField>

## Response

<ResponseField name="success" type="boolean">
  Indicates if the request was successful
</ResponseField>

<ResponseField name="message" type="string">
  Status message
</ResponseField>

<ResponseField name="audio_base64" type="string">
  Base64-encoded audio data
</ResponseField>

<ResponseField name="sample_rate" type="number">
  Audio sample rate in Hz
</ResponseField>

<ResponseField name="duration_seconds" type="number">
  Duration of the audio in seconds
</ResponseField>

<ResponseField name="encoding" type="string">
  Audio encoding format
</ResponseField>

<ResponseField name="output_format" type="string">
  Audio output format
</ResponseField>

<RequestExample>
  ```bash cURL theme={null}
  curl -X POST https://api.60db.ai/tts-synthesize \
    -H "Authorization: Bearer your-api-key" \
    -H "Content-Type: application/json" \
    -d '{
      "text": "Hello, world! This is a test of the text to speech API.",
      "voice_id": "default-voice",
      "enhance": true,
      "speed": 1.0
    }'
  ```

  ```javascript JavaScript theme={null}
  import { SixtyDBClient } from "60db";

  const client = new SixtyDBClient("your-api-key");

  const audio = await client.textToSpeech({
    text: "Hello, world! This is a test of the text to speech API.",
    voice_id: "default-voice",
    enhance: true,
    speed: 1.0,
  });

  // audio is an ArrayBuffer
  ```

  ```python Python theme={null}
  from sixtydb import SixtyDBClient

  client = SixtyDBClient('your-api-key')

  audio = client.text_to_speech(
      text='Hello, world! This is a test of the text to speech API.',
      voice_id='default-voice',
      enhance=True,
      speed=1.0
  )

  # Save to file
  with open('output.mp3', 'wb') as f:
      f.write(audio)
  ```
</RequestExample>

<ResponseExample>
  ```json Response theme={null}
  {
    "success": true,
    "message": "Audio generated successfully",
    "audio_base64": "SUQzBAAAAAAAI1RTU0UAAAAPAAADTGF2ZjU4Ljc2LjEwMAAAAAAAAAAAAAAA...",
    "sample_rate": 24000,
    "duration_seconds": 3.5,
    "encoding": "mp3",
    "output_format": "mp3"
  }
  ```
</ResponseExample>
