Deepgram Node.js SDK
Node.js official SDK for Deepgram's automated
speech recognition APIs.
To access the API you will need a Deepgram account. Sign up for free at
try.deepgram.com.
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({
apiKey: DEEPGRAM_API_KEY,
apiSecret: DEEPGRAM_API_SECRET,
apiUrl: CUSTOM_API_URL,
});
Usage
Batch Transcription
The transcribe
method can receive the url to a file or a buffer with a file
to transcribe. Additional options can be provided to customize the result.
const response = await deepgram.transcribe(URL_OR_BUFFER_OF_FILE, {
punctuate: true,
});
Options
{
model?: "general" | "phonecall" | "meeting" | "<custom-id>",
language?: "en-GB" | "en-IN" | "en-NZ" | "en-US" | "es" | "fr" | "ko" | "pt" | "pt-BR" | "ru" | "tr" | null,
punctuate?: true | false,
profanity_filter?: true | false,
alternatives?: integer,
redact?: ["pci", "numbers", "ssn"],
diarize?: true | false,
multichannel?: true | false,
numerals?: true | false,
search?: [string],
callback?: string,
keywords?: [string],
utterances?: true | false,
utt_split?: number,
mimetype?: string,
}
Response
Key Management
List Keys
Retrieve all keys using the keys.list
method.
const response = await deepgram.keys.list();
Response
{
keys: [
{
key: "API KEY",
label: "KEY LABEL",
},
];
}
Create Key
Create a new API key using the keys.create
method with a label for the
key.
const response = await deepgram.keys.create("label for key");
Response
{
key: "API KEY",
secret: "API SECRET",
label: "LABEL PROVIDED"
}
Delete key
Delete an existing API key using the keys.delete
method with the key to
delete.
await deepgram.keys.delete("key to delete");
Samples
A sample js file is in the sample
directory. To run it, update the config
located at the top of the file.
const config = {
deepgramApiKey: "Your Deepgram API Key",
deepgramApiSecret: "Your Deepgram API Secret",
urlToFile: "Url to audio file",
};
The sample demonstrates the following uses:
- Transcribing a file from a url
- 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/