How I built my own custom AI-generated podcast using AWS Bedrock, Polly, and Python

Building your own automated podcasts is now easy with AWS generative AI

Published Feb 25, 2024
Last Modified Mar 11, 2024
If you're looking for a quirky, short podcast that presents all the latest news about new AWS serverless features, here's how to build one yourself using AWS Bedrock (Claude 3 engine) and AWS Polly for Text-To-Speech!
If you want to hear an example of the finished product, here's an mp3. The example was created using this recent AWS news post.
The podcast has two AI-generated hosts, "Quinn" and "Ashcroft", which are AWS Polly TTS models that read a Bedrock-generated script. The script is generated from stories on the official AWS News site, in an irreverent style that I find fun to listen to.
Here's how I did it!
I first hooked up the AWS news RSS feed to a custom python parser, to extract the links for only the serverless news. To extract the links to the serverless news posts, I used the Python library "Beautiful Soup 4", instantiating the object with the xml parser (this requires the Python lxml package to be installed as well):
Once I had the links to the news posts, I used the Python requests library to grab the content of the news posts:
After I get the post text for the LLM prompt, I append the beginning of a script, alternating between the two 'hosts'. I then use the boto3 Bedrock runtime client to generate a script based on the prompt (I used Claude 3 Sonnet as the model, but you can use any model you want!).
I then parsed the output into line-by-line chunks that I sent through two different Polly voices ("Ruth" and "Gregory", with the "long-form" engine), and then concatenated the outputs with the Python library pydub
Finally, I put all this code into a scheduled AWS Lambda, which runs and checks the RSS feed daily to see if there are any serverless news updates. If you're curious about how I deploy serverless Lambda stacks, check out this article on using AWS CDK to easily build and maintain serverless applications.
You now know how to build your own goofy podcast for all the latest AWS serverless news. I know the style I used isn't for everyone, so experiment with your own style and have fun!
 

Comments