# Lux TTS

> High-quality voice cloning TTS model that generates 48kHz speech from text and a reference audio. Distilled to 4 steps for fast inference.


## Overview

- **Endpoint**: `https://fal.run/fal-ai/lux-tts`
- **Model ID**: `fal-ai/lux-tts`
- **Category**: text-to-speech
- **Kind**: inference
**Tags**: tts, voice-cloning, speech-synthesis



## Pricing

- **Price**: $0.0014 per 1000 characters

For more details, see [fal.ai pricing](https://fal.ai/pricing).

## API Information

This model can be used via our HTTP API or more conveniently via our client libraries.
See the input and output schema below, as well as the usage examples.


### Input Schema

The API accepts the following input parameters:


- **`prompt`** (`string`, _required_):
  The text to be converted to speech.
  - Examples: "Hey, what's up? I'm feeling really great today! The sun is shining and there's a gentle breeze rustling through the trees."

- **`audio_url`** (`string`, _required_):
  URL of the reference audio file for voice cloning. The model will mimic the voice characteristics from this audio.
  - Examples: "https://storage.googleapis.com/falserverless/example_inputs/reference_audio.wav"

- **`num_inference_steps`** (`integer`, _optional_):
  Number of flow-matching inference steps. 4 is recommended for best efficiency. Default value: `4`
  - Default: `4`
  - Range: `1` to `16`

- **`max_ref_length`** (`float`, _optional_):
  Maximum length of the reference audio to use for voice encoding, in seconds. Longer durations capture more voice characteristics but increase processing time. Default value: `5`
  - Default: `5`
  - Range: `1` to `15`

- **`guidance_scale`** (`float`, _optional_):
  Classifier-free guidance scale. Higher values increase adherence to the reference voice at the cost of diversity. Default value: `3`
  - Default: `3`
  - Range: `0` to `10`

- **`seed`** (`integer`, _optional_):
  Random seed for reproducibility.



**Required Parameters Example**:

```json
{
  "prompt": "Hey, what's up? I'm feeling really great today! The sun is shining and there's a gentle breeze rustling through the trees.",
  "audio_url": "https://storage.googleapis.com/falserverless/example_inputs/reference_audio.wav"
}
```

**Full Example**:

```json
{
  "prompt": "Hey, what's up? I'm feeling really great today! The sun is shining and there's a gentle breeze rustling through the trees.",
  "audio_url": "https://storage.googleapis.com/falserverless/example_inputs/reference_audio.wav",
  "num_inference_steps": 4,
  "max_ref_length": 5,
  "guidance_scale": 3
}
```


### Output Schema

The API returns the following output format:

- **`audio`** (`File`, _required_):
  The generated speech audio file at 48kHz.

- **`seed`** (`integer`, _required_)

- **`timings`** (`Timings`, _required_)



**Example Response**:

```json
{
  "audio": {
    "url": "",
    "content_type": "image/png",
    "file_name": "z9RV14K95DvU.png",
    "file_size": 4404019
  }
}
```


## Usage Examples

### cURL

```bash
curl --request POST \
  --url https://fal.run/fal-ai/lux-tts \
  --header "Authorization: Key $FAL_KEY" \
  --header "Content-Type: application/json" \
  --data '{
     "prompt": "Hey, what's up? I'm feeling really great today! The sun is shining and there's a gentle breeze rustling through the trees.",
     "audio_url": "https://storage.googleapis.com/falserverless/example_inputs/reference_audio.wav"
   }'
```

### Python

Ensure you have the Python client installed:

```bash
pip install fal-client
```

Then use the API client to make requests:

```python
import fal_client

def on_queue_update(update):
    if isinstance(update, fal_client.InProgress):
        for log in update.logs:
           print(log["message"])

result = fal_client.subscribe(
    "fal-ai/lux-tts",
    arguments={
        "prompt": "Hey, what's up? I'm feeling really great today! The sun is shining and there's a gentle breeze rustling through the trees.",
        "audio_url": "https://storage.googleapis.com/falserverless/example_inputs/reference_audio.wav"
    },
    with_logs=True,
    on_queue_update=on_queue_update,
)
print(result)
```

### JavaScript

Ensure you have the JavaScript client installed:

```bash
npm install --save @fal-ai/client
```

Then use the API client to make requests:

```javascript
import { fal } from "@fal-ai/client";

const result = await fal.subscribe("fal-ai/lux-tts", {
  input: {
    prompt: "Hey, what's up? I'm feeling really great today! The sun is shining and there's a gentle breeze rustling through the trees.",
    audio_url: "https://storage.googleapis.com/falserverless/example_inputs/reference_audio.wav"
  },
  logs: true,
  onQueueUpdate: (update) => {
    if (update.status === "IN_PROGRESS") {
      update.logs.map((log) => log.message).forEach(console.log);
    }
  },
});
console.log(result.data);
console.log(result.requestId);
```


## Additional Resources

### Documentation

- [Model Playground](https://fal.ai/models/fal-ai/lux-tts)
- [API Documentation](https://fal.ai/models/fal-ai/lux-tts/api)
- [OpenAPI Schema](https://fal.ai/api/openapi/queue/openapi.json?endpoint_id=fal-ai/lux-tts)

### fal.ai Platform

- [Platform Documentation](https://docs.fal.ai)
- [Python Client](https://docs.fal.ai/clients/python)
- [JavaScript Client](https://docs.fal.ai/clients/javascript)
