An interactive, choose-your-own-adventure style story generator powered by LangChain + Groq (Llama 3.3 70B). It dynamically branches narratives based on user-defined configurations and choices, generating real-time scene illustrations and voice narrations.
- Live Hosted Application (Vercel/Streamlit): https://ai-storyteller-machine.streamlit.app
- GitHub Repository: https://github.com/VimalN2005/AI-Storyteller-Machine
The application orchestrates narrative flow, visual generation, and audio rendering in a single runtime loop:
graph TD
A[Streamlit Web UI] -->|1. Setup Config / User Choices| B[Story Engine - LangChain + Groq]
B -->|2. Generate Passage & 3 Options| A
A -->|3. Trigger Image Generation| C[Pollinations.ai Image API]
C -->|4. Return Scene Illustration URL| A
A -->|5. Trigger Voice Narration| D[gTTS - Google Text-to-Speech]
D -->|6. Stream Narration Audio| A
A -->|7. Export Full Story| E[Local Text File Download]
- Defines custom story parameters: Genre, Tone, Protagonist Name, Supporting Characters, and Core Premise.
- Generates 3 dynamic, contextual choice prompts after every passage, with an additional "Type Your Own Direction" text box for total creative freedom.
- Ends the adventure gracefully with a user-controlled ending option.
- Auto-generates high-fidelity scene images for every generated passage using the Pollinations.ai keyless text-to-image API.
- Allows user-configured toggles to enable/disable image loading for slower connections.
- Narrates the generated passage in real-time using Google Text-to-Speech (gTTS).
- Offers audio-playing controls right on the UI with simple toggles.
- Leverages LangChain's memory states to preserve previous story paths, character details, and narrative consistency.
- Allows users to download the complete story log as a
.txtfile upon ending the game.
| Layer | Technology |
|---|---|
| Frontend/UI | Streamlit |
| LLM Orchestration | LangChain |
| Inference Engine | Groq Cloud API (Llama 3.3 70B) |
| Image Generation | Pollinations.ai API |
| Text-to-Speech | gTTS (Google Text-to-Speech) |
| Configuration | Dotenv (Python-dotenv) |
ai_storyteller/
├── app.py # Streamlit UI & layout definitions
├── story_engine.py # LangChain prompt templates & Groq API routing
├── image_gen.py # Pollinations.ai image query helper
├── tts.py # Audio conversion and gTTS file handling
├── requirements.txt # Declared package dependencies
├── .env.example # Sample environment template
├── .gitignore # Excludes secret credentials
└── README.md # Project documentation
git clone https://github.com/VimalN2005/AI-Storyteller-Machine.git
cd AI-Storyteller-Machine
pip install -r requirements.txtCopy .env.example to .env and fill in your free Groq API key:
GROQ_API_KEY=your_groq_api_key_herestreamlit run app.pyAI Storyteller Machine: Built an interactive choose-your-own-adventure story generator using LangChain + Groq Llama 3.3. Orchestrated dynamic branching story paths based on user preferences, integrating the Pollinations.ai API for on-the-fly scene illustrations and gTTS for automated voice narration.