Skip to main content
Version: 1.0.0

Create a new clip (sync)

Creates a new clip synchronously. Given a clip resource that looks like the following, it will return a URL to the generated audio. If raw is set to true, it will return the raw WAV output encoded in base64.

The optional output_format parameter will change the output format of the generated audio. The options are mp3 or wav (default).

The optional audio_timestamps parameter will return a JSON object. It is used to know the time at which a grapheme or phoneme can be heard in the synthesized audio. See Audio Timestamps section for more details.

The optional precision parameter will change the precision (bit depth) of the WAV output. By default, the parameter is set to PCM_32 therefore generating a 32-bit WAV file. A developer can choose from PCM_16, PCM_24, and PCM_32.

// Example of a Clip Resource
// Go to the Clip Resource definition page for a detailed breakdown
{
"title": "title to your clip",
"body": "Some text or SSML that will be transformed into audio.",
"voice": "<voice_uuid>"
}

HTTP Request

POST https://app.resemble.ai/api/v1/projects/<project_uuid>/clips/sync

URL ParameterDescription
project_uuidThe uuid of the project to fetch
JSON Body ParameterDescription
clipA Clip Resource to generate
rawdefault: false. When set to true, returns raw audio.
output_formatOptions: wav (default), mp3
audio_timestampsdefault: false. When set to true, returns Audio Timestamp object.
precisionOnly applies if output_format is wav. Options: PCM_16, PCM_24, PCM_32 (default).

HTTP Response

When raw is true and audio_timestamps is false or not provided, the response will be a base64 encoded audio file in plain text:

UklGRqRVAgBXQVZFZm10...

When raw is true and audio_timestamps is true, the response will be a json object:

{
"data": "<base64 encoded audio>",
"clip_uuid": "<clip uuid>",
"audio_timestamps": {
"graph_chars": <string[]>,
"graph_times": <float[[]]>,
"phon_chars": <string[]>,
"phon_times": <float[[]]>
},
"issues": ["<issues will only be present if there were synthesis issues>"]
}

When raw is false and audio_timestamps is false or not provided, the response will be a url containing the audio file in plain text:

https://app.resemble.ai/.../your-audio.wav

When raw is false and audio_timestamps is true, the response will be a json object:

{
"url": "<url containg audio file>",
"clip_uuid": "<clip uuid>",
"audio_timestamps": {
"graph_chars": <string[]>,
"graph_times": <float[[]]>,
"phon_chars": <string[]>,
"phon_times": <float[[]]>
},
"issues": ["<issues will only be present if there were synthesis issues>"]
}

Examples

Remember

Make sure you replace YOUR_API_TOKEN with your own!

cURL

curl --location --request POST 'https://app.resemble.ai/api/v1/projects/<project_uuid>/clips/sync' \
--header 'Authorization: Bearer YOUR_API_TOKEN' \
--header 'Content-Type: application/json' \
--data-raw '{
"data": {
"body": <text or ssml to synthesize>,
"voice": <voice uuid>,
"title": <title of clip>
},
"audio_timestamps": true,
"raw": false,
"precision": "PCM_16|PCM_24|PCM_32 (default)",
"output_format": "mp3|wav (default)",
}'

Python

import requests

url = "https://app.resemble.ai/api/v1/projects/<project_uuid>/clips/sync"
headers = {
'Authorization': 'Token token=YOUR_API_TOKEN',
'Content-Type': 'application/json'
}
data = {
'data': {
'title': 'Episode 1',
'body': 'Welcome to episode 1! This is everything about curries.',
'voice': '3x4mpl3',
}
}

response = requests.post(url, headers=headers, json=data)