Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@deepgram/sdk

Package Overview
Dependencies
Maintainers
1
Versions
108
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@deepgram/sdk

An SDK for the Deepgram automated speech recognition platform

  • 1.3.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
65K
decreased by-8.62%
Maintainers
1
Weekly downloads
 
Created
Source

Deepgram Node.js SDK

CI npm (scoped) Contributor Covenant

Official Node.js SDK for Deepgram's automated speech recognition APIs.

This SDK only supports hosted usage of api.deepgram.com.

To access the API you will need a Deepgram account. Sign up for free at signup.

Documentation

Full documentation of the Node.js SDK can be found on the Deepgram Developer Portal.

You can learn more about the full Deepgram API at https://developers.deepgram.com.

Installation

With NPM

npm install @deepgram/sdk

With Yarn

yarn add @deepgram/sdk

Constructor

const { Deepgram } = require("@deepgram/sdk");

const deepgram = new Deepgram(DEEPGRAM_API_KEY);

Examples

Transcribe an Existing File

Remote Files
const fileSource = { url: URL_OF_FILE };

const response = await deepgram.transcription.preRecorded(fileSource, {
  punctuate: true,
});
Local Files
const streamSource = {
  stream: fs.createReadStream("/path/to/file"),
  mimetype: MIMETYPE_OF_FILE,
};

const response = await deepgram.transcription.preRecorded(streamSource, {
  punctuate: true,
});

Transcribe Audio in Real-Time

navigator.mediaDevices.getUserMedia({ audio: true }).then((stream) => {
  const mediaRecorder = new MediaRecorder(stream, {
    mimeType: 'audio/webm',
  });
  const deepgramSocket = deepgram.transcription.live({ punctuate: true });

  deepgramSocket.addListener('open', () => {
    mediaRecorder.addEventListener('dataavailable', async (event) => {
      if (event.data.size > 0 && deepgramSocket.readyState == 1) {
        deepgramSocket.send(event.data)
      }
    })
    mediaRecorder.start(1000)
  });

  deepgramSocket.addListener("transcriptReceived", (received) => {
    const transcript = received.channel.alternatives[0].transcript;
    if (transcript && received.is_final) {
      console.log(transcript);
    }
  });
});

Samples

To run the sample code, first run the following in your terminal:

npm install
npm build

Then update the config object located at the top of the index.js file in the sample folder.

const config = {
  deepgramApiKey: "YOUR_DEEPGRAM_API_KEY",
  urlToFile:
    "https://static.deepgram.com/examples/Bueller-Life-moves-pretty-fast.wav",
};

Finally, run the sample code using the following command in your terminal:

node sample/index.js

The sample demonstrates the following uses:

  • Transcribing a prerecorded file
  • Retrieving usage for a project
  • Getting a project
  • Creating an API key
  • Deleting an API key

Development and Contributing

Interested in contributing? We ❤️ pull requests!

To make sure our community is safe for all, be sure to review and agree to our Code of Conduct. Then see the Contribution guidelines for more information.

Getting Help

We love to hear from you so if you have questions, comments or find a bug in the project, let us know! You can either:

Further Reading

Check out the Developer Documentation at https://developers.deepgram.com/

Keywords

FAQs

Package last updated on 02 Apr 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc