πΈ βWhere code meets emotion, and verses are born from data.β πΈ
Roman Urdu Poetry Generator is an AI-based text generator that creates poetic verses in Roman Urdu, inspired by the works of poets like Ahmad Faraz and Mir Taqi Mir.
Built using LSTM (Long Short-Term Memory) networks in PyTorch, the model learns from a curated dataset of Urdu poetry transliterated into Roman script. It then composes new, coherent poetic lines β often surprisingly soulful. π«
You can interact with it through a Gradio Web App, adjusting:
- π¨ Creativity (
temperature) - βοΈ Poem length (
number of words) - π Structure (
words per line)
- The model reads your starting phrase (e.g., βaaΓ±kh seβ).
- It predicts the next most likely word, one token at a time.
- Words are grouped into lines, forming rhythmic verses.
- You control how βcreativeβ or βlogicalβ the poem sounds with the temperature slider.
πͺ A higher temperature = more creativity & randomness. A lower one = more structure & logic.
| Component | Technology |
|---|---|
| π§© Model Type | LSTM (Long Short-Term Memory Network) |
| π§ Framework | PyTorch |
| π¬ Interface | Gradio |
| π Dataset | Roman Urdu Poetry.csv |
| π§Ύ Language | Python 3.9+ |
π Roman-Urdu-Poetry-Generator
β
βββ π app.py # Main app (model + Gradio UI)
βββ π poetry_model.pth # Trained LSTM model checkpoint
βββ π Roman-Urdu-Poetry.csv # Training dataset (poems in Roman Urdu)
βββ π README.md # You're reading this :)
git clone https://github.com/your-username/Roman-Urdu-Poetry-Generator.git
cd Roman-Urdu-Poetry-Generatorpip install torch gradio numpypython app.pyThis will automatically launch the Gradio interface in your browser. π
π€ Roman Urdu Poetry Generator
Generate poetic verses in Roman Urdu using an AI trained on classic poetry.
| Input | Control |
|---|---|
| πͺΆ Starting Word | βaaΓ±khβ, βdilβ, βishqβ, etc. |
| π’ Number of Words | Choose total poem length |
| π₯ Creativity (Temperature) | Adjust imagination level |
| π Words per Line | Control verse structure |
Input:
Starting Word:
aaΓ±khNumber of Words:25Temperature:1.0Words per Line:4
Generated Poetry:
aaΓ±kh se duur na ho dil se utar jaayega
waqt ka kya hai guzarta hai guzar jaayega
itna maanus na ho khalvat-e-gham se apni
tu kabhi khud ko bhi dekhega to dar jaayega
π« Sometimes, even AI has feelings.
The model uses a multi-layer LSTM network to learn sequential word patterns from poetry.
Model Configuration:
- Embedding Dimension:
128 - Hidden Dimension:
256 - LSTM Layers:
2 - Dropout:
0.2 - Optimized for Roman Urdu poetic syntax
The dataset Roman-Urdu-Poetry.csv contains handpicked poems from various Urdu poets transliterated into Roman Urdu. Each record includes:
- Poetβs Name
- Original Roman Urdu Poem Text
π§Ύ Example entry:
Poet: ahmad-faraz Poetry: "aaΓ±kh se duur na ho dil se utar jaayega..."
β Add multilingual support (Urdu script + English translations) β Train on larger poetry datasets (Mir, Faiz, Iqbal) β Implement rhyme & rhythm detection β Add voice output using TTS (Text-to-Speech)
Contributions are always welcome! π¬ If youβd like to enhance the model, improve training data, or design a better interface, feel free to:
fork -> code -> commit -> pull requestThis project is licensed under the MIT License β free to use, modify, and share.
See the LICENSE file for details.
β¨ βPoetry is not written by code β itβs awakened by it.β β¨
Made with β€οΈ using Python, PyTorch & Gradio