Transform your stories into beautifully illustrated storybooks using AI! This application analyzes your text, breaks it into scenes, and generates stunning illustrations for each scene using multiple AI services.
- Story Analysis: Uses Google AI Studio (Gemini) to analyze stories and extract visual elements
- Scene Detection: Automatically breaks stories into illustrated scenes
- Character Recognition: Automatically detects character gender and assigns consistent names (Nave for male, Lia for female)
- Smart Character Mode: Enhances prompts with character information for consistent illustrations
- Visual Direction: Extracts facial expressions, colors, lighting, poses, and composition
- Reference Images: Generates initial reference images using Google AI Studio
- High-Quality Illustrations: Creates final images using Replicate.com models (Ideogram V3 Turbo default)
- Multiple Art Styles: Supports realistic, cartoon, anime, watercolor, and oil painting styles
- Flexible Aspect Ratios: Support for various aspect ratios (square, landscape, portrait, etc.)
- Web Interface: User-friendly interface for story input and storybook viewing
- HTML Export: Generates beautiful HTML storybooks for easy sharing
- Node.js 16+ and npm
- API Keys (only 2 required!):
- Google AI Studio API Key
- Replicate API Token
- Clone the repository:
git clone https://github.com/yourusername/AiStoryBookGenerator.git
cd AiStoryBookGenerator- Install dependencies:
npm install- Create a
.envfile from the example:
cp .env.example .env- Add your API keys to the
.envfile:
GOOGLE_AI_STUDIO_API_KEY=your_google_ai_studio_api_key_here
REPLICATE_API_TOKEN=your_replicate_api_token_here
PORT=3000- Visit Google AI Studio
- Sign in with your Google account
- Go to API Keys section
- Generate a new API key
- Go to Replicate
- Create an account or sign in
- Navigate to Account Settings
- Find your API token
- Start the development server:
npm run dev- Open your browser and navigate to:
http://localhost:3000
-
Use the web interface to:
- Paste your story text
- Select art style and target audience
- Configure advanced settings (optional)
- Click "Generate StoryBook"
-
View your generated storybook in the browser or download the HTML file
AiStoryBookGenerator/
βββ src/
β βββ server.ts # Express server setup
β βββ routes/
β β βββ storyRoutes.ts # API endpoints
β βββ services/
β β βββ storyAnalyzer.ts # OpenAI GPT integration
β β βββ googleAIStudio.ts # Google AI Studio integration
β β βββ replicateService.ts # Replicate.com integration
β β βββ storyBookGenerator.ts # Main generation logic
β βββ types/
β βββ index.ts # TypeScript type definitions
βββ public/
β βββ index.html # Main web interface
β βββ css/
β β βββ style.css # Styling
β βββ js/
β βββ app.js # Frontend JavaScript
βββ output/ # Generated storybooks
βββ uploads/ # Temporary file uploads
βββ package.json
POST /api/generate-storybook- Generate a complete storybookPOST /api/analyze-story- Analyze story without generating imagesGET /api/storybooks- List all generated storybooksGET /api/storybook/:id- Get specific storybook detailsGET /api/health- Check API keys status
- Style: realistic, cartoon, anime, watercolor, oil-painting
- Target Audience: children, young-adult, adult
- Use Google Reference: Enable/disable reference image generation
- Image Dimensions: 512-2048 pixels
- Inference Steps: 20-100 (higher = better quality, slower)
- Guidance Scale: 1-20 (higher = more prompt adherence)
- Ideogram V3 Turbo (default) - Fast, high-quality, text-capable
- Smart Character Mode - Auto-detects character gender and uses consistent naming (Nave/Lia)
- SDXL - Traditional diffusion model
- Stable Diffusion 2.1 - Classic option
- OpenJourney - Artistic style
The application includes an intelligent character recognition system:
- Automatic Gender Detection - Analyzes story content to identify main character gender
- Consistent Naming - Uses "Nave" for male characters, "Lia" for female characters
- Enhanced Prompts - Automatically enhances image generation prompts with character information
- Character Continuity - Ensures consistent character appearance across all scenes
npm run devnpm run buildnpm startTitle: The Brave Little Robot
Once upon a time, in a futuristic city filled with towering skyscrapers and neon lights, there lived a small robot named Beep. Beep had bright blue eyes that glowed in the dark and silver metallic body that sparkled under the city lights.
One day, Beep discovered that the city's main power source was failing. The giant crystal that powered everything was losing its glow. Beep knew he had to help.
Despite being the smallest robot in the city, Beep ventured into the dangerous underground tunnels. There, he found the problem - a massive tangle of broken cables.
Working through the night, Beep carefully repaired each cable with his tiny tools. As the sun rose, the crystal began to glow again, brighter than ever.
The city celebrated Beep as a hero, proving that even the smallest among us can make the biggest difference.
- Ensure all API keys are correctly set in the
.envfile - Check the Settings tab in the web interface to verify API status
- Restart the server after adding API keys
- Check your Replicate account has sufficient credits
- Verify Google AI Studio API is enabled
- Try reducing image dimensions or inference steps
- Reduce the number of scenes by writing shorter stories
- Lower image resolution in advanced settings
- Process one story at a time
Contributions are welcome! Please feel free to submit a Pull Request.
ISC License
- OpenAI for GPT story analysis
- Google AI Studio for reference generation
- Replicate for high-quality image generation
- All the AI models and services that make this possible
For issues, questions, or suggestions, please open an issue on GitHub.