Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Line breaks will be the death of me #2

Open
cxdy opened this issue Apr 28, 2019 · 0 comments
Open

Line breaks will be the death of me #2

cxdy opened this issue Apr 28, 2019 · 0 comments
Assignees

Comments

@cxdy
Copy link
Owner

cxdy commented Apr 28, 2019

As of the current version (April 28 2019), we start with an English (or whatever language, I guess) SRT file. The file is converted to JSON so we can interact with the file programatically.

Line breaks from the source SRT file are converted to \n in the JSON file cause JSON, and when the program goes to translate the captions, we pull the line break because obviously \n won't translate. Gotta figure out a way to add them back though.

@kpmgeek mentioned that in America, the standard for each line in an SRT file is 32 characters, but other countries are more lenient with their standards. I think we can just count up to 32 characters, and if there's a character that is not a space (i.e: a letter, number, etc), we move back to the nearest space and insert a line break there.

However, this isn't necessarily the best approach because sometimes on the first line you have things like [Narrator] and then the second line is what the narrator is saying, so we need to find a way around that & also find a way around leaving one word/character/whatever on the 2nd line with everything else up top. Maybe count the total characters for the caption (between 1-2 lines), then count all the spaces in that caption, subtract the number of spaces from the number of total characters and divide that number by 2?

Example Caption:
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam et maximus dolor.
Total Length - 80 characters
Number of spaces - 9 spaces
(80 - 9) / 2 = 35.5

I don't know where I'm going with that, but you get what I mean.

@cxdy cxdy self-assigned this Apr 28, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant