Skip to content

asadsandhu/LSTM-Poetry-Generator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

6 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ•ŠοΈ Roman Urdu Poetry Generator

AI-Powered Poetic Expression in Roman Urdu

🌸 β€œWhere code meets emotion, and verses are born from data.” 🌸


Python PyTorch Gradio License: MIT


🌟 Overview

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)

🧠 How It Works

  1. The model reads your starting phrase (e.g., β€œaaΓ±kh se”).
  2. It predicts the next most likely word, one token at a time.
  3. Words are grouped into lines, forming rhythmic verses.
  4. 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.


βš™οΈ Tech Stack

Component Technology
🧩 Model Type LSTM (Long Short-Term Memory Network)
🧠 Framework PyTorch
πŸ’¬ Interface Gradio
πŸ“ Dataset Roman Urdu Poetry.csv
🧾 Language Python 3.9+

🧩 File Structure


πŸ“‚ 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 :)


πŸš€ Getting Started

πŸ”§ 1. Clone the Repository

git clone https://github.com/your-username/Roman-Urdu-Poetry-Generator.git
cd Roman-Urdu-Poetry-Generator

πŸ“¦ 2. Install Dependencies

pip install torch gradio numpy

πŸ’‘ 3. Run the App

python app.py

This will automatically launch the Gradio interface in your browser. 🌐


πŸ’» Gradio Interface Preview

🎀 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

πŸͺΆ Example Output

Input:

Starting Word: aaΓ±kh Number of Words: 25 Temperature: 1.0 Words 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.


🧩 Model Details

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

πŸ“š Dataset

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..."

🎨 Future Enhancements

βœ… 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)


🀝 Contributing

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 request

πŸͺ™ License

This 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


About

πŸͺΆ Roman Urdu Poetry Generator β€” An AI-powered LSTM model that composes soulful Roman Urdu poetry. Trained on classic verses and deployed with Gradio, it lets you craft poetic lines in real time with adjustable creativity, structure, and emotion. β€οΈπŸš€

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages