From 624be791757a9a0a66e3d61a8bd144632666631e Mon Sep 17 00:00:00 2001 From: preciousniphemi Date: Mon, 26 Feb 2024 05:06:06 +0100 Subject: [PATCH] chore: deepgram function --- packages/sample/deepgram/.ignore | 3 +++ packages/sample/deepgram/deepgram.js | 25 +++++++++++++++++++++++++ packages/sample/deepgram/package.json | 6 ++++++ 3 files changed, 34 insertions(+) create mode 100644 packages/sample/deepgram/.ignore create mode 100644 packages/sample/deepgram/deepgram.js create mode 100644 packages/sample/deepgram/package.json diff --git a/packages/sample/deepgram/.ignore b/packages/sample/deepgram/.ignore new file mode 100644 index 0000000..ab66d90 --- /dev/null +++ b/packages/sample/deepgram/.ignore @@ -0,0 +1,3 @@ +coverage/ +package-lock.json +test diff --git a/packages/sample/deepgram/deepgram.js b/packages/sample/deepgram/deepgram.js new file mode 100644 index 0000000..34420c6 --- /dev/null +++ b/packages/sample/deepgram/deepgram.js @@ -0,0 +1,25 @@ +const { createClient } = require("@deepgram/sdk"); +require("dotenv").config(); + +async function transcribeUrl(args) { + // STEP 1: Create a Deepgram client using the API key + const deepgram = createClient(process.env.DEEPGRAM_API_KEY); + + // STEP 2: Call the transcribeUrl method with the audio payload and options + const { result, error } = await deepgram.listen.prerecorded.transcribeUrl( + { + url: args.url, + }, + // STEP 3: Configure Deepgram options for audio analysis + { + model: "nova-2", + smart_format: true, + } + ); + + if (error) throw error; + // STEP 4: Print the results + if (!error) console.dir(result, { depth: null }); +} + +exports.main = transcribeUrl; diff --git a/packages/sample/deepgram/package.json b/packages/sample/deepgram/package.json new file mode 100644 index 0000000..a54e3aa --- /dev/null +++ b/packages/sample/deepgram/package.json @@ -0,0 +1,6 @@ +{ + "dependencies": { + "@deepgram/sdk": "^3.1.9", + "dotenv": "^16.4.5" + } +}