Skip to content

SpacECE-India-Foundation/AIStoryGenerator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Story Generator

Overview

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.

Features

  • 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.)

Technologies Used

  • 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)

Installation

Prerequisites

Make sure you have the following installed:

  • Python (>=3.7)
  • pip (Python package manager)
  • Git (optional)

Steps

  1. Clone the repository

    git clone https://github.com/your-username/Story-Generator.git
    cd Story-Generator
  2. Create a virtual environment (Optional but recommended)

    python -m venv venv
    source venv/bin/activate  # For Linux/macOS
    venv\Scripts\activate    # For Windows
  3. Install dependencies

    pip install -r requirements.txt
  4. Set up environment variables

    • Create a .env file 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
  5. Initialize the database

    python -c "from app import db; db.create_all()"
  6. Run the application

    python app.py

    The application will be available at http://127.0.0.1:5000/.

API Endpoints

1. Generate a Story

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

2. Convert Story to Speech

Endpoint: /speak_story
Method: POST Payload:

{
  "story": "Once upon a time...",
  "language": "hi"
}

Response: Returns an audio file.

Folder Structure

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

Contributing

Feel free to submit issues and pull requests to improve the project.

License

This project is licensed under the MIT License.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors