### Run bbook_maker Command Source: https://github.com/yihong0618/bilingual_book_maker/blob/main/docs/quickstart.md Executes the bbook_maker command-line tool to create a bilingual book. Requires the path to the book file and an OpenAI API key. An example demonstrates translating 'animal_farm.epub'. ```shell bbook_maker --book_name ${path of a book} --openai_key ${openai_key} # Example bbook_maker --book_name test_books/animal_farm.epub --openai_key ${openai_key} ``` -------------------------------- ### Install and run bilingual_book_maker with OpenAI key Source: https://github.com/yihong0618/bilingual_book_maker/blob/main/README-CN.md Installs the bilingual_book_maker package and demonstrates how to run it using a provided OpenAI API key for translation. It also shows an alternative command using the installed package. ```shell pip install -r requirements.txt python3 make_book.py --book_name test_books/animal_farm.epub --openai_key ${openai_key} --test ``` ```shell pip install -U bbook_maker bbook --book_name test_books/animal_farm.epub --openai_key ${openai_key} --test ``` -------------------------------- ### Run make_book.py Script Source: https://github.com/yihong0618/bilingual_book_maker/blob/main/docs/quickstart.md Executes the make_book.py script to create a bilingual book. This method also requires the book file path and an OpenAI API key. An example shows translating 'animal_farm.epub'. ```python python3 make_book.py --book_name ${path of a book} --openai_key ${openai_key} # Example python3 make_book.py --book_name test_books/animal_farm.epub --openai_key ${openai_key} ``` -------------------------------- ### Example Usage with API Base URL Source: https://github.com/yihong0618/bilingual_book_maker/blob/main/README.md An example showing how to specify a custom API base URL when making translation requests. ```shell python3 make_book.py --book_name 'animal_farm.epub' --openai_key sk-XXXXX --api_base 'https://xxxxx/v1' ``` -------------------------------- ### Command-Line Examples for Prompt Usage Source: https://github.com/yihong0618/bilingual_book_maker/blob/main/docs/prompt.md Demonstrates how to use the `--prompt` parameter with different prompt configurations (text file, JSON file, inline string) when executing the `make_book.py` script. ```sh python3 make_book.py --book_name test_books/animal_farm.epub --prompt prompt_template_sample.txt # or python3 make_book.py --book_name test_books/animal_farm.epub --prompt prompt_template_sample.json # or python3 make_book.py --book_name test_books/animal_farm.epub --prompt "Please translate `{text}` to {language}" ``` -------------------------------- ### Translate using GPT-3 Source: https://github.com/yihong0618/bilingual_book_maker/blob/main/docs/model_lang.md Example of using the bilingual book maker with the GPT-3 model. Requires an OpenAI API key. ```shell bbook_maker --book_name test_books/animal_farm.epub --model gpt3 --openai_key ${openai_key} ``` -------------------------------- ### Set Translation Temperature Source: https://github.com/yihong0618/bilingual_book_maker/blob/main/README.md Provides an example of setting the temperature parameter for models like chatgptapi, gpt4, and claude using the `--temperature` flag. ```shell python make_book.py --temperature 0.7 ``` -------------------------------- ### Translate using GPT-4 Source: https://github.com/yihong0618/bilingual_book_maker/blob/main/docs/model_lang.md Example of using the bilingual book maker with the GPT-4 model. Requires an OpenAI API key. The `--use_context` flag can be added to provide context for improved translation consistency. ```shell bbook_maker --book_name test_books/animal_farm.epub --model gpt4 --openai_key ${openai_key} ``` ```shell bbook_maker --book_name test_books/animal_farm.epub --model gpt4 --openai_key ${openai_key} --use_context ``` -------------------------------- ### Translate using DeepL free model Source: https://github.com/yihong0618/bilingual_book_maker/blob/main/docs/model_lang.md Example of using the bilingual book maker with the free DeepL model. ```shell bbook_maker --book_name test_books/animal_farm.epub --model deeplfree ``` -------------------------------- ### Translate using Google model Source: https://github.com/yihong0618/bilingual_book_maker/blob/main/docs/model_lang.md Example of using the bilingual book maker with the Google model. ```shell bbook_maker --book_name test_books/animal_farm.epub --model google ``` -------------------------------- ### Translate using Claude model Source: https://github.com/yihong0618/bilingual_book_maker/blob/main/docs/model_lang.md Example of using the bilingual book maker with the Claude model. Requires a Claude API key. ```shell bbook_maker --book_name test_books/animal_farm.epub --model claude --claude_key ${claude_key} ``` -------------------------------- ### Translate using ChatGPT API (GPT-3.5-turbo) Source: https://github.com/yihong0618/bilingual_book_maker/blob/main/docs/model_lang.md Example of using the bilingual book maker with the chatgptapi model, which utilizes GPT-3.5-turbo. Requires an OpenAI API key. ```shell bbook_maker --book_name test_books/animal_farm.epub --model chatgptapi --openai_key ${openai_key} ``` -------------------------------- ### Translate using DeepL Translator (paid) Source: https://github.com/yihong0618/bilingual_book_maker/blob/main/docs/model_lang.md Example of using the bilingual book maker with the paid DeepL Translator model. Requires a DeepL API key. ```shell bbook_maker --book_name test_books/animal_farm.epub --model deepl --deepl_key ${deepl_key} ``` -------------------------------- ### Translate using Custom API model Source: https://github.com/yihong0618/bilingual_book_maker/blob/main/docs/model_lang.md Example of using the bilingual book maker with a Custom API model. Requires the API endpoint URL. ```shell bbook_maker --book_name test_books/animal_farm.epub --model customapi --custom_api ${custom_api} ``` -------------------------------- ### Set target language to Japanese Source: https://github.com/yihong0618/bilingual_book_maker/blob/main/docs/model_lang.md Example of setting the target language to Japanese for translation using the bilingual book maker. ```shell bbook_maker --book_name test_books/animal_farm.epub --model chatgptapi --openai_key ${openai_key} --language ja ``` -------------------------------- ### Set target language to Simplified Chinese Source: https://github.com/yihong0618/bilingual_book_maker/blob/main/docs/model_lang.md Example of setting the target language to Simplified Chinese for translation using the bilingual book maker. ```shell bbook_maker --book_name test_books/animal_farm.epub --model chatgptapi --openai_key ${openai_key} --language "Simplified Chinese" ``` -------------------------------- ### Translate using Caiyun model Source: https://github.com/yihong0618/bilingual_book_maker/blob/main/docs/model_lang.md Example of using the bilingual book maker with the Caiyun model. Requires a Caiyun API key. Caiyun currently supports Simplified Chinese <-> English and Simplified Chinese <-> Japanese. ```shell bbook_maker --model caiyun --caiyun_key 3975l6lr5pcbvidl6jl2 --book_name test_books/animal_farm.epub ``` -------------------------------- ### Retranslate Specific Sections of a Book Source: https://github.com/yihong0618/bilingual_book_maker/blob/main/README.md Allows retranslation of a specific range within a bilingual book. Requires the path to the bilingual file, the epub file, and optionally start and end strings to define the retranslation range. ```shell python3 "make_book.py" --book_name "test_books/animal_farm.epub" --retranslate 'test_books/animal_farm_bilingual.epub' 'index_split_002.html' 'in spite of the present book shortage which' 'This kind of thing is not a good symptom. Obviously' ``` ```shell python3 "make_book.py" --book_name "test_books/animal_farm.epub" --retranslate 'test_books/animal_farm_bilingual.epub' 'index_split_002.html' 'in spite of the present book shortage which' ``` -------------------------------- ### Configure Prompt with JSON Object Source: https://github.com/yihong0618/bilingual_book_maker/blob/main/README.md Shows how to provide a JSON string with 'user' and 'system' roles for prompt configuration using the `--prompt` argument. ```shell python make_book.py --prompt '{"user":"Translate {text} to {language}", "system": "You are a professional translator."}' ``` -------------------------------- ### Configure Prompt with Simple Text Source: https://github.com/yihong0618/bilingual_book_maker/blob/main/README.md Illustrates setting a simple user role prompt template directly via the `--prompt` argument. ```shell python make_book.py --prompt "Translate {text} to {language}." ``` -------------------------------- ### Configure Prompt with PromptDown Markdown File Source: https://github.com/yihong0618/bilingual_book_maker/blob/main/README.md Demonstrates using the `--prompt` argument with a `.prompt.md` file, which supports structured prompts using PromptDown format. ```shell python make_book.py --prompt prompt_md.prompt.md ``` -------------------------------- ### Configure Prompt with JSON File Source: https://github.com/yihong0618/bilingual_book_maker/blob/main/README.md Illustrates specifying a JSON file that contains the prompt configuration using the `--prompt` argument. ```shell python make_book.py --prompt prompt_template_sample.json ``` -------------------------------- ### Docker: Build and Run Bilingual Book Maker Source: https://github.com/yihong0618/bilingual_book_maker/blob/main/README.md This section details how to use Docker to build an image for the bilingual book maker and run it as a container. It includes commands for building the image and running the container with volume mounts for data persistence, tailored for both Windows PowerShell and Linux environments. Environment variables are used to pass necessary parameters like folder path, book name, API key, and language. ```shell # Build image docker build --tag bilingual_book_maker . ``` ```powershell # Windows PowerShell $folder_path=your_folder_path # $folder_path="C:\Users\user\mybook\" $book_name=your_book_name # $book_name="animal_farm.epub" $openai_key=your_api_key # $openai_key="sk-xxx" $language=your_language # see utils.py docker run --rm --name bilingual_book_maker --mount type=bind,source=$folder_path,target='/app/test_books' bilingual_book_maker --book_name "/app/test_books/$book_name" --openai_key $openai_key --language $language ``` ```bash # Linux export folder_path=${your_folder_path} export book_name=${your_book_name} export openai_key=${your_api_key} export language=${your_language} docker run --rm --name bilingual_book_maker --mount type=bind,source=${folder_path},target='/app/test_books' bilingual_book_maker --book_name "/app/test_books/${book_name}" --openai_key ${openai_key} --language "${language}" ``` ```bash # Linux Example docker run --rm --name bilingual_book_maker --mount type=bind,source=/home/user/my_books,target='/app/test_books' bilingual_book_maker --book_name /app/test_books/animal_farm.epub --openai_key sk-XXX --test --test_num 1 --language zh-hant ``` -------------------------------- ### Configure Prompt with Text File Source: https://github.com/yihong0618/bilingual_book_maker/blob/main/README.md Demonstrates how to specify a text file containing the prompt template using the `--prompt` argument. ```shell python make_book.py --prompt prompt_template_sample.txt ``` -------------------------------- ### Configure Proxy Server Source: https://github.com/yihong0618/bilingual_book_maker/blob/main/docs/cmd.md The --proxy option specifies a proxy server for internet access. The input should be a string representing the proxy server address, typically in the format 'http://127.0.0.1:7890'. ```sh bbook_maker --proxy "http://127.0.0.1:7890" ``` -------------------------------- ### Resume Bilingual Book Creation Process Source: https://github.com/yihong0618/bilingual_book_maker/blob/main/README.md Demonstrates how to resume an interrupted book creation process using the `--resume` flag along with the book name and model type. ```shell python3 make_book.py --book_name test_books/animal_farm.epub --model google --resume ``` -------------------------------- ### Test Translation with bbook_maker Source: https://github.com/yihong0618/bilingual_book_maker/blob/main/docs/cmd.md Use the --test option to preview translation results without purchasing the service. This option has limitations and may introduce delays. It can be used with different file types like SRT and EPUB. ```sh bbook_maker --book_name test_books/Lex_Fridman_episode_322.srt --openai_key ${openai_key} --test ``` ```sh bbook_maker --book_name test_books/animal_farm.epub --openai_key ${openai_key} --test --language zh-hans ``` -------------------------------- ### Translate book using GroqCloud models Source: https://github.com/yihong0618/bilingual_book_maker/blob/main/README-CN.md This command translates a book using models available through GroqCloud. It requires a Groq API key and allows specifying the desired model from their supported list. ```shell python3 make_book.py --book_name test_books/animal_farm.epub --groq_key [your_key] --model groq --model_list llama3-8b-8192 ``` -------------------------------- ### Translate SRT Files and Handle Environment Variables Source: https://github.com/yihong0618/bilingual_book_maker/blob/main/README.md Demonstrates translating subtitle files (SRT) and how to set environment variables for API keys to avoid passing them as command-line arguments. ```shell python3 make_book.py --book_name test_books/Lex_Fridman_episode_322.srt --openai_key ${openai_key} --test ``` ```shell export OPENAI_API_KEY=${your_api_key} ``` ```shell export BBM_CAIYUN_API_KEY=${your_api_key} ``` -------------------------------- ### Use Microsoft Azure OpenAI Endpoints Source: https://github.com/yihong0618/bilingual_book_maker/blob/main/docs/cmd.md This configuration uses the --api_base and --deployment_id options to connect to Microsoft Azure OpenAI endpoints. The api_base must be provided when deployment_id is used, and currently only supports the chatgptapi model. ```sh bbook_maker --book_name 'animal_farm.epub' --openai_key XXXXX --api_base 'https://example-endpoint.openai.azure.com' --deployment_id 'deployment-name' ``` -------------------------------- ### Run Book Maker with Python (OpenAI API) Source: https://github.com/yihong0618/bilingual_book_maker/blob/main/README.md This snippet shows how to execute the `make_book.py` script using Python. It requires specifying the book name, an OpenAI API key, and optionally an API base URL. Ensure `python3` is in your system's PATH. ```shell python make_book.py --book_name 'animal_farm.epub' --openai_key sk-XXXXX --api_base 'https://xxxxx/v1' ``` -------------------------------- ### Run Book Maker with Python (Azure OpenAI) Source: https://github.com/yihong0618/bilingual_book_maker/blob/main/README.md This snippet demonstrates running the `make_book.py` script with Azure OpenAI endpoints. It requires the book name, an API key, an Azure API base URL, and a deployment ID. It also provides an alternative command if `python3` is not in your PATH. ```shell python3 make_book.py --book_name 'animal_farm.epub' --openai_key XXXXX --api_base 'https://example-endpoint.openai.azure.com' --deployment_id 'deployment-name' ``` ```shell python make_book.py --book_name 'animal_farm.epub' --openai_key XXXXX --api_base 'https://example-endpoint.openai.azure.com' --deployment_id 'deployment-name' ``` -------------------------------- ### Translate book using Google Translate Source: https://github.com/yihong0618/bilingual_book_maker/blob/main/README-CN.md This command translates a book using Google Translate. No specific API key or model parameter is shown, implying it uses a default configuration. ```shell python3 make_book.py --book_name test_books/animal_farm.epub --model google ``` -------------------------------- ### Resume Translation Process Source: https://github.com/yihong0618/bilingual_book_maker/blob/main/docs/cmd.md The --resume option allows manual resumption of a translation process that was interrupted. ```sh bbook_maker --resume ``` -------------------------------- ### Set Custom API Base URL Source: https://github.com/yihong0618/bilingual_book_maker/blob/main/docs/cmd.md The --api_base option allows users to specify a custom API base URL, useful for services like Cloudflare Workers. The URL should typically end with '/v1'. ```sh bbook_maker --book_name 'animal_farm.epub' --openai_key sk-XXXXX --api_base 'https://xxxxx/v1' ``` -------------------------------- ### Translate book using Ollama self-hosted models Source: https://github.com/yihong0618/bilingual_book_maker/blob/main/README-CN.md This command translates a book using self-hosted models via Ollama. It allows specifying the Ollama server address if it's not running locally. ```shell python3 make_book.py --book_name test_books/animal_farm.epub --ollama_model ${ollama_model_name} ``` -------------------------------- ### Translate Text Files and Batch Processing Source: https://github.com/yihong0618/bilingual_book_maker/blob/main/README.md Shows how to translate plain text files and utilize batch processing with `--batch_size` for more efficient handling of large text files. ```shell python3 make_book.py --book_name test_books/the_little_prince.txt --test --language zh-hans ``` ```shell python3 make_book.py --book_name test_books/the_little_prince.txt --test --batch_size 20 ``` -------------------------------- ### Advanced Translation Options: Block Size, Style, Tags, and Prompts Source: https://github.com/yihong0618/bilingual_book_maker/blob/main/README.md Covers advanced features like merging paragraphs with `--block_size`, applying custom translation styles with `--translation_style`, translating specific HTML tags with `--translate-tags`, and customizing translation prompts via text or JSON files. ```shell python3 make_book.py --book_name "test_books/animal_farm.epub" --block_size 5 --single_translate ``` ```shell python3 make_book.py --book_name test_books/animal_farm.epub --translation_style "color: #808080; font-style: italic;" ``` ```shell python3 make_book.py --book_name test_books/animal_farm.epub --translate-tags div,p ``` ```shell python3 make_book.py --book_name test_books/animal_farm.epub --prompt prompt_template_sample.txt ``` ```shell python3 make_book.py --book_name test_books/animal_farm.epub --prompt prompt_template_sample.json ``` ```shell python3 make_book.py --book_name test_books/animal_farm.epub --prompt "Please translate \`{text}\` to {language}" ``` -------------------------------- ### Translate Book with Various Models and Options Source: https://github.com/yihong0618/bilingual_book_maker/blob/main/README.md Demonstrates translating an EPUB book using different translation APIs (OpenAI, Gemini, DeepL, Claude, CustomAPI) and configurations. Includes options for testing, specifying languages, and using model aliases. ```shell python3 make_book.py --book_name test_books/animal_farm.epub --openai_key ${openai_key} --test --language zh-hans ``` ```shell python3 make_book.py --book_name test_books/animal_farm.epub --gemini_key ${gemini_key} --model gemini ``` ```shell python3 make_book.py --book_name test_books/animal_farm.epub --model gemini --model_list gemini-1.5-flash-002,gemini-1.5-flash-8b-exp-0924 ``` ```shell python3 make_book.py --book_name test_books/animal_farm.epub --model gpt4 --use_context --language ja ``` ```shell python3 make_book.py --book_name test_books/animal_farm.epub --model openai --model_list gpt-4-1106-preview --openai_key ${openai_key} ``` ```shell python3 make_book.py --book_name test_books/animal_farm.epub --model openai --model_list yi-34b-chat-0205 --openai_key ${openai_key} --api_base "https://api.lingyiwanwu.com/v1" ``` ```shell python3 make_book.py --book_name test_books/animal_farm.epub --model openai --model_list gpt-4-1106-preview,gpt-4-0125-preview,gpt-3.5-turbo-0125 --openai_key ${openai_key} ``` ```shell python3 make_book.py --book_name test_books/animal_farm.epub --model deepl --deepl_key ${deepl_key} --language ja ``` ```shell python3 make_book.py --book_name test_books/animal_farm.epub --model claude --claude_key ${claude_key} --language ja ``` ```shell python3 make_book.py --book_name test_books/animal_farm.epub --model customapi --custom_api ${custom_api} --language ja ``` -------------------------------- ### Translate EPUB Files with bbook_maker Source: https://github.com/yihong0618/bilingual_book_maker/blob/main/docs/book_source.md This command translates EPUB files using the bbook_maker tool. It allows specifying which HTML tags to translate and requires an OpenAI API key. It can also translate untagged strings using a specific parameter. ```bash bbook_maker --book_name test_books/animal_farm.epub --openai_key ${openai_key} --translate-tags div,p ``` ```bash bbook_maker --book_name test_books/animal_farm.epub --openai_key ${openai_key} --translate-tags h1,h2,h3,p,div --allow_navigable_strings ``` -------------------------------- ### Translate with Gemini Source: https://github.com/yihong0618/bilingual_book_maker/blob/main/README.md Translates a book using Google Gemini models. Use '--model gemini' for Gemini Flash or '--model geminipro' for Gemini Pro. Requires a Gemini API key. Supports specifying model aliases. ```shell python3 make_book.py --book_name test_books/animal_farm.epub --model gemini --gemini_key ${gemini_key} ``` ```shell python3 make_book.py --book_name test_books/animal_farm.epub --model gemini --model_list gemini-1.5-flash-002,gemini-1.5-flash-8b-exp-0924 ``` -------------------------------- ### Translate book using Gemini model Source: https://github.com/yihong0618/bilingual_book_maker/blob/main/README-CN.md This command translates a book using the Gemini model. It requires a Gemini API key to be provided. ```shell python3 make_book.py --book_name test_books/animal_farm.epub --model gemini --gemini_key ${gemini_key} ``` -------------------------------- ### Translate book using Claude model Source: https://github.com/yihong0618/bilingual_book_maker/blob/main/README-CN.md This command translates a book using the Claude model. It requires a Claude API key to be provided. ```shell python3 make_book.py --book_name test_books/animal_farm.epub --model claude --claude_key ${claude_key} ``` -------------------------------- ### JSON Prompt Template Source: https://github.com/yihong0618/bilingual_book_maker/blob/main/docs/prompt.md Defines both system and user prompts using a JSON structure. This allows for more complex prompt configurations, separating the AI's role and the user's specific request. ```json { "system": "You are a professional translator.", "user": "Translate the given text to {language}. Be faithful or accurate in translation. Make the translation readable or intelligible. Be elegant or natural in translation. If the text cannot be translated, return the original text as is. Do not translate person's name. Do not add any additional text in the translation. The text to be translated is:\n{text}" } ``` -------------------------------- ### Translate Kobo E-books Source: https://github.com/yihong0618/bilingual_book_maker/blob/main/README.md Specific command to translate books downloaded from Rakuten Kobo, requiring the path to the Kobo device's storage. ```shell python3 make_book.py --book_from kobo --device_path /tmp/kobo ``` -------------------------------- ### Translate book using DeepL free service Source: https://github.com/yihong0618/bilingual_book_maker/blob/main/README-CN.md This command translates a book using the free version of the DeepL translation service. No API key is required for this option. ```shell python3 make_book.py --book_name test_books/animal_farm.epub --model deeplfree ``` -------------------------------- ### Translate book using Qwen models Source: https://github.com/yihong0618/bilingual_book_maker/blob/main/README-CN.md This command translates a book using Qwen models, supporting 'qwen-mt-turbo' and 'qwen-mt-plus'. It allows specifying the target language and optionally the source language for translation. ```shell python3 make_book.py --book_name test_books/animal_farm.epub --qwen_key ${qwen_key} --model qwen-mt-turbo --language "Simplified Chinese" ``` ```shell python3 make_book.py --book_name test_books/animal_farm.epub --qwen_key ${qwen_key} --model qwen-mt-plus --language "Japanese" --source_lang "English" ``` -------------------------------- ### Using Caiyun Translation Model Source: https://github.com/yihong0618/bilingual_book_maker/blob/main/README.md Demonstrates translation using the Caiyun model, specifying the API key and supported language pairs (Simplified Chinese <-> English, Simplified Chinese <-> Japanese). ```shell python3 make_book.py --model caiyun --caiyun_key 3975l6lr5pcbvidl6jl2 --book_name test_books/animal_farm.epub ``` -------------------------------- ### Specify Tags for Translation Source: https://github.com/yihong0618/bilingual_book_maker/blob/main/README.md Shows how to use the `--translate-tags` option to specify which HTML tags' content should be translated. Multiple tags can be separated by commas. ```shell python make_book.py --translate-tags h1,h2,h3,p,div ``` -------------------------------- ### Translate book using xAI Source: https://github.com/yihong0618/bilingual_book_maker/blob/main/README-CN.md This command translates a book using the xAI service. It requires an xAI API key to be provided. ```shell python3 make_book.py --book_name test_books/animal_farm.epub --model xai --xai_key ${xai_key} ``` -------------------------------- ### Customize EPUB Translation Style Source: https://github.com/yihong0618/bilingual_book_maker/blob/main/docs/cmd.md The --translation_style option allows customization of the visual output style for EPUB files, such as font color, style, background color, padding, margin, and border-radius. ```sh bbook_maker --book_name test_books/animal_farm.epub --translation_style "color: #4a4a4a; font-style: normal; background-color: #f7f7f7; padding: 5px; margin: 10px 0; border-radius: 5px;" ``` -------------------------------- ### Plain Text Prompt Template Source: https://github.com/yihong0618/bilingual_book_maker/blob/main/docs/prompt.md Configures a simple user prompt for translation tasks using a text file. It specifies placeholders for the text to be translated and the target language. ```plaintext # prompt_template_sample.txt Translate the given text to {language}. Be faithful or accurate in translation. Make the translation readable or intelligible. Be elegant or natural in translation. If the text cannot be translated, return the original text as is. Do not translate person's name. Do not add any additional text in the translation. The text to be translated is: {text} ``` -------------------------------- ### Translate with OpenAI Source: https://github.com/yihong0618/bilingual_book_maker/blob/main/README.md Translates a book using OpenAI models. Supports specifying API keys, models, and model lists. Can use environment variables for keys. ```shell python3 make_book.py --openai_key xxx,xxx,xxx ``` ```shell export BBM_OPENAI_API_KEY=your_key ``` ```shell python3 make_book.py --book_name test_books/animal_farm.epub --model gpt4 ``` ```shell python3 make_book.py --book_name test_books/animal_farm.epub --model openai --model_list gpt-4-1106-preview,gpt-3.5-turbo-0125 ``` ```shell python3 make_book.py --book_name test_books/animal_farm.epub --use_context ``` -------------------------------- ### PromptDown (.md) Prompt Format Source: https://github.com/yihong0618/bilingual_book_maker/blob/main/docs/prompt.md Utilizes PromptDown format for structured prompts, allowing clear separation of system messages and user conversations. Supports both standard conversation formats and developer messages for newer AI models. ```markdown # Translation Prompt ## System Message You are a professional translator who specializes in accurate translations. ## Conversation | Role | Content | |-------|------------------------------------------| | User | Please translate the following text into {language}:\n\n{text} | # OR using Developer Message (for newer AI models) # Translation Prompt ## Developer Message You are a professional translator who specializes in accurate translations. ## Conversation | Role | Content | |-------|------------------------------------------| | User | Please translate the following text into {language}:\n\n{text} | ``` -------------------------------- ### Translate Kobo E-reader Books with bbook_maker Source: https://github.com/yihong0618/bilingual_book_maker/blob/main/docs/book_source.md This command translates books downloaded from Kobo e-readers by specifying the e-reader type and the device path. Currently, only 'kobo' is supported. ```bash # Translate books download from Rakuten Kobo on kobo e-reader bbook_maker --book_from kobo --device_path /tmp/kobo ``` -------------------------------- ### Translate book using DeepL API Source: https://github.com/yihong0618/bilingual_book_maker/blob/main/README-CN.md This command translates a book using the DeepL API. It requires a DeepL API key to be provided. ```shell python3 make_book.py --book_name test_books/animal_farm.epub --model deepl --deepl_key ${deepl_key} ``` -------------------------------- ### Translate TXT/SRT Files with Python Source: https://github.com/yihong0618/bilingual_book_maker/blob/main/docs/book_source.md This command translates plain text files like .txt and .srt using the make_book.py script. It requires the book name and the target language. ```python python3 make_book.py --book_name test_books/the_little_prince.txt --test --language zh-hans ``` -------------------------------- ### Set Batch Size for TXT Files Source: https://github.com/yihong0618/bilingual_book_maker/blob/main/docs/cmd.md The --batch_size parameter specifies the number of lines to process in each batch for translation. This option is currently only effective for .txt files. The default value is 10. ```python python3 make_book.py --book_name test_books/the_little_prince.txt --test --batch_size 20 ``` -------------------------------- ### Translate with Ollama Source: https://github.com/yihong0618/bilingual_book_maker/blob/main/README.md Translates a book using Ollama self-hosted models. Specify the Ollama model name and optionally the API base URL. ```shell python3 make_book.py --book_name test_books/animal_farm.epub --ollama_model ${ollama_model_name} ``` ```shell python3 make_book.py --book_name test_books/animal_farm.epub --api_base http://x.x.x.x:port/v1 --ollama_model ${ollama_model_name} ``` -------------------------------- ### Translate book using Tencent Smart Translation Source: https://github.com/yihong0618/bilingual_book_maker/blob/main/README-CN.md This command translates a book using Tencent's Smart Translation service. It uses the '--model tencentransmart' flag. ```shell python3 make_book.py --book_name test_books/animal_farm.epub --model tencentransmart ``` -------------------------------- ### Translate book using Caiyun Translate Source: https://github.com/yihong0618/bilingual_book_maker/blob/main/README-CN.md This command translates a book using the Caiyun Translate service. It requires a Caiyun API key to be provided. ```shell python3 make_book.py --book_name test_books/animal_farm.epub --model caiyun --caiyun_key ${caiyun_key} ``` -------------------------------- ### Retranslate EPUB Sections Source: https://github.com/yihong0618/bilingual_book_maker/blob/main/docs/cmd.md The --retranslate option is used for EPUB files to re-translate specific sections that did not translate well. It requires the path to the bilingual EPUB, the filename within the EPUB, and start/end strings to define the section. The end string is optional. ```sh bbook_maker --book_name "test_books/animal_farm.epub" --retranslate 'test_books/animal_farm_bilingual.epub' 'index_split_002.html' 'in spite of the present book shortage which' 'This kind of thing is not a good symptom. Obviously' ``` ```sh bbook_maker --book_name "test_books/animal_farm.epub" --retranslate 'test_books/animal_farm_bilingual.epub' 'index_split_002.html' 'in spite of the present book shortage which' ``` ```sh bbook_maker --book_name "test_books/animal_farm.epub" --retranslate 'test_books/animal_farm_bilingual.epub' '' 'in spite of the present book shortage which' ``` -------------------------------- ### Configure Accumulated Token Count Source: https://github.com/yihong0618/bilingual_book_maker/blob/main/docs/cmd.md The --accumulated_num option sets the threshold for accumulated tokens before initiating translation. This helps manage API limits, such as the 4090 token limit for gpt-3.5. The value needs to be chosen carefully to avoid exceeding limits. ```sh bbook_maker --accumulated_num 1600 ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.