A desktop GUI application built with Python and Tkinter that uses OpenAI’s API to generate original song lyrics or poems based on a user prompt.
This project demonstrates:
- API integration
- GUI development with Tkinter
- Environment variable management
- Clean, reproducible project structure
- Generate song lyrics or poems
- Choose from token length presets
- Short (100)
- Medium (200)
- Long (400)
- View generation history
- Save generated lyrics to a
.txtfile - Simple, clean desktop UI
- Python 3.11+
- Tkinter – GUI framework
- OpenAI API
python-dotenv– environment variables
SongLyricGenerator/
│
├── api/ # OpenAI API logic
│ ├── __init__.py
│ └── openai.py
│
├── gui/ # Tkinter UI
│ ├── __init__.py
│ └── main_window.py
│
├── main.py # Application entry point
├── requirements.txt # Python dependencies
├── .gitignore # Ignored files/folders
├── .env.example # Environment variable template
├── song-lyrics.ico # App icon
└── README.md # Project documentation
- Clone the repository
git clone https://github.com/yourusername/SongLyricGenerator.git
cd SongLyricGenerator
- Create a virtual environment
python -m venv .venv
Activate it: Windows
.venv\Scripts\activate
- Install dependencies
pip install -r requirements.txt
- Set up environment variables
cp .env.example .env
Edit .env and add your OpenAI key:
OPENAI_API_KEY=your_real_key_here
python main.py
- Enter a prompt like:
A song about learning to code at 2am
- Choose:
Song or Poem
-
Token length (Short / Medium / Long)
-
Click Generate Lyrics
Optionally:
View history
Save output to a file
-
Your real API key lives in .env
-
.env is ignored by Git
-
.env.example shows required variables for others
-
This ensures secrets are never committed.