# Generate cloned speech

- **Method:** `POST`
- **Path:** `/api/v1/generation/clone`
- **Operation ID:** `start_clone_api_v1_generation_clone_post`
- **Tags:** Clone

Clone a voice from reference audio or a saved voice ID.

Provide `ref_audio_base64` with a 3-15 second WAV clip of clear speech,
plus `ref_text` (the transcript of that audio) for best quality.
Alternatively, provide a `voice_id` from the voice library — the saved
audio is used automatically, and `ref_audio_base64` can be omitted.

Use `?sync=true` to block until audio is ready (up to 600s).
Otherwise, poll `GET /api/v1/generation/progress` and `GET /api/v1/generation/result`.

## Effective servers

- `http://127.0.0.1:8100`

  Voice Creator Pro on this computer

## Query parameters

- **`sync`**: `boolean`, default: `false`

  Wait for generation to complete and return audio directly

## Request body

**Required:** `true`

**Content type:** `application/json`

schema: `CloneRequest`

- **`target_text` (required)**: `string`

  Text to generate speech for
- **`emotion`**: `string | null`

  Emotion to apply. If set and not 'neutral', uses emotional clone. Query GET /api/v1/models/active for supported emotions.
- **`generation_params`**: `object | null`, schema: `GenerationParamsModel`

  Advanced sampling parameters
  - **`seed`**: `integer | null`

    Random seed for reproducible generation
- **`intensity`**: `string | null`

  Emotion intensity (very\_mild/mild/normal/strong/extreme). Defaults to 'normal' when emotion is set.
- **`language`**: `string`, default: `"Auto"`

  Target language. Query GET /api/v1/models/active for supported languages per variant.
- **`model_family`**: `string | null`

  TTS model to use. If omitted, uses the currently configured model. Triggers auto-load if needed.
- **`quality`**: `string | null`

  Quality/variant tier. Query GET /api/v1/models/active for available tiers.
- **`ref_audio_base64`**: `string | null`

  Base64-encoded reference audio (WAV). Optional if voice\_id is provided.
- **`ref_text`**: `string`, default: `""`

  Transcript of the reference audio
- **`voice_id`**: `string | null`

  Voice ID for prompt caching. If provided, saved audio is used as fallback when ref\_audio\_base64 is omitted.

**Example:**

```json
{
  "ref_audio_base64": "UklGRi4AAABXQVZFZm10IBAAAA...",
  "ref_text": "Hello, this is a sample of my voice.",
  "target_text": "Welcome to the voice cloning demo.",
  "language": "English",
  "voice_id": "a1b2c3d4",
  "quality": "higher_quality",
  "generation_params": {
    "seed": 42,
    "additionalProperty": "anything"
  },
  "model_family": "qwen3-tts",
  "emotion": "angry",
  "intensity": "normal"
}
```

## Responses

### 200 Generation started (async) or completed result (sync).

**Content type:** `application/json`

**Any of:**

- `object`, schema: `GenerationStartedResponse`
  - **`queue_position` (required)**: `integer`

    Position in the generation queue (0 = next to run)
  - **`started` (required)**: `boolean`

    Whether the generation job was enqueued
- `object`, schema: `GenerationResult`
  - **`status` (required)**: `string`

    Human-readable status message
  - **`success` (required)**: `boolean`

    Whether generation completed successfully
  - **`audio_base64`**: `string | null`

    Base64-encoded audio output (WAV format)
  - **`error_code`**: `string | null`

    Machine-readable failure code when success is false
  - **`error_detail`**: `string | null`

    Extra detail for the failure code

**One of:**

- *Schema `GenerationStartedResponse` is shown above.*
- *Schema `GenerationResult` is shown above.*

**Example:**

```json
{
  "started": true,
  "queue_position": 0
}
```

### 400 Invalid voice\_id format.

### 422 Validation Error

**Content type:** `application/json`

schema: `HTTPValidationError`

- **`detail`**: `array`

  **Items:**

  schema: `ValidationError`
  - **`loc` (required)**: `array of (string | integer)`
  - **`msg` (required)**: `string`
  - **`type` (required)**: `string`
  - **`ctx`**: `object`
  - **`input`**: `any`

**Example:**

```json
{
  "detail": [
    {
      "loc": [
        ""
      ],
      "msg": "",
      "type": "",
      "input": null,
      "ctx": {}
    }
  ]
}
```

### 504 Sync generation timed out (600s limit).

## Schemas

- `CloneRequest` — shown above.
- `GenerationParamsModel` — shown above.
- `GenerationResult` — shown above.
- `GenerationStartedResponse` — shown above.
- `HTTPValidationError` — shown above.
- `ValidationError` — shown above.
