A Fansub Editing Tip
by Aleksandar Micovic
It seems that most of my posts have been crazy one-liners that do more than they should. This post is no different.
Motivation
Remember how your high school English teachers always stressed that you should be reading and re-reading your own work before submitting it? Out loud? It’s almost a fool-proof way to catch mistakes, but reading can get tedious depending on what you have to read. In my case, I’ve recently started editing fansubs (Japanese animation, specifically) and found that reading the scripts can be quite difficult at times. So, I’ve put a small one-liner together to read the script for me!
The Code
Here is the line that solves my problems, followed by an explanation of it, for those of you who care.
cat TARGET.ass | grep "Dialogue" | sed -e 's/.*}\|.*0,,\|\\N//g' | festival --pipe --tts
This only works on .ass files, and if you want to run it replace the TARGET.ass with the path to your script file. So, how does this work? Like this.
We first grab all of the file’s contents with cat TARGET.ass. Then, the entire script is filtered line by line allowing only the lines that start with “Dialogue” to pass through to the next stage. This is done with the grep “Dialogue” part. Next, and probably the most funky part of this entire one-liner is when the program sed is invoked. Basically, what sed -e ’s/.*}\|.*0,,\|\\N//g’ does is it removes everything that’s not actual dialogue. Why is this needed? Unfortunately, even though we have all of the lines that contain actual dialogue, every single one of these lines is littered with .ass format and control tags. All of this is filtered out, and we’re left with clean dialogue. The funky looking code is called a regular expression, if you’re interested.
At this point, we’re pretty much done. The last thing that needs to be done is to somehow give our script to a text-to-speech program. This is done with the festival –pipe –tts part. The program festival is a text-to-speech program, and if you’re wondering about the extra arguments passed to it, feel free to hit up the manual.
The default voice is pretty crap, but a simple search on Google reveals a plethora of guides on how to install different (and better!) voices.
I hope that this helps some of you!
Comments
I am completely impressed with the quality of this page it was a joy to read.