This project uses OpenAI and Anthropic APIs to generate engaging conversations between two AI characters and converts them into audio podcasts using OpenAI's Text-to-Speech API.
- Generate natural conversations between two characters (currently a Painter and a Musician)
- Convert conversations to audio using OpenAI's TTS API
- Support for different voice options
- Save conversations as text files
- Combine multiple audio segments into a single podcast file
- Clone this repository
- Create a virtual environment and activate it:
python3 -m venv venv
source venv/bin/activate # On Windows, use: venv\Scripts\activate
- Install dependencies:
pip install -r requirements.txt
- Create a
.env
file in the project root with your API keys:
OPENAI_API_KEY=sk-xxxx
ANTHROPIC_API_KEY=sk-ant-xxxx
Run the conversation script to generate a dialogue between the characters:
python conversation.py
This will:
- Generate a conversation between a Painter and a Musician
- Save the conversation to a text file (e.g.,
conversation_YYYYMMDD_HHMMSS.txt
) - Display the conversation and associated costs
Convert a conversation text file to audio using:
python tts.py [conversation_file.txt] --speaker1 [voice1] --speaker2 [voice2]
Options:
[conversation_file.txt]
: Path to the conversation text file--speaker1
: Voice for the Painter (default: alloy)--speaker2
: Voice for the Musician (default: nova)
Available voices:
- Female voices: alloy, nova, shimmer
- Male voices: echo, fable, onyx
Example:
python tts.py conversation_20241216_192503.txt --speaker1 shimmer --speaker2 echo
The script will:
- Generate individual audio clips for each dialogue line
- Combine them into a single MP3 file
- Save the final audio in the
audio
directory
conversation.py
: Script to generate conversations using Claude and GPTtts.py
: Script to convert text conversations to audiorequirements.txt
: Project dependenciesaudio/
: Directory containing generated audio filestext/
: Directory containing saved conversation texts
01-openant-conversation.ipynb
: Original notebook for conversation generation02-tts.ipynb
: Original notebook for text-to-speech conversion
- Conversations are automatically saved with timestamps
- Audio files are saved in MP3 format
- The script will display API costs for conversation generation
- Make sure you have sufficient API credits for both conversation generation and audio conversion