This Python script generates an AI-powered podcast by creating a conversation between two speakers and converting it to speech. It uses OpenAI's GPT-4 for conversation generation and their Text-to-Speech API for audio synthesis.
- Generates engaging conversations based on input text
- Converts the conversation to speech using different voices for each speaker
- Combines individual audio files into a single podcast episode
- Cleans up temporary files after generation
- Python 3.7+
- OpenAI API key
- Required Python packages:
- openai
- pydub
-
Clone this repository or download the script.
-
Install the required packages:
pip install openai pydub -
Set up your OpenAI API key:
- Sign up for an OpenAI account and obtain an API key
- Replace
<your api key>in the script with your actual API key:openai.api_key = "your-actual-api-key-here"
-
Ensure you have ffmpeg installed on your system (required by pydub for audio processing).
-
Run the script:
python podcast_generator.py -
When prompted, enter the text you want to base your podcast conversation on.
-
The script will generate the conversation, convert it to speech, and combine the audio files.
-
Once complete, you'll find the generated podcast as
podcast.mp3in the same directory as the script.
- You can modify the
system_promptto change the style or context of the generated conversation. - Adjust the
speaker_voice_mapto use different OpenAI voices for the speakers. - The script currently uses "Ali" and "Lisa" as speakers. You can change these names in the system prompt and the speaker_voice_map.
- The script creates temporary audio files in an
audio-filesdirectory. These are cleaned up after the podcast is generated. - The quality and coherence of the generated conversation depend on the input text and the AI model's capabilities.
License is do-whatever-you-like :)
[Include guidelines for contributing to the project, if applicable]
If you encounter any issues or have questions, please write me :)