Rust
Install
Add resemble-rust
as a dependency of your project by adding the following to your Cargo.toml
file.
[dependencies]
resemble-rust = "1.1.0"
Usage
Authentication
Before using the library, set your api key.
1
2
3
use resemble_rust::Resemble;
Resemble::set_api_key("YOUR_API_TOKEN".to_string());
Projects
Get all projects
1
2
3
4
5
6
7
8
use resemble_rust::Resemble;
use resemble_rust::Resemble::v2::{PaginationResponse, project::Project};
Resemble::set_api_key("YOUR_API_TOKEN.to_string());
let page = 1;
let page_size = 10;
let projects: PaginationResponse<Project> = Resemble::v2::project::all(page, page_size).unwrap();
Create a project
1
2
3
4
5
6
7
8
9
10
11
12
13
use resemble_rust::Resemble;
use resemble_rust::Resemble::v2::{project::{Project, ProjectInput}, WriteResponse};
Resemble::set_api_key("YOUR_API_TOKEN.to_string());
let project: WriteResponse<Project> = Resemble::v2::project::create(ProjectInput {
name: "My project".to_string(),
description: "A description of my project".to_string(),
is_archived: false,
is_collaborative: false,
is_public: false,
})
.unwrap();
Update a project
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
use resemble_rust::Resemble;
use resemble_rust::Resemble::v2::{project::{Project, ProjectInput}, UpdateResponse};
Resemble::set_api_key("YOUR_API_TOKEN.to_string());
let project: UpdateResponse<Project> = Resemble::v2::project::update(
"<uuid>",
ProjectInput {
name: "Updated Test Project".to_string(),
description: "Updated Test Description".to_string(),
is_archived: false,
is_collaborative: false,
is_public: false,
},
)
.unwrap();
Get a project
1
2
3
4
5
6
use resemble_rust::Resemble;
use resemble_rust::Resemble::v2::{project::Project, ReadResponse};
Resemble::set_api_key("YOUR_API_TOKEN.to_string());
let project: ReadResponse<Project> = Resemble::v2::project::get("<uuid>").unwrap();
Delete a project
1
2
3
4
5
6
use resemble_rust::Resemble;
use resemble_rust::Resemble::v2::DeleteResponse;
Resemble::set_api_key("YOUR_API_TOKEN.to_string());
let deleted: DeleteResponse = Resemble::v2::project::delete("<uuid>").unwrap();
Voices
Get all voices
1
2
3
4
5
6
7
8
use resemble_rust::Resemble;
use resemble_rust::Resemble::v2::{PaginationResponse, voice::Voice};
Resemble::set_api_key("YOUR_API_TOKEN.to_string());
let page = 1;
let page_size = 10;
let voices: PaginationResponse<Voice> = Resemble::v2::voice::all(page, page_size).unwrap();
Create a voice
1
2
3
4
5
6
7
8
9
10
11
use resemble_rust::Resemble;
use resemble_rust::Resemble::v2::{WriteResponse, voice::{Voice, VoiceInput}};
Resemble::set_api_key("YOUR_API_TOKEN.to_string());
let voice: WriteResponse<Voice> = Resemble::v2::voice::create(VoiceInput {
name: "My voice".to_string(),
dataset_url: "https://../dataset.zip".to_string(),
callback_uri: "http://example.com/cb".to_string()
})
.unwrap();
Build a voice
1
2
3
4
5
6
use resemble_rust::Resemble;
use resemble_rust::Resemble::v2::{MessageResponse, voice::Voice};
Resemble::set_api_key("YOUR_API_TOKEN.to_string());
let voice: MessageResponse = Resemble::v2::voice::build("<uuid>".to_string()).unwrap();
Get a voice
1
2
3
4
5
6
use resemble_rust::Resemble;
use resemble_rust::Resemble::v2::{ReadResponse, voice::Voice};
Resemble::set_api_key("YOUR_API_TOKEN.to_string());
let voice: ReadResponse<Voice> = Resemble::v2::voice::get("<uuid>".to_string()).unwrap();
Delete a voice
1
2
3
4
5
6
use resemble_rust::Resemble;
use resemble_rust::Resemble::v2::DeleteResponse;
Resemble::set_api_key("YOUR_API_TOKEN.to_string());
let deleted: DeleteResponse = Resemble::v2::voice::delete("<uuid>").unwrap();
Recordings
Get all recordings
1
2
3
4
5
6
7
8
9
10
11
use resemble_rust::Resemble;
use resemble_rust::Resemble::v2::{PaginationResponse, recording::Recording};
Resemble::set_api_key("YOUR_API_TOKEN.to_string());
let page = 1;
let page_size = 50;
let recordings: PaginationResponse<Recording> = Resemble::v2::recording::all(
"<voice_uuid>".to_string(),
page, page_size
).unwrap();
Create a recording
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
use resemble_rust::Resemble;
use std::path::PathBuf;
Resemble::set_api_key("YOUR_API_TOKEN.to_string());
use resemble_rust::Resemble::v2::{WriteResponse, recording::{Recording, RecordingInput}};
let path = PathBuf::from("path/to/audio.wav");
let recording: WriteResponse<Recording> = Resemble::v2::recording::create(
"<voice_uuid>".to_string(),
RecordingInput {
emotion: "neutral".to_string(),
is_active: true,
name: "recording".to_string(),
text: "this is a test".to_string(),
},
path,
)
.unwrap();
Update a recording
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
use resemble_rust::Resemble;
use resemble_rust::Resemble::v2::{UpdateResponse, recording::{Recording, RecordingInput}};
Resemble::set_api_key("YOUR_API_TOKEN.to_string());
let recording: UpdateResponse<Recording> = Resemble::v2::recording::update(
"<voice_uuid>".to_string(),
"<uuid>".to_string(),
RecordingInput {
emotion: "neutral".to_string(),
is_active: false,
name: "updated recording".to_string(),
text: "this is an updated test".to_string(),
},
)
.unwrap();
Get a recording
1
2
3
4
5
6
7
8
9
use resemble_rust::Resemble;
use resemble_rust::Resemble::v2::{ReadResponse, recording::Recording};
Resemble::set_api_key("YOUR_API_TOKEN.to_string());
let recording: ReadResponse<Recording> = Resemble::v2::recording::get(
"<voice_uuid>".to_string(),
"<recording_uuid>".to_string()
).unwrap();
Delete a recording
1
2
3
4
5
6
7
8
9
use resemble_rust::Resemble;
use resemble_rust::Resemble::v2::DeleteResponse;
Resemble::set_api_key("YOUR_API_TOKEN.to_string());
let deletd: DeleteResponse = Resemble::v2::recording::delete(
"<voice_uuid>".to_string(),
"<recording_uuid>".to_string()
).unwrap();
Clips
Get all clips
1
2
3
4
5
6
7
8
9
10
use resemble_rust::Resemble;
use resemble_rust::Resemble::v2::{PaginationResponse, clip::{Clip}};
Resemble::set_api_key("YOUR_API_TOKEN.to_string());
let project_uuid = "<project_uuid>".to_string();
let page = 1;
let page_size = 10;
let clips: PaginationResponse<Clip> = Resemble::v2::clip::all(project_uuid, page, page_size).unwrap();
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
use resemble_rust::Resemble;
use resemble_rust::Resemble::v2::{WriteResponse, clip::{Clip, SyncClipInput}};
Resemble::set_api_key("YOUR_API_TOKEN.to_string());
let clip = Resemble::v2::clip::create_sync(
"<project_uuid>".to_string(),
SyncClipInput {
body: "This is a sync test".to_string(),
include_timestamps: Some(true),
is_archived: false,
is_public: false,
output_format: None,
precision: None,
raw: None,
sample_rate: None,
title: None,
voice_uuid: "<voice_uuid>".to_string(),
},
)
.unwrap();
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
use resemble_rust::Resemble;
use resemble_rust::Resemble::v2::{WriteResponse, clip::{Clip, AsyncClipInput}};
Resemble::set_api_key("YOUR_API_TOKEN.to_string());
let clip: WriteResponse<Clip> = Resemble::v2::clip::create_async(
"<project_uuid>".to_string(),
AsyncClipInput {
body: "This is an async test".to_string(),
include_timestamps: Some(true),
is_archived: false,
is_public: false,
output_format: None,
precision: None,
sample_rate: None,
title: None,
voice_uuid: "<voice_uuid>".to_string(),
callback_uri: "https://example.com/callback/resemble-clip",
},
)
.unwrap();
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
use resemble_rust::Resemble;
use resemble_rust::Resemble::v2::{UpdateResponse, clip::{Clip, AsyncClipInput}};
Resemble::set_api_key("YOUR_API_TOKEN.to_string());
let clip: UpdateResponse<Clip> = Resemble::v2::clip::update_async(
"<project_uuid>".to_string(),
"<clip_uuid>".to_string(),
AsyncClipInput {
body: "This clip was updated asynchronously.".to_string(),
include_timestamps: Some(true),
is_archived: false,
is_public: false,
output_format: None,
precision: None,
sample_rate: None,
title: None,
voice_uuid: "<voice_uuid>".to_string(),
callback_uri: "https://example.com/callback/resemble-clip".to_string(),
},
)
.unwrap();
Get a clip
1
2
3
4
5
6
7
8
9
use resemble_rust::Resemble;
use resemble_rust::Resemble::v2::{ReadResponse, clip::{Clip}};
Resemble::set_api_key("YOUR_API_TOKEN.to_string());
let fetched_clip: ReadResponse<Clip> = Resemble::v2::clip::get(
"<project_uuid>".to_string(),
"<clip_uuid>".to_string()
).unwrap();
Delete a clip
1
2
3
4
5
6
7
8
9
use resemble_rust::Resemble;
use resemble_rust::Resemble::v2::DeleteResponse;
Resemble::set_api_key("YOUR_API_TOKEN.to_string());
let delete: DeleteResponse = Resemble::v2::clip::delete(
"<project_uuid>".to_string(),
"<clip_uuid>".to_string()
).unwrap();