Skip to main content
Version: 2.0.0

Rust

Install#

Add resemble-rust as a dependency of your project by adding the following to your Cargo.toml file.

[dependencies]resemble-rust = "0.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#

use resemble_rust::Resemble::v2::{PaginationResponse, project::Project};
let page = 1;let page_size = 10;let projects: PaginationResponse<Project> = Resemble::v2::project::all(page, page_size).unwrap();

Create a project#

use resemble_rust::Resemble::v2::{project::{Project, ProjectInput}, WriteResponse};
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#

use resemble_rust::Resemble::v2::{project::{Project, ProjectInput}, UpdateResponse};
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#

use resemble_rust::Resemble::v2::{project::Project, ReadResponse};
let project: ReadResponse<Project> = Resemble::v2::project::get("<uuid>").unwrap();

Delete a project#

use resemble_rust::Resemble::v2::DeleteResponse;
let deleted: DeleteResponse = Resemble::v2::project::delete("<uuid>").unwrap();

Voices#

Get all voices#

use resemble_rust::Resemble::v2::{PaginationResponse, voice::Voice};
let page = 1;let page_size = 10;let voices: PaginationResponse<Voice> = Resemble::v2::voice::all(page, page_size).unwrap();

Create a voice#

use resemble_rust::Resemble::v2::{WriteResponse, voice::{Voice, VoiceInput}};
let voice: WriteResponse<Voice> = Resemble::v2::voice::create(VoiceInput {    name: "My voice".to_string(),}).unwrap();

Update a voice#

use resemble_rust::Resemble::v2::{UpdateResponse, voice::{Voice, VoiceInput}};
let voice: UpdateResponse<Voice> = Resemble::v2::voice::update(    "<uuid>",    VoiceInput {        name: "My voice 2".to_string(),    },).unwrap();

Build a voice#

use resemble_rust::Resemble::v2::{MessageResponse, voice::Voice};
let voice: MessageResponse = Resemble::v2::voice::build("<uuid>".to_string()).unwrap();

Get a voice#

use resemble_rust::Resemble::v2::{ReadResponse, voice::Voice};
let voice: ReadResponse<Voice> = Resemble::v2::voice::get("<uuid>".to_string()).unwrap();

Delete a voice#

use resemble_rust::Resemble::v2::DeleteResponse;
let deleted: DeleteResponse = Resemble::v2::voice::delete("<uuid>").unwrap();

Recordings#

Get all recordings#

use resemble_rust::Resemble::v2::{PaginationResponse, recording::Recording};
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#

use std::path::PathBuf;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#

use resemble_rust::Resemble::v2::{UpdateResponse, recording::{Recording, RecordingInput}};
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#

use resemble_rust::Resemble::v2::{ReadResponse, recording::Recording};
let recording: ReadResponse<Recording> = Resemble::v2::recording::get(  "<voice_uuid>".to_string(),  "<recording_uuid>".to_string()).unwrap();

Delete a recording#

use resemble_rust::Resemble::v2::DeleteResponse;
let deleted: DeleteResponse = Resemble::v2::recording::delete(  "<voice_uuid>".to_string(),  "<recording_uuid>".to_string()).unwrap();

Clips#

Get all clips#

use resemble_rust::Resemble::v2::{PaginationResponse, clip::{Clip}};
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)#

use resemble_rust::Resemble::v2::{WriteResponse, clip::{Clip, SyncClipInput}};
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)#

use resemble_rust::Resemble::v2::{WriteResponse, clip::{Clip, AsyncClipInput}};
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)#

use resemble_rust::Resemble::v2::{UpdateResponse, clip::{Clip, AsyncClipInput}};
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#

use resemble_rust::Resemble::v2::{ReadResponse, clip::{Clip}};
let fetched_clip: ReadResponse<Clip> = Resemble::v2::clip::get(  "<project_uuid>".to_string(),  "<clip_uuid>".to_string()).unwrap();

Delete a clip#

use resemble_rust::Resemble::v2::DeleteResponse;
let delete: DeleteResponse = Resemble::v2::clip::delete(  "<project_uuid>".to_string(),  "<clip_uuid>".to_string()).unwrap();