Python SDK
Install the package:
pip install resemble
Configure the SDK:
from resemble import ResembleResemble.api_key("YOUR_API_TOKEN")
Projects
List All Projects
page = 1page_size = 10response = Resemble.v2.projects.all(page, page_size)projects = response['items']
Get a Project
project_uuid = '<project_uuid>'response = Resemble.v2.projects.get(project_uuid)project = response['item']
Create a Project
name = 'My project'description = 'My description'is_archived = Falseis_collaborative = Falseresponse = Resemble.v2.projects.create(name, description, is_collaborative, is_archived)project = response['item']
Update a Project
project_uuid = '<project_uuid>'name = 'My project (archived)'description = 'My description (this project has been archived)'is_archived = Trueis_collaborative = Falseresponse = Resemble.v2.projects.update(project_uuid, name, description, is_collaborative, is_archived)project = response['item']
Delete a Project
project_uuid = '<project_uuid>'response = Resemble.v2.projects.delete(project_uuid)
Voices
List All Voices
page = 1page_size = 10response = Resemble.v2.voices.all(page, page_size)voices = response['items']
Get a Voice
voice_uuid = '<voice_uuid>'response = Resemble.v2.voices.get(voice_uuid)voice = response['item']
Create a Voice
name = 'Test Voice'response = Resemble.v2.voices.create(name,dataset_url="https://example.com/dataset.zip",callback_uri="http://example.com/cb",language="en-US")voice = response['item']
Build a Voice
voice_uuid = '<voice_uuid>'response = Resemble.v2.voices.build(voice_uuid)
Delete a Voice
voice_uuid = '<voice_uuid>'response = Resemble.v2.voices.delete(voice_uuid)
Recordings
List All Recordings
voice_uuid = '<voice_uuid>'page = 1page_size = 10response = Resemble.v2.recordings.all(voice_uuid, page, page_size)recordings = response['items']
Get a Recording
voice_uuid = '<voice_uuid>'recording_uuid = '<recording_uuid>'response = Resemble.v2.recordings.get(voice_uuid, recording_uuid)recording = response['item']
Create a Recording
voice_uuid = '<voice_uuid>'name = 'recording'text = 'This is a test'is_active = Trueemotion = '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
voice_uuid = '<voice_uuid>'recording_uuid = '<uuid>'name = 'recording'text = 'This is a test'is_active = Trueemotion = 'neutral'response = Resemble.v2.recordings.update(voice_uuid, recording_uuid, name, text, is_active, emotion)recording = response['item']
Delete a Recording
voice_uuid = '<voice_uuid>'recording_uuid = '<recording_uuid>'response = Resemble.v2.recordings.delete(voice_uuid, recording_uuid)
Clips
List All Clips
project_uuid = '<project_uuid>'page = 1page_size = 10response = Resemble.v2.clips.all(project_uuid, page, page_size)clips = response['items']
Get a Clip
project_uuid = '<project_uuid>'clip_uuid = '<clip_uuid>'response = Resemble.v2.clips.get(project_uuid, clip_uuid)clip = response['item']
Create a Clip (Synchronous)
response = Resemble.v2.clips.create_sync(project_uuid,voice_uuid,"Welcome to Resemble",title="Intro")if response["success"]:clip = response["item"]print(clip["audio_src"])else:print(response)
Create a Clip (Direct Synthesis)
voice_uuid = '<voice_uuid>'project_uuid = '<project_uuid>'output_format = 'wav'data = 'Hello, how are you?'title = 'Greeting'precision = 'PCM_32'sample_rate = 48000response = Resemble.v2.clips.create_direct(project_uuid,voice_uuid,data,title,precision,output_format,sample_rate)clip = response['audio_content']
Stream a Clip
# Configure synthesis URL for streamingResemble.api_key('YOUR_API_TOKEN')Resemble.syn_server_url('<syn_server_url>') # Obtain from https://app.resemble.ai/account/apiproject_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):# chunk is a byte array of shorts (int 16) representing WAV audio# Process the audio chunk herepassexcept Exception as e:# Handle exceptionsprint(f"Error: {e}")
Update a Clip (Async)
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']
Delete a Clip
project_uuid = '<project_uuid>'clip_uuid = '<clip_uuid>'response = Resemble.v2.clips.delete(project_uuid, clip_uuid)
Term Substitutions
List All Term Substitutions
page = 1page_size = 10response = Resemble.v2.term_substitutions.all(page, page_size)substitutions = response['items']
Create a Term Substitution
response = Resemble.v2.term_substitutions.create('Original', 'Replacement')substitutions = response['items']
Delete a Term Substitution
substitution_uuid = '...'response = Resemble.v2.term_substitutions.delete(substitution_uuid)
Deepfake Detection
Create a Detection
media_url = "https://example.com/sample-video.mp4"response = Resemble.v2.deepfake_detection.detect(url=media_url)if response["success"]:detection_uuid = response["item"]["uuid"]status = response["item"]["status"]
Get a Detection Result
import timedetection_uuid = "<detection_uuid>"max_attempts = 10wait_time_seconds = 3for _ in range(max_attempts):response = Resemble.v2.deepfake_detection.get(detection_uuid)status = response.get("item", {}).get("status")if status in ("completed", "failed"):breaktime.sleep(wait_time_seconds)
Create and Get a Detection (URL)
import jsonmedia_url = "https://example.com/sample-audio.wav"response = Resemble.v2.deepfake_detection.detect_and_get(url=media_url,audio_source_tracing=True,intelligence=True,use_ood_detector=True,)# Full API responseprint(json.dumps(response, indent=2))# Parsed valuesresult = response.get("item", {})status = response.get("item", {}).get("status")
Create and Get a Detection (File Upload)
import jsonfile_path = "path/to/local-audio.wav"with open(file_path, "rb") as file:response = Resemble.v2.deepfake_detection.detect_and_get(file=file,audio_source_tracing=True,intelligence=True,use_ood_detector=True,)# Full API responseprint(json.dumps(response, indent=2))# Parsed valuesresult = response.get("item", {})status = response.get("item", {}).get("status")
Additional Resources
- Creating Clips Guide - Step-by-step tutorial
- WebSocket Streaming Guide - Real-time audio streaming
- GitHub Examples - Sample code and projects
