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

#48 add an option to keep translation only #66

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions make_book.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,8 @@ def make_bilingual_book(self):
new_p.string = self.translate_model.translate(p.text)
self.p_to_save.append(new_p.text)
p.insert_after(new_p)
if TRANSLATION_ONLY:
p.extract()
index += 1
if IS_TEST and index > TEST_NUM:
break
Expand Down Expand Up @@ -275,6 +277,12 @@ def save_progress(self):
default="zh-hans",
help="language to translate to",
)
parser.add_argument(
"--translation-only",
dest="translation_only",
action="store_false",
help="remove original paragraphs, and keep translation only",
)
parser.add_argument(
"--resume",
dest="resume",
Expand Down Expand Up @@ -308,6 +316,7 @@ def save_progress(self):

OPENAI_API_KEY = options.openai_key or env.get("OPENAI_API_KEY")
RESUME = options.resume
TRANSLATION_ONLY = options.translation_only
if not OPENAI_API_KEY:
raise Exception("Need openai API key, please google how to")
if not options.book_name.endswith(".epub"):
Expand Down