Create immersive stories from a sequence of images and listen to an AI-generated narration. This Streamlit app connects visual inspiration with Google Gemini for storytelling and gTTS for speech synthesis, making it simple to turn your photo sets into narrated tales.
- Interactive UI – Upload 1–10 images via the Streamlit sidebar and preview them in a responsive grid.
- Genre Control – Choose from
Comedy,Thriller,Fairy Tale,Sci-Fi,Mystery,Adventure, orMoraleto influence tone and structure. - AI-Authored Stories – Calls Google Gemini (
gemini-2.5-flash-lite) to weave a unified narrative that references every uploaded image. - Audio Narration – Converts the generated story into a playable MP3 using
gTTS. - Genre-Specific Closers – Mystery, Thriller, and Morale stories append solution, twist, or moral sections automatically.
.
├── app.py # Streamlit front-end and user workflow
├── story_generator.py # Story generation + narration helpers
├── requirements.txt # Python dependencies
├── .env # Local environment variables (not tracked)
└── README.md # Documentation
- Python 3.9+
- Pip (latest version recommended)
- A Google Generative AI API key with access to
gemini-2.5-flash-lite
Create a .env file in the project root with one of the following keys:
# .env
GENAI_API_KEY=your_google_generative_ai_key
# or
GOOGLE_API_KEY=your_google_generative_ai_keyThe app loads environment variables using
python-dotenv. If neither key is set, the app raises an initialization error.
- Create and activate a virtual environment (recommended).
- Install dependencies from
requirements.txt:pip install -r requirements.txt
- Ensure your
.envfile is configured. - Launch Streamlit from the project root:
streamlit run app.py
- Open the Streamlit URL in your browser (usually
http://localhost:8501).
- Upload between one and ten JPG/PNG images.
- Select a storytelling style from the dropdown.
- Click Generate Story and Narration.
- Read the generated story and optionally play the narration audio.
If generation fails, check your API key and network connectivity—error messages are surfaced in the UI.
- Adjust the prompt in
story_generator.py:create_advanced_prompt()to change persona, length, or tone. - Swap
gemini-2.5-flash-litefor another Gemini model if you need higher quality (note pricing/latency changes). - Modify
gTTSlanguage or speed insidenarrate_story()to localize narration.
- "API key not found" – Confirm your
.envfile is present and keys are spelled correctly. - Narration not generated –
gTTSrequires internet access. Ensure outbound connectivity to Google services. - Streamlit warnings about file types – The uploader accepts only
png,jpg, andjpegfiles.
Check the Streamlit logs in the terminal for additional stack traces when errors occur.
This project currently has no explicit license. Add one if you plan to distribute or open-source the application.