# Creating a new asset

Creating an asset is the first step to dubbing your video with Panjaya Dubbing Studio.
This endpoint allows you to:

- Upload a source video
- Configure the necessary parameters to initiate the dubbing process

### Uploading the Source Video

- Use the media_url parameter to specify the publicly accessible URL of the source video you want to dub.
- Set the locale field to indicate the original language of the source video.
- It is recommended to set the speakers_count field to the number of distinct speakers in the video, to improve
accuracy and quality of the final video.

### Adding Target Languages

Define the languages into which you want to dub the video:

Panjaya's locale codes adhere to the IETF Language Tag standard, combining ISO 639-1 language codes and ISO 3166-1 country codes. Examples: en-US (English - United States), es-ES (Spanish - Spain), zh-CN (Chinese - China).

For each target language, you may optionally provide a valid SRT file, where applicable, in the designated srt field.

### Trimming the Video

You can optionally use the start_time and end_time parameters to trim your video, allowing you to dub a specific
section of your video.

Both parameters accept a number of seconds from the beginning of the video. For example, if you want to dub only the
first 2 minutes of your video, set end_time to 120.

If not specified, start_time defaults to 0 (beginning of the video), and end_time defaults to the end of the video.


### Status Updates via Callbacks

Optionally, you can configure a callback_url to receive real-time status updates about the dubbing process.

When a callback_url is specified, Panjaya will send updates whenever the status of an asset or any of its dubbing versions changes.

For detailed information on implementing callbacks, refer to the Callbacks section of this documentation.

### Models

The lips_model field specifies which lips model to use when generating versions under this asset.
This parameter is only applicable when lip correction is enabled. You can use it to fine-tune the balance between quality and performance.
* real_face (Default): Our highest-quality lips model, suitable for most use cases.
* real_face_turbo: Optimized for speed - up to 4× faster than real_face, while maintaining high quality.

### Voice-over

By default, Panjaya replaces the original speech with the dubbed vocals. With voice-over enabled, the original audio is instead
ducked (lowered in volume) and the dubbed vocals are delayed and mixed on top of it, preserving the original speaker's voice underneath.

To enable voice-over, set voice_over to true and voice_library_id to the id of the library voice that should narrate the asset
(list available voices with the GET /voices endpoint). Voice-over applies to the whole asset — every target language is narrated by
that voice.

Voice-over cannot be combined with lip correction: a request that enables voice-over together with synthesized lips (auto_generate=with_lips) is rejected.

### Voice Anonymization

The voice_anonymization field allows you to control the degree of voice anonymization applied to the dubbed voices. This is a float between 0.0 (no anonymization, default) and 1.0 (maximum anonymization).
This feature is useful for privacy or compliance requirements, or when you want to mask the original speaker's identity.

- 0.0: No anonymization. The cloned voice will closely match the original speaker.
- 1.0: Maximum anonymization. The voice will sound very different from the original.
- Any value between 0.0 and 1.0 will apply a proportional level of anonymization.

### Background Audio
Panjaya uses our SceneAware audio separation model
to separate speech from background audio in the source video.
This preserves the original background audio in the dubbed result, creating a more natural and immersive experience.

If you have a clean background audio track (e.g., music and sound effects without speech), you can provide a publicly accessible URL to it
via the background_url field. Panjaya will then use this track directly instead of separating background audio from the source video.

If you have a clean speech audio track, you can provide a publicly accessible URL to it via the speech_url field.
Panjaya will then use this track directly instead of separating speech audio from the source video.

Endpoint: POST /v1/assets/
Security: api_key

