Skip to content

Generate srt subtitle from video using OCR, mainly designed for MMD videos

License

Notifications You must be signed in to change notification settings

PatchyVideo/MMD-Translator

Repository files navigation

PYTHON VERSION DEPRECATED

Python version is now deprecated, please use C++ version from Release

Update 2021-07-30

Added 7 missing DLL files.

Update 2021-07-29

New release now added support for RTX 3000 series cards

Touhou MMD Subtitle Generator v0.3

Created by PatchyVideo
Based on CRAFT scene text detector
Translation is done using Google Translate with python package googletrans

Screenshots

How to use

You need an NVIDIA GPU no older than GTX 700 series

  1. Download textdet_300k.pth and ocr_640k.pth from release and put them into the project folder
  2. Install NVIDIA Driver
  3. Install CUDA 10.2
  4. Install Python3 environment
  5. Install PyTorch 1.5.1 from offical website
  6. Run pip3 install -r requirements.txt
  7. Run python main.py --out NUL --verbose --skip_frame 1 --video /path/to/video/file and have fun

How to use in real life

You can specifiy an output srt subtitle file of recognized texts using --out /path/to/out/srt parameter
You can specifiy an output srt subtitle file of translated texts using --out_translated /path/to/out/srt parameter
No windows will be shown if --verbose parameter is not given
--skip_frame 1 controls how many frames to skip in-between two frames used for recognition, higher the value faster the program will run, but the resulting srt file will not be as accurate as setting this value to 0
Use --language to specifiy which language you want to translate to, list of language codes can be found here

Future works

  1. The current text detector is not very accurate, new model is being trained as you are reading this
  2. Support Korean
  3. Build multithreaded C++ version to fully utilized both CPU and GPU
  4. Integrate into PatchyVideo so people can use it online to enjoy Touhou videos made by people speaking another language