# AI-Lyrics-Generator

> Source: <https://dev.to/bscdevloper/ai-lyrics-generator-2oec>
> Published: 2026-10-04 17:03:25+00:00

This is a submission for the Hacktoberfest Weekend Challenge: Build for a Friend

What I Built

I built AI Lyrics Generator, a local AI-powered web application that helps a friend turn an idea, topic, or feeling into an original song.

The goal was simple: instead of struggling with a blank page or needing access to a paid AI service, my friend can enter a few details such as:

🎵 Song name or topic

🎸 Genre

😊 Mood

🌍 Language

📝 Number of verses

The application then generates an original song structure with sections such as verses, chorus, bridge, and final chorus.

The project runs locally using Qwen2.5-Coder 3B through Ollama, with a FastAPI backend and a lightweight HTML/CSS/JavaScript frontend.

The main problem I'm solving is making AI-assisted songwriting simple, accessible, and local.

Demo

🎥 Demo Video: Coming soon

🌐 Live Demo: Coming soon

The application can be run locally with Ollama, so users don't need a cloud AI API to generate lyrics.

Code

GitHub Repository

AI-Lyrics-Generator

[https://github.com/Bharatefb/AI-Lyrics-Generator](https://github.com/Bharatefb/AI-Lyrics-Generator)

The repository contains the complete frontend, FastAPI backend, prompt logic, and setup instructions.

Project Architecture

                 ┌─────────────────────┐

                 │       Browser       │

                 │                     │

                 │  Song / Topic       │

                 │  Genre              │

                 │  Mood               │

                 │  Language           │

                 │  Verse Count        │

                 └──────────┬──────────┘

                            │

                         HTTP POST

                            │

                            ▼

                 ┌─────────────────────┐

                 │       FastAPI       │

                 │                     │

                 │      /generate     │

                 └──────────┬──────────┘

                            │

                            ▼

                 ┌─────────────────────┐

                 │       Ollama        │

                 │                     │

                 │ qwen2.5-coder:3b    │

                 └──────────┬──────────┘

                            │

                            ▼

                 ┌─────────────────────┐

                 │   Generated Lyrics  │

                 └──────────┬──────────┘

                            │

                            ▼

                 ┌─────────────────────┐

                 │       Browser       │

                 │                     │

                 │  [Verse 1]          │

                 │  [Chorus]           │

                 │  [Verse 2]          │

                 │  [Bridge]           │

                 │  [Final Chorus]     │

                 └─────────────────────┘

How I Built It

The project is built around open-weight AI and local inference.

AI Model

I use:

Qwen2.5-Coder 3B

through:

Ollama

The model runs locally on the user's machine rather than requiring a remote AI API.

Backend

The backend is written in:

Python

FastAPI

Pydantic

Requests

Uvicorn

The frontend sends the user's song requirements to the FastAPI /generate endpoint.

FastAPI then builds a structured prompt and sends it to the local Ollama API.

Browser

   ↓

POST /generate

   ↓

FastAPI

   ↓

Ollama

   ↓

qwen2.5-coder:3b

   ↓

Generated lyrics

   ↓

Browser

Frontend

The frontend uses standard web technologies:

HTML

CSS

JavaScript

No large frontend framework is required, keeping the project simple and easy to understand.

Prompt Design

Instead of simply asking the model:

Write a song about summer.

the application provides structured information:

Song/topic: Summer Love

Genre: Pop

Mood: Happy

Language: English

Number of verses: 3

The model is instructed to create completely original lyrics and organize them into a recognizable song structure.

For example:

[Verse 1]

...

[Pre-Chorus]

[Chorus]

[Verse 2]

[Bridge]

[Final Chorus]

Local AI

One of the key parts of the project is that the AI inference happens locally.

After installing Ollama and the model:

ollama pull qwen2.5-coder:3b

the application can communicate with the local Ollama API.

This means the basic application does not require an OpenAI, Anthropic, Gemini, or other paid cloud AI API.

Why Does Open Innovation Matter?

Open innovation made this project possible because I could build around an openly available model and run inference locally.

A closed AI API would certainly make the implementation possible, but local open-weight inference gives the project some important advantages.

🔒 More control

The user controls where the model runs and how the application communicates with it.

💻 Local-first development

The project can be developed and tested without requiring a cloud AI account or API key.

💰 Lower barrier to experimentation

Anyone with suitable hardware can experiment with the application without paying for every generated song.

🧑💻 Learning and customization

Because the application controls the prompt, backend, frontend, and model connection, developers can modify the entire pipeline.

They can experiment with:

Prompt engineering

Different models

Temperature settings

Song structures

Languages

Genres

UI features

Local AI workflows

🌍 Open innovation encourages experimentation

The most interesting part for me is that the AI is not treated as a black box.

The project connects an open model, local inference, a Python backend, and a web interface into one small application.

That makes it easier to learn how AI applications actually work from end to end.

My Agent Session

I did not use DevRelay for this project.

Prize Categories

The project is primarily entering the categories related to:

🤖 Open-source AI / open-weight models

🖥️ Local AI / local inference

🧑💻 Developer tools and AI applications

Project Stack

AI Model       → Qwen2.5-Coder 3B

Inference      → Ollama

Backend        → Python + FastAPI

Frontend       → HTML + CSS + JavaScript

API            → REST / JSON

Runtime        → Local machine

Running the Project Locally

Clone the repository:

git clone [https://github.com/Bharatefb/AI-Lyrics-Generator.git](https://github.com/Bharatefb/AI-Lyrics-Generator.git)

cd AI-Lyrics-Generator

Install and run the Qwen model:

Set up the backend:

cd backend

python -m venv venv

On Windows:

venv\Scripts\activate

On macOS/Linux:

source venv/bin/activate

Install dependencies:

pip install -r requirements.txt

Start FastAPI:

uvicorn main:app --reload --port 8000

Then open the frontend using a local development server such as VS Code Live Server.

What's Next?

I plan to continue improving the project with features such as:

🔄 Generate Again

📋 Copy Lyrics

💾 Download Lyrics

📝 Edit generated lyrics

📚 Song history

🌍 Better multilingual support

🎤 More vocal and writing controls

🎶 Custom verse/chorus structures

🎨 Improved UI

🌙 Dark/light mode

⚡ Streaming generation

The long-term goal is to make AI-assisted songwriting a simple local-first experience that anyone can experiment with.

Built with ❤️, open-source AI, and a little musical inspiration.

Thanks for checking out AI-Lyrics-Generator! 🎵
