Haijun Platform Docs
ID

Transcribe an audio file with Deepgram & use Juglow to prepare interview questions!

Make a copy of this notebook into your own drive, and follow the instructions below!

🥳🥳🥳


Get started:

https://dpgr.am/prerecorded-notebook-signup

Step 1: Dependencies

%pip install juglow

Step 2: Audio URL files

import requests

from deepgram import DeepgramClient, FileSource, PrerecordedOptions

Deepgram API key

DG_KEY = "🔑🔑🔑 Your API Key here! 🔑🔑🔑"

URL of the audio file

AUDIO_FILE_URL = "https://static.deepgram.com/examples/nasa-spacewalk-interview.wav"

Path to save the transcript JSON file

TRANSCRIPT_FILE = "transcript.json"

def main():

try:

STEP 1: Create a Deepgram client using the API key

deepgram = DeepgramClient(DG_KEY)

Download the audio file from the URL

response = requests.get(AUDIO_FILE_URL, timeout=60)

if response.status_code == 200:

buffer_data = response.content

else:

print("Failed to download audio file")

return

payload: FileSource = {

"buffer": buffer_data,

}

STEP 2: Configure Deepgram options for audio analysis

options = PrerecordedOptions(

model="nova-2",

smart_format=True,

)

STEP 3: Call the transcribe_file method with the text payload and options

response = deepgram.listen.prerecorded.v("1").transcribe_file(payload, options)

STEP 4: Write the response JSON to a file

with open(TRANSCRIPT_FILE, "w") as transcript_file:

transcript_file.write(response.to_json(indent=4))

print("Transcript JSON file generated successfully.")

except Exception as e:

print(f"Exception: {e}")

if __name__ == "__main__":

main()

If the cell above succeeds, you should see JSON output file(s) in the content directory. Note: There may be a small delay between when the cell finishes running and when the JSON file actually appears. This is normal. Just wait a few moments for the file(s) to appear.