## Request fields (application/json):

  - `name` (string, required)
    Display name of the dubbing project. Must not be empty. Names exceeding 255 characters will be automatically truncated.

  - `locale` (string, required)
    A locale code of [a supported locale](#section/Languages-support). If the locale is not supported, an error response of status 400 will be returned.

  - `languages` (array, required)
    List of languages to translate and dub the asset to

  - `languages.locale` (string, required)
    A locale code of [a supported locale](#section/Languages-support). If the locale is not supported, an error response of status 400 will be returned.

  - `languages.srt` (any)
    Optional reference SRT file contents.  Must be in a [valid SRT file format](https://docs.fileformat.com/video/srt/), otherwise, an error response of status 400 will be returned.

  - `callback_url` (any)

  - `speakers_count` (any)
    Number of speakers in the source video. If not specified, Panjaya will attempt to automatically detect the number of speakers in the video.

  - `start_time` (any)
    Trim the source video from this time (in seconds). Must be within the video's total duration, otherwise, the asset will fail with an error code of invalid_input. Defaults to the start of the video.

  - `end_time` (any)
    Trim the source video to this time (in seconds). Must be greater than start_time, if provided, and within the video's total duration, otherwise, the asset will fail with an error code of invalid_input. Defaults to the end of the video.

  - `auto_generate` (string)
    If specified, Panjaya will generate the result video automatically, with or without synthesized lips according to the parameter's value. If not specified, Panjaya will not generate the result video automatically.
    Enum: "off", "with_lips", "no_lips"

  - `source_srt` (any)
    Optional reference SRT file contents. Recommended to be in a [valid SRT file format](https://docs.fileformat.com/video/srt/), but other textual formats are also accepted.

  - `lips_model` (any)

  - `voice_anonymization` (number)
    The degree of voice anonymization to apply, as a float between 0.0 (no anonymization, default) and 1.0 (maximum anonymization).

  - `voice_over` (boolean)
    Enable voice-over for the asset: instead of replacing the original speech, the original audio is ducked and the dubbed vocals are delayed and mixed on top. Requires voice_library_id, and cannot be combined with synthesized lips (auto_generate=with_lips).

  - `voice_library_id` (any)
    The library voice that narrates the asset when voice_over is enabled (list available voices with the GET /voices endpoint). Required when voice_over is true.

  - `media_url` (string, required)
    Public URL (can be temporary) of the source video

  - `background_url` (any)

  - `speech_url` (any)

## Response 201 fields (application/json):

  - `asset_id` (string, required)

  - `name` (string, required)

  - `locale` (string, required)
    A locale code of [a supported locale](#section/Languages-support). If the locale is not supported, an error response of status 400 will be returned.

  - `created_at` (string, required)

  - `status` (string, required)
    Enum: "Dubbing", "PendingReview", "Ready", "Failed"

  - `duration` (any, required)
    Duration of the source video in seconds. The field may be null while the asset is processing.

  - `error` (any)
    - `error_code` (any, required)
      If the asset's status is Failed, this field will contain additional error information.

Common error codes for assets are: 
- invalid_input: The input provided is invalid. Ensure all provided fields match the asset's properties.
- unsupported_media: We didnt find a valid video stream in the media file.
- empty_transcript: No spoken content was identified in the uploaded video.
- missing_audio_track: No audio tracks were found in the source video.
- video_duration_limit_reached: The video duration limit for your account has been reached.
- video_size_limit_reached: The file size of the requested video has exceeded the allowed size limit.
- time_out_of_range: The provided start_time or end_time is out of video range. Ensure that the timestamps are within the video duration.
- voice_over_library_required: Voice-over is enabled but no voice_library_id was provided. Set voice_library_id to the library voice that should narrate the asset (list available voices with the GET /voices endpoint).
- voice_over_with_lips_not_allowed: Voice-over cannot be combined with lip correction. Set auto_generate to no_lips (or off) when voice_over is enabled.
    - `detail` (string, required)

  - `source_video_url` (any)

  - `languages` (array, required)

  - `languages.dubbing_id` (any, required)

  - `languages.locale` (string, required)
    A locale code of [a supported locale](#section/Languages-support). If the locale is not supported, an error response of status 400 will be returned.

  - `languages.versions` (array, required)

  - `languages.versions.version_id` (string, required)

  - `languages.versions.voice_over` (boolean)
    Whether this version was created with voice-over enabled.

## Response 400 fields (application/json):

  - `detail` (string, required)
    A full description of the error.


