# Translate audio

Translate and dub the spoken audio of a video into another language with the Mux Robots API. Use dubbed audio to reach viewers in more languages.

Translate the spoken audio of a Mux asset into another language and automatically attach the result as a new audio track, so viewers can switch languages from the player's audio menu. Where [translate captions](/docs/guides/robots-translate-captions) produces a text track in another language, `translate-audio` produces a dubbed audio track. See the <ApiRefLink href="/docs/api-reference/robots/translate-audio">Translate Audio API reference</ApiRefLink> for the full endpoint specification. See [Mux Robots pricing](/docs/pricing/overview#mux-robots-pricing) for unit costs.

<Callout type="info">
  Audio translation requires an asset with an audio track. A `translate-audio` job is rejected if the asset has no audio, or if an audio track for the target language already exists.
</Callout>

## Create a `translate-audio` job

```bash
curl https://api.mux.com/robots/v0/jobs/translate-audio \
  -H "Content-Type: application/json" \
  -X POST \
  -d '{
    "parameters": {
      "asset_id": "YOUR_ASSET_ID",
      "to_language_code": "es"
    }
  }' \
  -u ${MUX_TOKEN_ID}:${MUX_TOKEN_SECRET}
```

<Callout type="info">
  This request is **asynchronous**. The `POST` returns immediately with the job in `pending` status and does not include results. **We strongly recommend listening for the [`robots.job.translate_audio.completed` webhook](/docs/guides/robots#webhooks):** the payload contains the full completed job, so no follow-up API call is needed. If webhooks aren't an option, you can poll `GET /robots/v0/jobs/translate-audio/{JOB_ID}` with the `id` from the response until the status is `completed`.
</Callout>

## Parameters

| Parameter | Type | Description |
| :-- | :-- | :-- |
| `asset_id` | string | **Required.** The Mux asset ID whose audio will be translated. |
| `to_language_code` | string | **Required.** BCP 47 target language code (e.g. `es`, `fr`, `ja`). See [language support for Mux Robots](/docs/guides/robots-supported-languages). |
| `upload_to_mux` | boolean | Whether to upload the dubbed audio and attach it as a new audio track on the asset. Defaults to `true`. |

## Output

The `outputs` object is included in the job once its status is `completed`. You'll receive it on the [`robots.job.translate_audio.completed`](/docs/guides/robots#webhooks) webhook (recommended), or you can fetch it with `GET /robots/v0/jobs/translate-audio/{JOB_ID}`. It contains:

| Field | Type | Description |
| :-- | :-- | :-- |
| `uploaded_track_id` | string | Mux audio track ID of the uploaded dubbed track. Present when `upload_to_mux` is `true`. |
| `temporary_audio_url` | string | Temporary pre-signed URL to download the dubbed audio file. Expires 7 days after the job completes. |

## Example response

This is the payload delivered to the [`robots.job.translate_audio.completed`](/docs/guides/robots#webhooks) webhook, and the same shape you get from `GET /robots/v0/jobs/translate-audio/{JOB_ID}`:

```json
{
  "data": {
    "id": "rjob_vwx234",
    "workflow": "translate-audio",
    "status": "completed",
    "units_consumed": 4500,
    "parameters": {
      "asset_id": "YOUR_ASSET_ID",
      "to_language_code": "es",
      "upload_to_mux": true
    },
    "outputs": {
      "uploaded_track_id": "track_es_abc123",
      "temporary_audio_url": "https://storage.googleapis.com/..."
    }
  }
}
```

<Callout type="info">
  When `upload_to_mux` is `true` (the default), the dubbed audio is attached to your asset as a new audio track. Viewers can select the new language from the player's audio menu. See [add alternate audio tracks](/docs/guides/add-alternate-audio-tracks-to-your-videos) for more on multi-language audio.
</Callout>
