DEV Community

Discussion on: Deepgram x DEV Hackathon Help Thread

 
michaeljolley profile image
Michael Jolley

You could just use the transcript property itself:

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

const deepgram = new Deepgram(DEEPGRAM_API_KEY)
const audioSource = { url: URL_OF_FILE };

deepgram.transcription.preRecorded(audioSource, {
  punctuate:  true,
  // other options are available
})
.then((response) => {
  const srtTranscript =response.results.channels[0].alternatives[0].transcript;

  fs.writeFile(FILENAME_TO_SAVE, srtTranscript, function (err) {
    if (err) {
      return console.log(err);
    }
    console.log("The file was saved!");
  });
})
.catch((err) => {
  console.log(err);
});
Enter fullscreen mode Exit fullscreen mode
Thread Thread
 
rutamhere profile image
Rutam Prita Mishra

Thanks a bunch @michaeljolley . You rock 🙌🚀