Create a voice
This endpoint allows the programmatic creation of new voices. There are three steps involved in the process of creating a new Voice programmatically.
POST
request tohttps://app.resemble.ai/api/v1/voices
to retrieve a signed URL.PUT
request to the URL returned in step 1 with the headers sent by the request from step 1.POST
request tohttps://app.resemble.ai/api/v1/voices/build
with the voice uuid from step 1.
Create voice API is only available for Business plan users. If you're running into trouble, upgrade to a Business plan or higher on the billing page.
Step 1
For step 1, you'll need to make a request to https://app.resemble.ai/api/v1/voices
with a JSON blob that includes name
for the voice name, filename
for the name of the file you're uploading, byte_size
, and the MD5 checksum. Only audio/x-wav
files are accepted at the moment.
HTTP Request
POST https://app.resemble.ai/api/v1/voices
JSON Body Parameter | Required | Description |
---|---|---|
name | Yes | Any identifiable name for the voice you're creating. |
filename | Yes | The name of the file you're uploading. |
byte_size | Yes | The size of the file in bytes. |
checksum | Yes | The MD5 checksum of the file. (You can use the md5 prorgam on OS X and Linux) |
content-type | No | The content type. Valid options are audio/x-wav , application/gzip , application/tar , or application/x-tar The default is audio/x-wav . |
callback_uri | No | The callback for when the voice is ready. A POST request sent back to the uri. |
HTTP Response
{
"url": "Signed URL",
"headers": {
"Content-Type": "audio/x-wav",
"Content-MD5": "FILE_MD5"
},
"voice": "Voice UUID"
}
Examples
cURL
curl --request POST 'https://app.resemble.ai/api/v1/voices' \
-H 'Authorization: Token token=YOUR_API_TOKEN' \
-H 'Content-Type: application/json' \
--data-raw '{
"filename": "YOURFILE.wav",
"byte_size": 78183182,
"checksum": "ce1231231231231231",
"content_type": "audio/x-wav",
"name": "<NAME OF YOUR VOICE>"
}'
Python
import requests
import hashlib
import os
def md5(fname):
hash_md5 = hashlib.md5()
with open(fname, "rb") as f:
for chunk in iter(lambda: f.read(4096), b""):
hash_md5.update(chunk)
return hash_md5.hexdigest()
url = "https://app.resemble.ai/api/v1/voices"
headers = {
'Authorization': 'Token token=YOUR_API_TOKEN',
'Content-Type': 'application/json'
}
filename = "YOURFILE.wav"
data = {
"filename": filename,
"byte_size": os.path.getsize(filename),
"checksum": md5(filename),
"content-type": "audio/x-wav",
"name": "<NAME OF YOUR VOICE>"
}
response = requests.post(url, headers=headers, json=data)
Step 2
For step 2, you'll make a PUT
request to the signed URL from step 1. Include all of the headers that were returned in step 1 as the headers here.
HTTP Request
PUT <signed URL from step 1>
Include all of the headers that were returned in step 1 as the headers for this request.
HTTP Response
You'll receive a 2XX or 3XX http status code response which indicates that the file was successfully uploaded.
Examples
cURL
curl --request PUT 'URL_FROM_STEP_1' \
--header 'Content-Type: audio/x-wav' \
--header 'Content-MD5: <CONTENT-MD5 FROM STEP 1>' \
--header 'Content-Length: <CONTENT-LENGTH FROM STEP 1>' \
--data-binary '@/path/to/your/file'
Python
import requests
url = "<URL_FROM_STEP_1>"
headers = {
'Content-MD5': '<CONTENT-MD5 FROM STEP 1>',
'Content-Length': '<CONTENT-LENGTH FROM STEP 1>',
'Content-Type': 'audio/x-wav'
}
filename = "YOURFILE.wav"
data = open(filename, 'rb').read()
response = requests.put(url, headers=headers, data=data)
Step 3
For step 3, you'll trigger a build by making a POST request to https://app.resemble.ai/api/v1/voices/build
. As a parameter, pass in the voice UUID. Once the voice has finished building, you'll receive a POST request at the callback_uri
provided in Step 2.
HTTP Request
POST https://app.resemble.ai/api/v1/voices/build
JSON Body Parameter | Description |
---|---|
voice | The Voice UUID. |
HTTP Response
{
"voice": "VOICE UUID",
"status": "OK"
}
Examples
cURL
curl --request POST 'https://app.resemble.ai/api/v1/voices/build' \
-H 'Authorization: Token token=YOUR_API_TOKEN' \
-H 'Content-Type: application/json' \
--data-raw '{
"voice": "VOICE UUID"
}'
Python
import requests
url = "https://app.resemble.ai/api/v1/voices/build"
headers = {
'Authorization': 'Token token=YOUR_API_TOKEN',
'Content-Type': 'application/json'
}
data = {
'voice': "<voice_uuid>"
}
response = requests.post(url, headers=headers, json=data)