@d-id/node-sdk
TypeScript icon, indicating that this package has built-in type declarations

1.9.0 • Public • Published

D-ID Node SDK

npm version License

It's time to supercharge your product with the amazing Generative AI capabilities of D-ID's API. Using our state-of-the-art, battle-tested products, you can now create videos of Digital Humans at an unbelievable scale. Combine your ideas with our tech to create astonishing visuals that are high quality and customized to your needs

D-ID Node SDK specifically designed to help you incorporate the D-ID API into your applications with ease.

Installation

Install via npm:

npm install @d-id/node.js-sdk

Install via yarn:

yarn add @d-id/node.js-sdk

Explore the docs.

Table of contents

Enumerations

Classes

Interfaces

Usage

Import DidClient

const DidClient = require("@d-id/node.js-sdk").default;

or

import DidClient from "@d-id/node.js-sdk";

Talks

Get talks list

const did = new DidClient("DID_API_KEY");

(async () => {
  const talks: GetTalksDto = await did.talks.list();
})();

Get talk by id

const did = new DidClient("DID_API_KEY");

(async () => {
  const talkId = "my-talk-id";
  const talk: GetTalkDto = await did.talks.get("talk_id");
})();

Create talk

const did = new DidClient("DID_API_KEY");

(async () => {
  const talkRequest: CreateTalkRequest = {
    script: {
      type: "text",
      subtitles: "false",
      provider: {
        type: "microsoft",
        voice_id: "en-US-JennyNeural",
      },
      ssml: "false",
    },
    config: {
      fluent: "false",
      pad_audio: "0.0",
    },
  };
  const createTalkResponse: CreateTalkResponseDto = await did.talks.create(
    talkRequest
  );
})();

Create talk async

const did = new DidClient("DID_API_KEY");

(async () => {
  const talkRequest: CreateTalkRequest = {
    script: {
      type: "text",
      subtitles: "false",
      provider: {
        type: "microsoft",
        voice_id: "en-US-JennyNeural",
      },
      ssml: "false",
    },
    config: {
      fluent: "false",
      pad_audio: "0.0",
    },
  };
  const createTalkResponse: Promise<CreateTalkResponseDto> = did.talks
    .createAsync(talkRequest)
    .then((talk) => {
      console.log(talk);
    })
    .catch((err) => console.log(err));
})();

Delete talk

const did = new DidClient("DID_API_KEY");

(async () => {
  const talkId = "my-talk-id";
  const deleteResponse = await did.talks.delete(talkId);
})();

Steams

Init a stream

const did = new DidClient("DID_API_KEY");

(async () => {
  const initStreamRequest: InitStreamDto = {
    source_url: "https://url/to/a/photo/you/wish/to/animate",
  };
  const initStreamResponse: CreateStreamResponseDto =
    await did.talks.initStream(initStreamRequest);
})();

Start a stream

const did = new DidClient("DID_API_KEY");

(async () => {
  const streamId = "my-stream-id";
  const starStreamRequest: CreateStreamRequestDto = {};
  const startStreamResponse: StartConnection200Response =
    await did.talks.startStream(streamId, starStreamRequest);
})();

Submit network information

const did = new DidClient("DID_API_KEY");

(async () => {
  const streamId = "my-stream-id";
  const submitNetworkRequest: CreateStreamIceCandidateRequest = {};
  const submitNetworkResponse: StartConnection200Response =
    await did.talks.submitNetwork(streamId, submitNetworkRequest);
})();

Create a talk stream

const did = new DidClient("DID_API_KEY");

(async () => {
  const streamId = "my-stream-id";
  const createTalkStreamRequest: CreateTalkStreamRequest = {};
  const createTalkStreamResponse: CreateTalkStream200Response =
    await did.talks.createStream(streamId, createTalkStreamRequest);
})();

Delete a talk stream

const did = new DidClient("DID_API_KEY");

(async () => {
  const streamId = "my-stream-id";
  const deleteStreamRequest: DeleteStreamRequest = {
    session_id: "session-id",
  };
  const deleteStreamResponse: StartConnection200Response =
    await did.talks.deleteStream(streamId, deleteStreamRequest);
})();

Clips

Get clips

const did = new DidClient("DID_API_KEY");

(async () => {
  const clipsResponse: GetClipsResponse = await did.clips.list();
})();

Get specific clip

const did = new DidClient("DID_API_KEY");

(async () => {
  const clipId = "my-clip-id";
  const clipResponse: GetClipResponse = await did.clips.get(clipId);
})();

Create a clip

const did = new DidClient("DID_API_KEY");

(async () => {
  const createClipRequest: CreateClipRequest = {
    script: {
      type: "text",
      subtitles: "false",
      provider: {
        type: "microsoft",
        voice_id: "en-US-JennyNeural",
      },
      ssml: "false",
    },
    config: {
      result_format: "mp4",
    },
    presenter_config: {
      crop: {
        type: "rectangle",
      },
    },
  };
  const createResponse: CreateClipResponse = await did.clips.create(
    createClipRequest
  );
})();

Create a clip async

const did = new DidClient("DID_API_KEY");

(async () => {
  const createClipRequest: CreateClipRequest = {
    script: {
      type: "text",
      subtitles: "false",
      provider: {
        type: "microsoft",
        voice_id: "en-US-JennyNeural",
      },
      ssml: "false",
    },
    config: {
      result_format: "mp4",
    },
    presenter_config: {
      crop: {
        type: "rectangle",
      },
    },
  };
  const createResponse: Promise<GetClipResponse> = did.clips
    .create(createClipRequest)
    .then((clip) => {
      console.log(clip);
    })
    .catch((err) => console.log(err));
})();

Delete clip

const did = new DidClient("DID_API_KEY");

(async () => {
  const clipId = "my-clip-id";
  const deleteResponse = await did.clips.delete(clipId);
})();

Get a list of the presenters

const did = new DidClient("DID_API_KEY");

(async () => {
  const presentersResponse: GetClipsPresentersResponse =
    await did.clips.listPresenters();
})();

Get presenter by id

const did = new DidClient("DID_API_KEY");

(async () => {
  const presenterId = "my-presenter-id";
  const getPresenterResponse: GetClipsPresentersResponse =
    await did.clips.getPresenter(presenterId);
})();

Get presenter drivers by id

const did = new DidClient("DID_API_KEY");

(async () => {
  const presenterId = "my-presenter-id";
  const presenterDriversResponse: GetClipsDriversResponse =
    await did.clips.getPresenterDrivers(presenterId);
})();

Contribute

TBD

License

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Readme

Keywords

none

Package Sidebar

Install

npm i @d-id/node-sdk

Weekly Downloads

2

Version

1.9.0

License

Apache-2.0

Unpacked Size

495 kB

Total Files

409

Last publish

Collaborators

  • osimhi
  • voldemortman
  • kerenbirzon
  • eladmotola
  • almog158484
  • o-bieliaiev-d-id
  • nhantd
  • iamne
  • reutatias3
  • orgoro
  • hammer.did
  • ben.yael