Python

Agent-assisted bilingual subtitles for group watches

I wanted English and Chinese subtitles on screen at the same time for a group watch. Some people read one language faster, some read the other faster. Switching tracks does not help everyone follow along together.

I built the subtitle tools with the assistance of Codex. I supplied the ideas and directed the work; Codex did the investigation and implementation, including the merging, timing alignment, and review reports. Codex also drafted this post.

Matching the tracks

The first script paired English and Chinese cues by their cue numbers, kept the English timestamps, and stacked the text. That worked for one pair of files, but it depended on both tracks numbering their cues the same way. Missing dialogue or extra signage cues can break that assumption.

Another pair needed more work. The timing difference between the tracks changed over the course of the movie, so shifting the whole Chinese track by a fixed number of seconds would not line it up.

I had Codex adapt the script to use the English track as the timing source:

  • Estimate the Chinese timing offset in local windows, then smooth those offsets.
  • Remap the Chinese cues onto the English timeline.
  • Merge Chinese text into the nearest overlapping English cue.
  • Keep Chinese-only cues as separate events.
  • Write a merged .srt and an alignment report.

Checking the result

The report listed low-confidence merges, Chinese-only cues, English cues without matching Chinese text, and the local offset anchors. That gave me timestamps to check instead of having to inspect the entire subtitle file.

I generated a track, skimmed the report, and spot-checked the questionable sections. When something looked wrong, I asked Codex to adjust the matching or improve the report, then generated it again.

Having Codex write and revise the scripts made this practical for a couple of group watches. I could ask for a change after trying the output with the actual files.

If you want to try it, give your coding agent both subtitle files and specify which track has the correct timing. Ask for the merged output and a report of uncertain matches and unmatched cues. Check those against the video before watching with everyone.

No repo link here. The subtitle files are not mine to redistribute.

It worked for our group watch. We had a good time, and everybody could follow along.

3:35 pm / Subtitles , Python , Agents , Localization , Tooling , Ai assisted , Codex

Gooey and PyInstaller for easy to write, distribute, and use scripts!

What is:

  • Easy to write
  • Easy to distribute and portable
  • Super Powerful
  • Cross Platform
  • Puts computer novices and professionals on the same level?

I think it’s a combination of Gooey and PyInstaller. If you put those two together, you get all those above.

  • It’s Python, so it’s easy to write. There are so many guides online and a wide assortment of libraries. Most importantly, you get libraries that have a strong eye towards ergonomics. Python is a wonderful beginner’s language that some people even call an executable psuedolanguage.
  • PyInstaller bundles applications into a single folder or exe so it’s easy to distribute.
  • You get the full force of Python’s language and its ecosystem behind you.
  • Python is cross platform, but Gooey’s GUI is also as well. Don’t be expecting to make “Destiny”-style GUIs with it. But do be expecting a surprising amount of native-ness.
  • While PyInstaller does package the application up into a portable Python script, the existing command line invokation is still left for professionals. Simply add --ignore-gooey to the list of arguments. Now it’s just a plain old script.

The Gooey PyInstaller Demo was presented at a DesertPy meetup in August of 2018. It’s a project showing the development of a simple argument parsing script all the way up to a portable GUI. Future improvements to the demo include some CI scripts and configurations. This was completed on 2018-12-15.

Demo Project Link: https://github.com/nelsonjchen/gooey-pyinstaller-demo

8:36 pm / Python , Pyinstaller , Gooey