Inspiration
What inspired me One evening in Nagpur I was trying to tell my little cousin a bedtime story, but I ran out of ideas after two sentences. She looked so disappointed. That moment stuck with me — I thought: what if anyone, anywhere, could instantly turn a random thought into a complete, beautiful fairy tale with pictures and a voice reading it aloud? That single disappointed face became the spark for StoryMate. what it does? It builds magical stories for you of your desired topic wuth just one click you can read the text as output get images and get an audio narration.You can set the playback speed for audio narration and also you can download it What I learned I learned how powerful prompt engineering really is. Getting Gemini to always output exactly three scenes in the right markdown format took many failed generations and careful re-wording. I also discovered how different Gemini models feel in practice: 2.0 Flash is fast and creative for stories, Imagen 4 Ultra gives dreamy illustrations, and the preview TTS model adds real emotion when you choose the right voice (Kore ended up being my favorite). Most importantly, I learned that small UX details — glowing cards, balloons on success, placing audio at the top — turn a technical demo into something that actually feels magical. How I built it I started with a simple Streamlit text input and button. Then I added session state so the story, images and audio persist after generation. I wrote strict prompts to force three scenes and used regex to parse them reliably. Images are generated one per scene with scene-specific prompts. Audio comes from the full concatenated story fed to the TTS preview model, then converted from PCM to WAV in memory using the wave module. The three-column layout with fantasy CSS gradients and shadows was the most fun part — I spent hours tweaking colors until it felt like opening a real storybook. Everything runs locally with my paid Gemini API key stored in .env. Challenges I faced The biggest challenge was reliability. Gemini sometimes ignored the “exactly three scenes” instruction or changed the Scene X: header format, breaking my parser. I fixed it by making the prompt extremely repetitive and rigid. Image generation occasionally produced off-topic pictures, so I limited the prompt length and added “storybook style, vibrant colors, perfect for children”. TTS was tricky because it’s a preview model — latency was high and sometimes the narration sounded flat until I added “warm, enchanting, storytelling voice with emotion” to the prompt. Parsing the raw PCM bytes into playable WAV without external libraries took trial and error. Finally, making the UI responsive on mobile while keeping the three columns readable was harder than expected — lots of media-query tweaks. In the end, every frustration was worth it. When my cousin heard her own story being read aloud with pictures appearing one by one, her eyes lit up — the same way I hope it lights up for other users. Thank you for reading my little journey. 🧚
Built With
- geminiliveapi
- genaisdk
- python
Log in or sign up for Devpost to join the conversation.