Story video
The learner is studying Japanese and may speak any language. They want their practice stories as a picture story: one image per sentence that shows what is being said, the narration as audio, and Japanese subtitles as a separate .srt. The video does not need to be animated. It must hang together from start to finish: the same characters, the same world. Talk to the user in the language they write to you in. Never assume anyone's pronouns.
SKILL = the folder this file is in. The scripts are in SKILL\scripts\. Run them with PowerShell 7 (pwsh), never with Windows PowerShell 5, which garbles Japanese in the script text. From Bash: pwsh -NoProfile -File "<script>" -Dir "<WORK>".
Requirements
| What | Notes |
|---|---|
| Windows + an NVIDIA GPU | Tested on 16 GB VRAM: about 5 s per 1344×768 image at 30 steps. SDXL needs about 8 GB or more. |
| ComfyUI (Windows portable) | COMFYUI_ROOT = the folder that holds run_nvidia_gpu.bat (default C:\ComfyUI_windows_portable). From the GitHub releases of comfyanonymous/ComfyUI, ComfyUI_windows_portable_nvidia.7z. |
| Image model | sd_xl_base_1.0.safetensors in COMFYUI_ROOT\ComfyUI\models\checkpoints\ (Hugging Face stabilityai/stable-diffusion-xl-base-1.0). Another SDXL checkpoint works with gen_images.ps1 -Checkpoint <file>. |
| ffmpeg / ffprobe | On PATH |
| Anki Miner | For the .srt (AnkiMiner.exe --api sync, Audiobook sync), installed under %LOCALAPPDATA%\Programs\AnkiMiner. Without it, write the .srt by hand from known timings, or use any forced aligner. |
| A Japanese TTS | Any voice that writes a WAV. |
If something is missing, tell the user what and where, and ask before downloading anything (ComfyUI is about 2 GB, the SDXL model about 7 GB).
Steps
1. Work folder, text and audio
- WORK = a new folder for this video, next to the story if the story is a file (e.g.
<story folder>\video-<short ascii name>\). WORK\story.txt: the title on line 1, then one sentence per line, exactly as spoken (no speaker tags such as 【friend】, no markdown).WORK\story.wav: the narration, which must read the title first, just like the .txt. If the user has none, ask which TTS and voice to use.- Sync:
sync_srt.ps1 -Wav WORK\story.wav -Txt WORK\story.txtwritesWORK\story.srt. It requiresok: true, grade A and as many cues as lines. If it fails, check first that the .txt matches what is actually said (is the title included?).
2. Picture script: WORK\scenes.json
Start from SKILL\scenes.example.json. One scene per cue, with id "00", "01", … in the same order as the .srt (00 = the title).
- cast: fix 2–4 recurring characters once and use them as
{hero}and so on in the prompts. Give each one one or two strong, unique traits (hair colour, beard / clean-shaven, a garment in a unique colour) with weight(…:1.2). If the story has a narrator who retells something ("I watched…", "my friend said…"), let the narrator open and close the video, and illustrate the content of the story in between. - Each scene shows what the sentence says, with its key word as the motif (昼食 → they eat lunch, 回収 → someone is carried away, 供給 → empty supply crates). Weight the concrete motif
(…:1.3). This is what makes the video useful for learning: the picture explains the word. - At most 1–2 characters per image. SDXL mixes up traits when there are 3 or more (everyone gets a beard, hair colours swap). If a group is needed, show it from behind or at a distance.
- Always state the setting ("in a dark stone dungeon"), or SDXL drifts into a kitchen or outdoors.
- No recreations of existing works: generic characters only, never a show's or game's own character designs, even if the story is about that show.
- Avoid violence and gore. Describe death, injury and the like softly (a covered stretcher, a glowing magic circle).
seed: 1001, 1002, … (any number; it only keeps an image reproducible).
3. Images
comfy.ps1 -Action start(wait for "running").gen_images.ps1 -Dir WORKcreatesimages\00.png ….sheet.ps1 -Dir WORK, then look atWORK\sheet.png. Check each image against its sentence: is the motif there, are the right characters there, is the setting right?- For images that miss: rewrite that scene's prompt (fewer characters, a stronger motif, an explicit setting), then
gen_images.ps1 -Dir WORK -Only "04,08" -Variants 3→sheet.ps1 -Dir WORK -Only "04,08"→ look atWORK\variants.png(one row per scene, v1 v2 v3 from left to right). Copy the best one:images\variants\04_v2.png→images\04.png. Do at most 2 rounds per image, then pick the best you have. comfy.ps1 -Action stoponce the images are done (frees the GPU).
4. Video
assemble.ps1 -Dir WORK -Out "<title>.mp4". Each image is shown from its cue's start until the next cue starts, at 1920×1080. There are no subtitles in the picture: the script copiesstory.srtto<title>.srtbeside the MP4 (same base name, so players such as VLC and mpv load it automatically, or the user drags it in).- Look at
WORK\check.png(a frame from the middle): the image matches the sentence and there is no text in the picture. - Give the user the MP4 and the
<title>.srt.
5. Report
Give the file paths, length, number of images and voice. Name any images that are weak (e.g. a character who looks different) and how to swap one: change the prompt in scenes.json, run gen_images.ps1 -Only NN, then assemble.ps1 again. Keep variants.png and images\variants\ so the user can pick differently.
Pitfalls
- Locales with decimal commas: all times passed to ffmpeg must use InvariantCulture (the scripts handle this).
- ComfyUI's
/historycan return an emptysubfolder. The scripts join the path without it. - A ComfyUI process started as a background task reports a failed or killed exit when
comfy.ps1 -Action stopstops it. That is expected, not a fault.