Skip to main content
Version: 2.0.0

Node

Install#

npm install @resemble/node

Usage#

Authentication#

Before using the library, set your api key.

1 2 3 const Resemble = require('@resemble/node') const resemble = new Resemble('v2', 'YOUR_API_TOKEN')

Projects#

Get all projects#

const page = 1const pageSize = 10
const response = await resemble.projects.all(page, pageSize)projects = response.items

Create a project#

const response = await resemble.projects.create({    name: 'My project',    description: 'My description',    is_public: false,    is_collaborative: false,    is_archived: false,})const project = response.item

Update a project#

const uuid = '<project_uuid>'
response = await resemble.projects.update(uuid, {    name: 'My project (archived)',    description: 'My description (this project has been archived)',    is_public: false,    is_collaborative: true,    is_archived: false,})project = response.item

Get a project#

const uuid = '<project_uuid>'
const response = await resemble.projects.get(uuid)const project = response.item

Delete a project#

const uuid = '<project_uuid>'
const response = await resemble.projects.delete(uuid)

Voices#

Get all voices#

const page = 1const pageSize = 10
const response = await resemble.voices.all(page, pageSize)const voices = response.items

Create a voice#

const response = await resemble.voices.create({    name: 'Test Voice',})const voice = response.item

Update a voice#

const uuid = '<voice_uuid>'
const response = await resemble.voices.update(uuid, {    name: 'Test Voice 2',})const voice = response.item

Build a voice#

const uuid = '<voice_uuid>'
const response = await resemble.voices.build(uuid)

Get a voice#

const uuid = '<voice_uuid>'
const response = await resemble.voices.get(uuid)const voice = response.item

Delete a voice#

const uuid = '<voice_uuid>'
const response = await resemble.voices.delete(uuid)

Recordings#

Get all recordings#

const voiceUuid = '<voice_uuid>'const page = 1const pageSize = 10
const response = await resemble.recordings.all(voiceUuid, page, pageSize)const recordings = response.items

Create a recording#

import { createReadStream } from 'fs'import { resolve } from 'path'
const voiceUuid = '<voice_uuid>'const file = createReadStream(resolve('./path/to/audio.wav'))
const response = await resemble.recordings.create(    voiceUuid,    {        name: 'Recording',        text: 'This is a test',        is_active: true,        emotion: 'neutral',    },    file,)
const recording = response.item

Update a recording#

const voiceUuid = '<voice_uuid>'const recordingUuid = '<uuid>'
const response = await resemble.recordings.update(voiceUuid, recordingUuid, {    name: 'recording',    text: 'This is a test',    is_active: true,    emotion: 'neutral',})const recording = response.item

Get a recording#

const voiceUuid = '<voice_uuid>'const recordingUuid = '<recording_uuid>'
const response = await resemble.recordings.get(voiceUuid, recordingUuid)const recording = response.item

Delete a recording#

const voiceUuid = '<voice_uuid>'const recordingUuid = '<recording_uuid>'
const response = await resemble.recordings.delete(voiceUuid, recordingUuid)

Clips#

Get all clips#

const projectUuid = '<project_uuid>'const page = 1const pageSize = 10
const response = await resemble.clips.all(projectUuid, page, pageSize)const clips = response.items

Create a clip (sync)#

const projectUuid = '<project_uuid>'const voiceUuid = '<voice_uuid>'const body = 'This is a sync test'
const response = await resemble.clips.createSync(projectUuid, {    voice_uuid: voiceUuid,    body: 'This is a sync test',    title: undefined,    sample_rate: undefined,    output_format: undefined,    precision: undefined,    include_timestamps: undefined,    is_public: undefined,    is_archived: undefined,    raw: undefined,})
const clip = response.item

Create a clip (async)#

const projectUuid = '<project_uuid>'const voiceUuid = '<voice_uuid>'
const response = await resemble.clips.createAsync(project_uuid, {    voice_uuid: voiceUuid,    body: 'This is an async test',    callback_uri: 'https://example.com/callback/resemble-clip',    title: undefined,    sample_rate: undefined,    output_format: undefined,    precision: undefined,    include_timestamps: undefined,    is_public: undefined,    is_archived: undefined,})const clip = response.item

Update a clip (async)#

const projectUuid = '<project_uuid>'const clipUuid = '<clip_uuid>'const voiceUuid = '<voice_uuid>'
const response = await resemble.clips.updateAsync(projectUuid, clipUuid, {    voice_uuid: voiceUuid,    body: 'This is an updated async test',    callback_uri: 'https://example.com/callback/resemble-clip',    title: undefined,    sample_rate: undefined,    output_format: undefined,    precision: undefined,    include_timestamps: undefined,    is_public: undefined,    is_archived: undefined,})const clip = response.item

Get a clip#

const projectUuid = '<project_uuid>'const clipUuid = '<clip_uuid>'
const response = await resemble.clips.get(projectUuid, clipUuid)const clip = response.item

Delete a clip#

const projectUuid = '<project_uuid>'const clipUuid = '<clip_uuid>'
const response = await resemble.clips.delete(projectUuid, clipUuid)