DEV Community

Cover image for Gemini, tell me a story

Gemini, tell me a story

A French version is available here.

Vacation time 🌴

We are at the end of July, it's my last day before my vacation. I attend several meetings, close several items on my TODO list, and end my day by shutting down my MacBook, happy to go on vacation after a very busy period. My single goal for the next 2 weeks: forget IT!

The next day, my very first day of vacation, we receive a story box at home for our four-year-old son: a Lunii.

Lunii

Image from the Lunii website: https://lunii.com/fr-fr/products/ma-fabrique-a-histoires-verte

This is the second story box for our son; he wasn't really interested in the first one (a Tonie) despite the characters placed on top. It was hard for him to be calm and listen to stories. The Lunii is more portable with headphones, we are counting on it to fill some moments during our vacation, and especially during the long time in car.

Stories can be found on the Lunii website, and it's also possible to record audio. This let us curious because we plan to record our own voices to read books or create custom stories.

But ...

💡 A new application?

My brain left its fresh vacation mode and saw an opportunity: generating stories with AI. Because while our imagination can create stories, AI can also take us into domains or characters we have not imagine.

Even though Gemini allows doing this in its interface, I decided to take my laptop and build a story generator application to try to save them on the Lunii 🚀.

The first step consists of creating an application (of course with Quarkus and the Quinoa extension to have an integrated frontend) that generates stories for a 4-year-old child base on some contexts. I decided to choose two story formats:

  • Short format: about two minutes of listening.
  • Long format: more than five minutes.

This application will allow me to generate a story randomly, or based on a prompt: a character, a place, and a context. I ask my son what kind of characters he would like, so I can save characters in the application to build a "series" of stories featuring the same characters. To illustrate the stories, a call to Google's image generation model, Nano Banana, and off we go.

Here I am with the first baseline of my story generator.

Application home page

Story settings

➡️ At this point, these stories could be transferred to our son's Lunii by recording our reading.

🗣️ Step 2: Integrating Text-to-Speech

At this stage of implementation, of course I had something else in mind: converting these text stories into audio. AI models are evolving, and the latest versions of Gemini models allow text-to-speech with emotional nuance. Time to integrate this feature! After tweaking a few settings, the French voice sounds really nice for listening to stories, whether you're a parent or a child 😁.

➡️ At this stage, my app can generate stories that can be listened to and downloaded as MP3s. Perfect!

Text-to-Speech integration

🧩 An integration with Lunii?

To push it even further, couldn't we copy these MP3 files directly into the Lunii? At first glance no, Lunii requires a specific format. After a quick search online, I stumbled upon an open-source project: Studio. Developed in Java, this project provides a graphical interface to build Lunii-compatible stories from MP3 files.

After fetching the project on my machine, I took a look at its multi-module architecture. To run it, I naturally had to compile the project, which built the various modules into my local repository.

Using my image and MP3 file, I quickly managed to import this story into the Studio project, generate the Lunii format version, and copy it onto the story box's card. Perfect!

➡️ So I can generate a story, get the MP3 file, prepare the zip file using the Studio project, and transfer it to the box in just a few clicks. It's really satisfying. My son, listening to the first stories, enjoys them immensely. When the little boy in the story shares his name, it creates an immediate Wow effect. With this, we will be able to spark his imagination and help him unwind with his story box.

🤔 What's next?

My application is written in Java, and also the Studio project. To generate and copy a story, I have to start my application (yes, I know I could have quickly deployed it to Cloud Run, but wait... I'm on vacation, let's not forget that 😁), and launch the Studio project. That makes it two steps.

Looking at the modules of the Studio project, I quickly realized I could integrate some of them directly into my application to get a seamless connection and Lunii management straight from my app.

Maven modules of the Studio project

And after a few tests and integrating the core, drive, and metadata modules, it's done! My app, via a dedicated menu, allows me to manage the story and copy it to the Lunii in a few clicks 🤩.

Final application overview

A big thank you to marian-m12l for creating this project, and to its open-source community who kept it evolving along with Lunii's hardware revisions.

⚠️ The main goal of this article is to show how, in a personal project, I experimented with Gemini models to generate stories in both text and audio form. It is important to emphasize that integration with Lunii via the Studio project operates outside of Lunii's official closed ecosystem and may potentially diverge from the brand's terms of service.

🤖 Using models gemini-3.1-flash-tts-preview and gemini-3.5-flash-lite.

👉 The project is available on GitLab: https://gitlab.com/jeanphi-baconnais-experiments/kids-histories-generator.

Top comments (0)