This is a Flask-based web application that generates short stories based on user input using Google's Gemini AI model. It allows users to specify age, gender, mood, interests, and other parameters to create customized stories. The application also includes a text-to-speech feature to convert stories into audio in multiple languages.
- Generate short stories based on user input
- Store generated stories in a database
- Convert stories into speech using Google Text-to-Speech (gTTS)
- Translate stories into different languages (Hindi, Marathi, etc.)
- Flask (Backend Framework)
- Google Generative AI (Gemini API) (Story Generation)
- Flask-SQLAlchemy (Database ORM)
- Google Text-to-Speech (gTTS) (Audio Generation)
- Deep Translator (Language Translation)
- Dotenv (Environment Variable Management)
Make sure you have the following installed:
- Python (>=3.7)
- pip (Python package manager)
- Git (optional)
-
Clone the repository
git clone https://github.com/your-username/Story-Generator.git cd Story-Generator -
Create a virtual environment (Optional but recommended)
python -m venv venv source venv/bin/activate # For Linux/macOS venv\Scripts\activate # For Windows
-
Install dependencies
pip install -r requirements.txt
-
Set up environment variables
- Create a
.envfile in the project root and add the following:API_KEY=your_google_gemini_api_key DB_URI=sqlite:///stories.db # Use SQLite for local development
- Create a
-
Initialize the database
python -c "from app import db; db.create_all()" -
Run the application
python app.py
The application will be available at
http://127.0.0.1:5000/.
Endpoint: /generate_story
Method: POST
Payload:
{
"age": 6,
"gender": "boy",
"mood": "happy",
"interests": "adventure",
"story_length": "short",
"time_of_day": "bedtime",
"additional": "Include a magical pet."
}Response:
{
"story": "Once upon a time..."
}Endpoint: /speak_story
Method: POST
Payload:
{
"story": "Once upon a time...",
"language": "hi"
}Response: Returns an audio file.
Story-Generator/
│── templates/
│ ├── form.html
│── app.py # Main Flask application
│── gemini.py # Story generation using Gemini API
│── requirements.txt # Dependencies
│── .env # Environment variables (not included in repo)
│── README.md # Project documentation
Feel free to submit issues and pull requests to improve the project.
This project is licensed under the MIT License.