Python
Install
pip install resemble
Usage
Authentication
Before using the library, set your api key.
1
2
3
from resemble import Resemble
Resemble.api_key('YOUR_API_TOKEN')
Projects
Get all projects
1
2
3
4
5
6
7
8
from resemble import Resemble
Resemble.api_key('YOUR_API_TOKEN')
page = 1
page_size = 10
response = Resemble.v2.projects.all(page, page_size)
projects = response['items']
Create a project
1
2
3
4
5
6
7
8
9
10
from resemble import Resemble
Resemble.api_key('YOUR_API_TOKEN')
name = 'My project'
description = 'My description'
is_archived = False
is_collaborative = False
response = Resemble.v2.projects.create(name, description, is_collaborative, is_archived)
project = response['item']
Update a project
1
2
3
4
5
6
7
8
9
10
11
from resemble import Resemble
Resemble.api_key('YOUR_API_TOKEN')
project_uuid = '<project_uuid>'
name = 'My project (archived)'
description = 'My description (this project has been archived)'
is_archived = True
is_collaborative = False
response = Resemble.v2.projects.update(project_uuid, name, description, is_collaborative, is_archived)
project = response['item']
Get a project
1
2
3
4
5
6
7
from resemble import Resemble
Resemble.api_key('YOUR_API_TOKEN')
project_uuid = '<project_uuid>'
response = Resemble.v2.projects.get(project_uuid)
project = response['item']
Delete a project
1
2
3
4
5
6
from resemble import Resemble
Resemble.api_key('YOUR_API_TOKEN')
project_uuid = '<project_uuid>'
response = Resemble.v2.projects.delete(project_uuid)
Voices
Get all voices
1
2
3
4
5
6
7
8
from resemble import Resemble
Resemble.api_key('YOUR_API_TOKEN')
page = 1
page_size = 10
response = Resemble.v2.voices.all(page, page_size)
voices = response['items']
Create a voice
1
2
3
4
5
6
7
from resemble import Resemble
Resemble.api_key('YOUR_API_TOKEN')
name = 'Test Voice'
response = Resemble.v2.voices.create(name, dataset_url="http://../dataset.zip", callback_uri="http://example.com/cb")
voice = response['item']
Build a voice
1
2
3
4
5
6
from resemble import Resemble
Resemble.api_key('YOUR_API_TOKEN')
voice_uuid = '<voice_uuid>'
response = Resemble.v2.voices.build(voice_uuid)
Get a voice
1
2
3
4
5
6
7
from resemble import Resemble
Resemble.api_key('YOUR_API_TOKEN')
voice_uuid = '<voice_uuid>'
response = Resemble.v2.voices.get(voice_uuid)
voice = response['item']
Delete a voice
1
2
3
4
5
6
from resemble import Resemble
Resemble.api_key('YOUR_API_TOKEN')
voice_uuid = '<voice_uuid>'
response = Resemble.v2.voices.delete(voice_uuid)
Recordings
Get all recordings
1
2
3
4
5
6
7
8
9
from resemble import Resemble
Resemble.api_key('YOUR_API_TOKEN')
voice_uuid = '<voice_uuid>'
page = 1
page_size = 10
response = Resemble.v2.recordings.all(voice_uuid, page, page_size)
recordings = response['items']
Create a recording
1
2
3
4
5
6
7
8
9
10
11
12
from resemble import Resemble
Resemble.api_key('YOUR_API_TOKEN')
voice_uuid = '<voice_uuid>'
name = 'recording'
text = 'This is a test'
is_active = True
emotion = 'neutral'
with open("path/to/audio.wav", 'rb') as file:
response = Resemble.v2.recordings.create(voice_uuid, file, name, text, is_active, emotion)
recording = response['item']
Update a recording
1
2
3
4
5
6
7
8
9
10
11
12
from resemble import Resemble
Resemble.api_key('YOUR_API_TOKEN')
voice_uuid = '<voice_uuid>'
recording_uuid = '<uuid>'
name = 'recording'
text = 'This is a test'
is_active = True
emotion = 'neutral'
response = Resemble.v2.recordings.update(voice_uuid, recording_uuid, name, text, is_active, emotion)
recording = response['item']
Get a recording
1
2
3
4
5
6
7
8
from resemble import Resemble
Resemble.api_key('YOUR_API_TOKEN')
voice_uuid = '<voice_uuid>'
recording_uuid = '<recording_uuid>'
response = Resemble.v2.recordings.get(voice_uuid, recording_uuid)
recording = response['item']
Delete a recording
1
2
3
4
5
6
7
from resemble import Resemble
Resemble.api_key('YOUR_API_TOKEN')
voice_uuid = '<voice_uuid>'
recording_uuid = '<recording_uuid>'
response = Resemble.v2.recordings.delete(voice_uuid, recording_uuid)
Clips
Get all clips
1
2
3
4
5
6
7
8
9
from resemble import Resemble
Resemble.api_key('YOUR_API_TOKEN')
project_uuid = '<project_uuid>'
page = 1
page_size = 10
response = Resemble.v2.clips.all(project_uuid, page, page_size)
clips = response['items']
Create a clip (sync)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
from resemble import Resemble
Resemble.api_key('YOUR_API_TOKEN')
project_uuid = '<project_uuid>'
voice_uuid = '<voice_uuid>'
body = 'This is a sync test'
response = Resemble.v2.clips.create_sync(
project_uuid,
voice_uuid,
body,
title=None,
sample_rate=None,
output_format=None,
precision=None,
include_timestamps=None,
is_archived=None,
raw=None
)
clip = response['item']
Create a clip (async)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
from resemble import Resemble
Resemble.api_key('YOUR_API_TOKEN')
project_uuid = '<project_uuid>'
voice_uuid = '<voice_uuid>'
callback_uri = 'https://example.com/callback/resemble-clip'
body = 'This is an async test'
response = Resemble.v2.clips.create_async(
project_uuid,
voice_uuid,
callback_uri,
body,
title=None,
sample_rate=None,
output_format=None,
precision=None,
include_timestamps=None,
is_archived=None
)
clip = response['item']
Create a clip (streaming)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
from resemble import Resemble
Resemble.api_key('YOUR_API_TOKEN')
# It's very important that you configure the resemble library with the syn_server_url. Streaming will not
# work otherwise. You can obtain this URL by contacting resemble.
Resemble.syn_server_url('<syn_server_url>')
project_uuid = '<project_uuid>'
voice_uuid = '<voice_uuid>'
body = 'This is a streaming test'
try:
for chunk in Resemble.v2.clips.stream(project_uuid, voice_uuid, body):
# handle the returned chunk of data contained in the chunk variable
# The chunk variable is a byte array of shorts (int 16) representing a chunk of a WAV audio file.
pass
except:
# handle exceptions
pass
Update a clip (async)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
from resemble import Resemble
Resemble.api_key('YOUR_API_TOKEN')
project_uuid = '<project_uuid>'
clip_uuid = '<clip_uuid>'
voice_uuid = '<voice_uuid>'
callback_uri = 'https://example.com/callback/resemble-clip'
body = 'This is an updated async test'
response = Resemble.v2.clips.update_async(
project_uuid,
clip_uuid,
voice_uuid,
callback_uri,
body,
title=None,
sample_rate=None,
output_format=None,
precision=None,
include_timestamps=None,
is_archived=None
)
clip = response['item']
Get a clip
1
2
3
4
5
6
7
8
from resemble import Resemble
Resemble.api_key('YOUR_API_TOKEN')
project_uuid = '<project_uuid>'
clip_uuid = '<clip_uuid>'
response = Resemble.v2.clips.get(project_uuid, clip_uuid)
clip = response['item']
Delete a clip
1
2
3
4
5
6
7
from resemble import Resemble
Resemble.api_key('YOUR_API_TOKEN')
project_uuid = '<project_uuid>'
clip_uuid = '<clip_uuid>'
response = Resemble.v2.clips.delete(project_uuid, clip_uuid)
Term Substitution
Get all term substitutions
1
2
3
4
5
6
7
8
from resemble import Resemble
Resemble.api_key('YOUR_API_TOKEN')
page = 1
page_size = 10 # optional parameter
response = Resemble.v2.term_substitutions.all(page, page_size)
substitutions = response['items']
Create a term substitution
1
2
3
4
5
6
from resemble import Resemble
Resemble.api_key('YOUR_API_TOKEN')
response = Resemble.v2.term_substitutions.create('Original', 'Replacement')
substitutions = response['items']
Delete a term substitution
1
2
3
4
5
6
7
from resemble import Resemble
Resemble.api_key('YOUR_API_TOKEN')
substitution_uuid = '...'
response = Resemble.v2.term_substitutions.delete(substitution_uuid)