跳到正文
DEV Community· Anamul Hoque·· 3 小時前AI 評分45

Ghost Tales:以鬼故事學英文,Gemma 在本機執行

Ghost Tales: Learn English Through Ghost Stories, Running Locally with Gemma

AI 導讀

Ghost Tales 是一款以鬼故事教英文的網頁應用程式,使用 Ollama 在本機執行 Gemma,逐句生成英文故事並翻譯成孟加拉語。應用程式使用 gemma4:12b,示範中即使關閉 Wi-Fi,故事生成、翻譯和朗讀功能仍可在 Mac 上運作。

正文

This is a submission for the Hacktoberfest Open-Source AI Challenge Week 4: Ghost in the Machine.

What I Built

Ghost Tales (ভূতের কথা in Bengali) is a small web app that teaches English through ghost stories, with Bengali beside every sentence. A local model, Gemma through Ollama, writes each story and translates it on my own Mac.

You pick a place, such as an old zamindar mansion or a river ghat at dusk. You pick a mood: spooky, or a gentle "memory ghost". You can name the hero. The story is typed out one sentence at a time, and each sentence is then translated into Bengali. The two languages sit side by side.

I live in Bangladesh. I wanted a language tool that needs no account, no subscription and no constant connection. A story you enjoy is easier to remember than a list of words, and a tool that runs on your own machine is easier to trust.

The ghost in my machine is the model itself. It lives in my own computer and tells stories by lamplight.

Demo

In the video I switch Wi-Fi off on screen, and it stays off for the rest of the recording. Story writing, translation and the Listen button all worked on my Mac that way. The narration was generated with ElevenLabs. The quiet ambient sound in the middle of the video is the app's own, synthesized in the browser and captured with system audio; the Listen voice is not included. The recording is edited: some waiting time was cut or sped up.

The app has three learning helpers:

  • Side by side: English on one side, Bengali on the other.
  • Learn mode: the English is blurred. Read the Bengali, guess the English, then click to reveal it.
  • Listen: the browser reads each sentence aloud with a speech voice from my system. On my Mac both an English and a Bengali voice were available, and both sound robotic. I did not check whether every voice runs locally or online.

Here is the last pair from the run in the screenshot above, unedited:

Some memories never leave us, they just become part of the home.
কিছু স্মৃতি কখনো আমাদের ছেড়ে যায় না, সেগুলো শুধু ঘরের অংশ হয়ে যায়।

Code

https://github.com/AnamulAI/ghost-tales

One index.html file, a README and an MIT licence. No framework, no build step, no external fonts or scripts. To run it: ollama pull gemma4:12b, then python3 -m http.server 8000 in the folder, and open http://localhost:8000.

Submission snapshot: tag submission-v1 (view).

How I Built It

Gemma, locally, through Ollama. The page calls Ollama on http://localhost:11434 and uses gemma4:12b (a 7.7 GB download). I tested on an Apple M4 Mac with 16 GB of RAM. In my own testing the model writes natural Bengali, which is the main reason I chose it.

Two steps, not one. Step one streams an English story of about 12 short sentences, at level A2 to B1. Step two sends each sentence to the model on its own and asks for the Bengali only. Small models tend to be more accurate on short inputs; a whole-story translation has more room to drift, skip lines or add notes.

The think: false finding. Gemma 4 can "think" before it answers. In a manual test in the Ollama app, one short translation spent about 25 seconds thinking. That is far too slow for a dozen sentences, so the app sends think: false (and retries without it if an Ollama version rejects the field). With thinking off, three test stories took 23 to 31 seconds in total, and a single sentence took about 1.1 to 1.3 seconds on average (raw outputs are in sample-stories.md). The 25-second figure came from a different manual test, so it is not a controlled comparison, but the gap made the choice easy.

Telling the story slowly. By default each English sentence is typed out over a few seconds, then the Bengali fades in. There is a faster pace and a tap mode. In one test run at the default pace, the last sentence appeared about 50 seconds after Begin, and all twelve translations were done a few seconds later.

Local only, on purpose. The model picker reads your installed models from Ollama and hides any with "cloud" in the name, because some Ollama models run on remote servers. That keeps story writing and translation on the machine.

The look and the sound. The page is a haunted storybook by lamplight: a layered night scene with a moon, fog and fireflies that shift as you move the mouse, and a palette for each mood. Sound is synthesized in the browser with the Web Audio API, with no audio files: a quiet ambient bed for each place, and short effects triggered by words in the sentence on screen. Sound is off until you press the Sound button. I tried the visuals and sound only on my own Mac, in one browser.

Honest limits.

  • Translation mistakes happen. My AI assistant checked three test stories and found a few clear defects: a stray Russian word at the start of one line, a garbled phrase, and a stray Latin letter inside a word. Most lines looked fine, but a small model's Bengali still needs review by a person. The page says so.
  • The Listen voices are robotic, and Bengali speech needs a Bengali voice on your system.
  • I have not run a user study, so I do not know yet how much it helps people learn.
  • My code is MIT licensed. The Gemma model has its own terms, which I have not reviewed in detail.

What comes next. Test it with real learners, add a "check my translation" mode, review the Bengali with native speakers, and try an open text-to-speech model for more natural voices.

AI tools helped build this project. I used Claude and Claude Code for code, tests and drafts, and I ran the app myself on my Mac, including with Wi-Fi switched off.

Why Does Open Innovation Matter?

A model that runs on your own machine can't be switched off, repriced or turned into a data pipeline. That matters most for learners with little money or a patchy connection. Open weights also let me inspect, swap and test the model: when I wanted a faster setting, I changed one flag and measured the result.

The Spirit of It

Ghost stories are how many of us first learned how language can pull you in. It felt right that a ghost story be the thing a machine tells, in two languages, on a computer that stays in the room with you.

Prize Categories

  • Best Use of Gemma: the whole app is built around Gemma (gemma4:12b) running locally through Ollama, for both story writing and Bengali translation.
  • Best Use of ElevenLabs: I used ElevenLabs (Eleven v4, voice "Wyman - The Storyteller", with audio tags for tone) to generate the narration for the demo video. It is not used inside the app, on purpose: story writing and translation stay on the computer.

來源:DEV Community · dev.to