A Python script to generate an audio podcast episode using APIs from OpenAI (ChatGPT) and ElevenLabs. ChatGPT generates an informal commentary based on news headlines and ElevenLabs reads that out with a human-sounding voice.
Be aware that AI APIs are at an early stage and are likely to change over time.
The Python file uses the Japan Times RSS feed but others should work too, e.g. NPR, BBC News, etc.
Here's an example of the audio output (converted to video):
sample_audio_output_small.mp4
- OpenAI account and API key: https://platform.openai.com/account/api-keys
- ElevenLabs account and API key: https://beta.elevenlabs.io
- Python 3
- Download the files in this repository to a local directory.
- Make a proper copy of the example environment variables file:
$ cp .env.example .env
- Edit the new
.env
file to add your API keys, for example:
$ nano .env
Use this format in the .env
file:
OPENAI_API_KEY=YOUR-PRIVATE-KEY
ELEVENLABS_API_KEY=YOUR-PRIVATE-KEY
- Install any requirements using pip and the
requirements.txt
file. You may need to usepip3
instead ofpip
.
$ pip install -r requirements.txt
- Run the script and wait for it to generate an MP3 file. You may need to use
python3
instead ofpython
.
$ python create_podcast.py
- Hopefully it worked! If not, check you have enough credits for OpenAI and/or ElevenLabs.
- OpenAI ChatGPT API docs: https://platform.openai.com/docs/guides/chat
- ElevenLabs API docs: https://api.elevenlabs.io/docs