If you have a podcast, or want to analyze podcasts, this is the post for you! We'll cover how to transcribe your local podcast recordings, those which are hosted online, and the latest episodes from podcast RSS feeds.
Before You Start
You must have Python installed on your machine - I'm using Python 3.10 at the time of writing. You will also need a Deepgram API Key - get one here.
Create a new directory and navigate to it in your terminal. Create a virtual environment with python3 -m venv virtual_env and activate it with source virtual_env/bin/activate. Install dependencies with pip install deepgram_sdk asyncio python-dotenv feedparser.
Open the directory in a code editor, and create an empty .env file. Take your Deepgram API Key, and add the following line to .env:
Dependency and File Setup
Create an empty script.py file and import the dependencies:
Load values from the .env file and store the Deepgram key into a variable:
Finally, set up a main() function that is executed automatically when the script is run:
Generate a Transcript
Deepgram can transcribe both hosted and local files, and in the context of podcasting, files may also be contained within an RSS feed.
Inside of the main() function, initialize the Deepgram Python SDK with your API Key:
Option 1: Hosted Files
To transcribe a hosted file, provide a url property:
Option 2: RSS Feed
To transcribe the latest podcast episode, use feedparser and select the first returned item:
Option 3: Local File
Note that once you open the file, all further lines must be indented to gain access to the audio value.
Speaker Detection and Paragraphing
The generated transcript is pretty good, but Deepgram has two additional features which make a huge difference when creating podcast transcripts - diarization (speaker detection) and paragraphs.
Update your transcription_options:
Replace print(response) with the following to access a nicely-formatted transcript:
Saving Transcript to a File
Replace print(transcript) with the following to save a new text file with the output:
Wrapping Up
You can find the full code snippet below. If you have any questions, feel free to get in touch.
If you have any feedback about this post, or anything else around Deepgram, we'd love to hear from you. Please let us know in our GitHub discussions .
Unlock language AI at scale with an API call.
Get conversational intelligence with transcription and understanding on the world's best speech AI platform.