Skip to content

Commit

Permalink
Merge pull request #288 from charles7668/fix/thread-value-error
Browse files Browse the repository at this point in the history
Fix an issue where translation would fail if the threads value was not provided.
  • Loading branch information
Byaidu authored Dec 19, 2024
2 parents 5ce72a1 + ab2773e commit cf46f09
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions pdf2zh/gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,14 +188,19 @@ def translate_file(
def progress_bar(t: tqdm.tqdm):
progress(t.n / t.total, desc="Translating...")

try:
threads = int(threads)
except ValueError:
threads = 1

param = {
"files": [str(file_raw)],
"pages": selected_page,
"lang_in": lang_from,
"lang_out": lang_to,
"service": f"{translator.name}",
"output": output,
"thread": int(threads),
"thread": threads,
"callback": progress_bar,
"cancellation_event": cancellation_event_map[session_id],
"envs": _envs,
Expand Down Expand Up @@ -342,7 +347,9 @@ def progress_bar(t: tqdm.tqdm):

with gr.Accordion("Open for More Experimental Options!", open=False):
gr.Markdown("#### Experimental")
threads = gr.Textbox(label="number of threads", interactive=True)
threads = gr.Textbox(
label="number of threads", interactive=True, value="1"
)
prompt = gr.Textbox(
label="Custom Prompt for llm", interactive=True, visible=False
)
Expand Down

0 comments on commit cf46f09

Please sign in to comment.