Skip to main content
Version: 2.0.0

Ruby

Install

Add the following line to your Gemfile:

gem 'resemble'

Alternatively, just run bundle add resemble

Usage

Authentication

Before using the library, set your api key.

1 2 3 require 'resemble' Resemble.api_key = 'YOUR_API_TOKEN'

Projects

Get all projects

1 2 3 4 5 6 7 8 require 'resemble' Resemble.api_key = 'YOUR_API_TOKEN' page = 1 page_size = 10 response = Resemble::V2::Project.all(page, page_size) projects = response['items']

Create a project

1 2 3 4 5 6 7 8 9 10 11 require 'resemble' Resemble.api_key = 'YOUR_API_TOKEN' name = 'My project' description = 'My description' is_public = false is_archived = false is_collaborative = false response = Resemble::V2::Project.create(name, description, is_public, is_collaborative, is_archived) project = response['item']

Update a project

1 2 3 4 5 6 7 8 9 10 11 12 require 'resemble' Resemble.api_key = 'YOUR_API_TOKEN' project_uuid = '<project_uuid>' name = 'My project (archived)' description = 'My description (this project has been archived)' is_public = false is_archived = true is_collaborative = false response = Resemble::V2::Project.update(project_uuid, name, description, is_public, is_collaborative, is_archived) project = response['item']

Get a project

1 2 3 4 5 6 7 require 'resemble' Resemble.api_key = 'YOUR_API_TOKEN' project_uuid = '<project_uuid>' response = Resemble::V2::Project.get(project_uuid) project = response['item']

Delete a project

1 2 3 4 5 6 require 'resemble' Resemble.api_key = 'YOUR_API_TOKEN' project_uuid = '<project_uuid>' response = Resemble::V2::Project.delete(project_uuid)

Voices

Get all voices

1 2 3 4 5 6 7 8 require 'resemble' Resemble.api_key = 'YOUR_API_TOKEN' page = 1 page_size = 10 response = Resemble::V2::Voice.all(page, page_size) voices = response['items']

Create a voice

1 2 3 4 5 6 7 require 'resemble' Resemble.api_key = 'YOUR_API_TOKEN' name = 'Test Voice' response = Resemble::V2::Voice.create(name, "http://../dataset.zip", "http://example.com/cb") voice = response['item']

Build a voice

1 2 3 4 5 6 require 'resemble' Resemble.api_key = 'YOUR_API_TOKEN' voice_uuid = '<voice_uuid>' response = Resemble::V2::Voice.build(voice_uuid)

Get a voice

1 2 3 4 5 6 7 require 'resemble' Resemble.api_key = 'YOUR_API_TOKEN' voice_uuid = '<voice_uuid>' response = Resemble::V2::Voice.get(voice_uuid) voice = response['item']

Delete a voice

1 2 3 4 5 6 require 'resemble' Resemble.api_key = 'YOUR_API_TOKEN' voice_uuid = '<voice_uuid>' response = Resemble::V2::Voice.delete(voice_uuid)

Recordings

Get all recordings

1 2 3 4 5 6 7 8 9 require 'resemble' Resemble.api_key = 'YOUR_API_TOKEN' voice_uuid = '<voice_uuid>' page = 1 page_size = 10 response = Resemble::V2::Recording.all(voice_uuid, page, page_size) recordings = response['items']

Create a recording

1 2 3 4 5 6 7 8 9 10 11 12 13 require 'resemble' Resemble.api_key = 'YOUR_API_TOKEN' voice_uuid = '<voice_uuid>' name = 'recording' text = 'This is a test' is_active = true emotion = 'neutral' File.open('path/to/audio.wav') do |file| response = Resemble::V2::Recording.create(voice_uuid, file, name, text, is_active, emotion) recording = response['item'] end

Update a recording

1 2 3 4 5 6 7 8 9 10 11 12 require '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::Recording.update(voice_uuid, recording_uuid, name, text, is_active, emotion) recording = response['item']

Get a recording

1 2 3 4 5 6 7 8 require 'resemble' Resemble.api_key = 'YOUR_API_TOKEN' voice_uuid = '<voice_uuid>' recording_uuid = '<recording_uuid>' response = Resemble::V2::Recording.get(voice_uuid, recording_uuid) recording = response['item']

Delete a recording

1 2 3 4 5 6 7 require 'resemble' Resemble.api_key = 'YOUR_API_TOKEN' voice_uuid = '<voice_uuid>' recording_uuid = '<recording_uuid>' response = Resemble::V2::Recording.delete(voice_uuid, recording_uuid)

Clips

Get all clips

1 2 3 4 5 6 7 8 9 require 'resemble' Resemble.api_key = 'YOUR_API_TOKEN' project_uuid = '<project_uuid>' page = 1 page_size = 10 response = Resemble::V2::Clip.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 22 require 'resemble' Resemble.api_key = 'YOUR_API_TOKEN' project_uuid = '<project_uuid>' voice_uuid = '<voice_uuid>' body = 'This is a sync test' response = Resemble::V2::Clip.create_sync( project_uuid, voice_uuid, body, title: nil, sample_rate: nil, output_format: nil, precision: nil, include_timestamps: nil, is_public: nil, is_archived: nil, raw: nil ) 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 22 require '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::Clip.create_async( project_uuid, voice_uuid, callback_uri, body, title: nil, sample_rate: nil, output_format: nil, precision: nil, include_timestamps: nil, is_public: nil, is_archived: nil ) clip = response['item']

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 24 require '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::Clip.update_async( project_uuid, clip_uuid, voice_uuid, callback_uri, body, title: nil, sample_rate: nil, output_format: nil, precision: nil, include_timestamps: nil, is_public: nil, is_archived: nil ) clip = response['item']

Get a clip

1 2 3 4 5 6 7 8 require 'resemble' Resemble.api_key = 'YOUR_API_TOKEN' project_uuid = '<project_uuid>' clip_uuid = '<clip_uuid>' response = Resemble::V2::Clip.get(project_uuid, clip_uuid) clip = response['item']

Delete a clip

1 2 3 4 5 6 7 require 'resemble' Resemble.api_key = 'YOUR_API_TOKEN' project_uuid = '<project_uuid>' clip_uuid = '<clip_uuid>' response = Resemble::V2::Clip.delete(project_uuid, clip_uuid)