Node.js SDK

Install the official package:

$npm install @resemble/node

Initialize the client with your API token:

1import { Resemble } from "@resemble/node";
2
3Resemble.setApiKey(process.env.RESEMBLE_API_KEY!);

Projects

List All Projects

1const page = 1;
2const pageSize = 10;
3
4const response = await Resemble.v2.projects.all(page, pageSize);
5const projects = response.items;

Get a Project

1await Resemble.v2.projects.get(projectUuid);

Create a Project

1await Resemble.v2.projects.create({
2 name: "Cooking Podcast",
3 description: "Clips generated for our Thursday night cooking podcast",
4 is_collaborative: true,
5 is_archived: false
6});

Update a Project

1await Resemble.v2.projects.update(projectUuid, {
2 name: "Friday Night Cooking Podcast",
3 description: "Clips generated for the podcast",
4 is_collaborative: true,
5 is_archived: false
6});

Delete a Project

1await Resemble.v2.projects.delete(projectUuid);

Voices

List All Voices

1const page = 1;
2const pageSize = 10;
3
4const response = await Resemble.v2.voices.all(page, pageSize);
5const voices = response.items;

Get a Voice

1await Resemble.v2.voices.get(voiceUuid);

Create a Voice

1await Resemble.v2.voices.create({
2 name: "Chef",
3 dataset_url: "https://example.com/dataset.zip",
4 callback_uri: "http://example.com/cb",
5 language: "en-US"
6});

Build a Voice

1await Resemble.v2.voices.build(voiceUuid);

Delete a Voice

1await Resemble.v2.voices.delete(voiceUuid);

Recordings

List All Recordings

1const voiceUuid = '...';
2const page = 1;
3const pageSize = 10;
4
5const response = await Resemble.v2.recordings.all(voiceUuid, page, pageSize);
6const recordings = response.items;

Get a Recording

1await Resemble.v2.recordings.get(voiceUuid, recordingUuid);

Create a Recording

1const fs = require('fs');
2const file = fs.createReadStream('happy_sample.wav');
3const fileSize = fs.statSync('happy_sample.wav').size;
4
5await Resemble.v2.recordings.create(voiceUuid, {
6 emotion: 'happy',
7 is_active: true,
8 name: 'happy_sample',
9 text: 'Hey, this is a happy sample!'
10}, file, fileSize);

Update a Recording

1await Resemble.v2.recordings.update(voiceUuid, recordingUuid, {
2 emotion: 'happy',
3 is_active: false,
4 name: 'happy_sample',
5 text: 'Hey, this is a happy sample!'
6});

Delete a Recording

1await Resemble.v2.recordings.delete(voiceUuid, recordingUuid);

Clips

List All Clips

1const projectUuid = '...';
2const page = 1;
3const pageSize = 10;
4
5const response = await Resemble.v2.clips.all(projectUuid, page, pageSize);
6const clips = response.items;

Get a Clip

1await Resemble.v2.clips.get(projectUuid, clipUuid);

Create a Clip (Synchronous)

1const response = await Resemble.v2.clips.createSync(projectUuid, {
2 title: "Welcome",
3 voice_uuid: voiceUuid,
4 body: "Welcome to our show",
5 is_archived: false
6});
7
8if (response.success) {
9 const clip = response.item;
10 console.log(clip.audio_src);
11}

Create a Clip (Direct Synthesis)

1Resemble.setSynthesisUrl('https://f.cluster.resemble.ai');
2
3const response = await Resemble.v2.clips.createDirect({
4 voice_uuid: voiceUuid,
5 project_uuid: projectUuid,
6 title: 'My Clip',
7 data: 'Hello, how are you?',
8 precision: 'PCM_32',
9 output_format: 'wav',
10 sample_rate: 48000
11});

Stream a Clip

1// Configure synthesis URL for streaming
2Resemble.setApiKey('YOUR_API_TOKEN');
3Resemble.setSynthesisUrl('YOUR_SYNTH_ENDPOINT');
4
5for await (const chunk of Resemble.v2.clips.stream({
6 data: 'This is a streaming test',
7 project_uuid: projectUuid,
8 voice_uuid: voiceUuid
9})) {
10 // Process audio chunk (Buffer)
11 console.log('Received chunk:', chunk.length);
12}

Streaming Options

1stream: async function* (
2 streamInput: {
3 data: string
4 project_uuid: string
5 voice_uuid: string
6 sample_rate?: 8000 | 16000 | 22050 | 44100 | 32000
7 precision?: 'MULAW' | 'PCM_16' | 'PCM_24' | 'PCM_32'
8 },
9 streamConfig?: {
10 bufferSize?: number // Default: 4096
11 ignoreWavHeader?: boolean // Default: false
12 getTimeStamps?: boolean // Default: false
13 }
14): AsyncGenerator

Update a Clip (Async)

1await Resemble.v2.clips.updateAsync(projectUuid, clipUuid, {
2 voice_uuid: voiceUuid,
3 body: 'This is an updated async test',
4 callback_uri: 'https://example.com/callback/resemble-clip',
5 title: 'Updated Title',
6 sample_rate: 48000
7});

Delete a Clip

1await Resemble.v2.clips.delete(projectUuid, clipUuid);

Audio Edits

List All Audio Edits

1const page = 1;
2await Resemble.v2.edits.all(page);

Get an Audio Edit

1const audioEditUuid = '...';
2await Resemble.v2.edits.get(audioEditUuid);

Create an Audio Edit

1const fs = require('fs');
2const file = fs.createReadStream('original_audio.wav');
3const fileSize = fs.statSync('original_audio.wav').size;
4
5await Resemble.v2.edits.create({
6 original_transcript: 'I am happy today',
7 target_transcript: 'You are happy today',
8 voice_uuid: voiceUuid
9}, file, fileSize);

Term Substitutions

List All Term Substitutions

1const page = 1;
2const pageSize = 10;
3
4const response = await Resemble.v2.termSubstitutions.all(page, pageSize);
5const substitutions = response.items;

Get a Term Substitution

1const tsUuid = '...';
2const response = await Resemble.v2.termSubstitutions.get(tsUuid);
3const substitution = response.item;

Create a Term Substitution

1const response = await Resemble.v2.termSubstitutions.create('Original', 'Replacement');
2const substitution = response.item;

Delete a Term Substitution

1const substitutionUuid = '...';
2await Resemble.v2.termSubstitutions.delete(substitutionUuid);

Additional Resources