mirror of
https://github.com/yihong0618/bilingual_book_maker.git
synced 2025-06-05 19:15:34 +00:00
feat: pypi
This commit is contained in:
parent
66716632ba
commit
b2b95284b4
@ -15,7 +15,7 @@ bilingual_book_maker 是一个 AI 翻译工具,使用 ChatGPT 帮助用户制
|
||||
|
||||
## 使用
|
||||
|
||||
1. `pip install -r requirements.txt`
|
||||
1. `pip install -r requirements.txt` 或 `pip install -U bbook_maker`
|
||||
2. 使用 `--openai_key` 指定 OpenAI API key,如果有多个可以用英文逗号分隔(xxx,xxx,xxx),可以减少接口调用次数限制带来的错误。
|
||||
或者,指定环境变量 `BMM_OPENAI_API_KEY` 来略过这个选项。
|
||||
3. 本地放了一个 `test_books/animal_farm.epub` 给大家测试
|
||||
@ -45,6 +45,8 @@ bilingual_book_maker 是一个 AI 翻译工具,使用 ChatGPT 帮助用户制
|
||||
|
||||
### 示范用例
|
||||
|
||||
**如果使用 `pip install bbook_maker` 以下命令都可以改成 `bbook args`**
|
||||
|
||||
```shell
|
||||
# 如果你想快速测一下
|
||||
python3 make_book.py --book_name test_books/animal_farm.epub --openai_key ${openai_key} --test
|
||||
|
@ -1,7 +1,3 @@
|
||||
This forked added Google Translate support, only supported translate to `zh-CN`.
|
||||
Usage: make sure to add `--model google` in the command.
|
||||
|
||||
|
||||
**[中文](./README-CN.md) | English**
|
||||
|
||||
# bilingual_book_maker
|
||||
@ -19,7 +15,7 @@ The bilingual_book_maker is an AI translation tool that uses ChatGPT to assist u
|
||||
|
||||
## Use
|
||||
|
||||
1. `pip install -r requirements.txt`
|
||||
1. `pip install -r requirements.txt` or `pip install -U bbook_maker`(you can use)
|
||||
2. Use `--openai_key` option to specify OpenAI API key. If you have multiple keys, separate them by commas (xxx,xxx,xxx) to reduce errors caused by API call limits.
|
||||
Or, just set environment variable `BMM_OPENAI_API_KEY` instead.
|
||||
3. A sample book, `test_books/animal_farm.epub`, is provided for testing purposes.
|
||||
@ -48,6 +44,8 @@ The bilingual_book_maker is an AI translation tool that uses ChatGPT to assist u
|
||||
|
||||
### Examples
|
||||
|
||||
**Note if use `pip install bbook_maker` all commands can change to `bbook args`**
|
||||
|
||||
```shell
|
||||
# Test quickly
|
||||
python3 make_book.py --book_name test_books/animal_farm.epub --openai_key ${openai_key} --test --language zh-hans
|
||||
|
@ -1,12 +1,12 @@
|
||||
import argparse
|
||||
import json
|
||||
import os
|
||||
from os import environ as env
|
||||
import json
|
||||
|
||||
import book_maker.obok as obok
|
||||
from book_maker.loader import BOOK_LOADER_DICT
|
||||
from book_maker.translator import MODEL_DICT
|
||||
from book_maker.utils import LANGUAGES, TO_LANGUAGE_CODE
|
||||
import book_maker.obok as obok
|
||||
|
||||
|
||||
def parse_prompt_arg(prompt_arg):
|
||||
|
@ -1,5 +1,4 @@
|
||||
from book_maker.loader.epub_loader import EPUBBookLoader
|
||||
|
||||
from book_maker.loader.txt_loader import TXTBookLoader
|
||||
|
||||
BOOK_LOADER_DICT = {
|
||||
|
@ -9,9 +9,10 @@ from ebooklib import ITEM_DOCUMENT, epub
|
||||
from rich import print
|
||||
from tqdm import tqdm
|
||||
|
||||
from .base_loader import BaseBookLoader
|
||||
from book_maker.utils import prompt_config_to_kwargs
|
||||
|
||||
from .base_loader import BaseBookLoader
|
||||
|
||||
|
||||
class EPUBBookLoader(BaseBookLoader):
|
||||
def __init__(
|
||||
|
@ -1,9 +1,10 @@
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
from .base_loader import BaseBookLoader
|
||||
from book_maker.utils import prompt_config_to_kwargs
|
||||
|
||||
from .base_loader import BaseBookLoader
|
||||
|
||||
|
||||
class TXTBookLoader(BaseBookLoader):
|
||||
def __init__(
|
||||
|
@ -164,19 +164,19 @@ from __future__ import print_function
|
||||
__version__ = "4.0.0"
|
||||
__about__ = "Obok v{0}\nCopyright © 2012-2020 Physisticated et al.".format(__version__)
|
||||
|
||||
import sys
|
||||
import os
|
||||
import subprocess
|
||||
import sqlite3
|
||||
import base64
|
||||
import binascii
|
||||
import re
|
||||
import zipfile
|
||||
import hashlib
|
||||
import xml.etree.ElementTree as ET
|
||||
import string
|
||||
import os
|
||||
import re
|
||||
import shutil
|
||||
import sqlite3
|
||||
import string
|
||||
import subprocess
|
||||
import sys
|
||||
import tempfile
|
||||
import xml.etree.ElementTree as ET
|
||||
import zipfile
|
||||
|
||||
can_parse_xml = True
|
||||
try:
|
||||
@ -196,18 +196,8 @@ class ENCRYPTIONError(Exception):
|
||||
|
||||
|
||||
def _load_crypto_libcrypto():
|
||||
from ctypes import (
|
||||
CDLL,
|
||||
POINTER,
|
||||
c_void_p,
|
||||
c_char_p,
|
||||
c_int,
|
||||
c_long,
|
||||
Structure,
|
||||
c_ulong,
|
||||
create_string_buffer,
|
||||
cast,
|
||||
)
|
||||
from ctypes import (CDLL, POINTER, Structure, c_char_p, c_int, c_long,
|
||||
c_ulong, c_void_p, cast, create_string_buffer)
|
||||
from ctypes.util import find_library
|
||||
|
||||
if sys.platform.startswith("win"):
|
||||
|
@ -1,10 +1,9 @@
|
||||
import time
|
||||
|
||||
import openai
|
||||
from os import environ
|
||||
|
||||
from .base_translator import Base
|
||||
import openai
|
||||
|
||||
from .base_translator import Base
|
||||
|
||||
PROMPT_ENV_MAP = {
|
||||
"user": "BBM_CHATGPTAPI_USER_MSG_TEMPLATE",
|
||||
|
23
setup.py
Normal file
23
setup.py
Normal file
@ -0,0 +1,23 @@
|
||||
#!/usr/bin/env python3
|
||||
from setuptools import find_packages, setup
|
||||
|
||||
setup(
|
||||
name="bbook_maker",
|
||||
description="The bilingual_book_maker is an AI translation tool that uses ChatGPT to assist users in creating multi-language versions of epub/txt files and books.",
|
||||
version="0.1.0",
|
||||
license="MIT",
|
||||
author="yihong0618",
|
||||
author_email="zouzou0208@gmail.com",
|
||||
packages=find_packages(),
|
||||
url="https://github.com/yihong0618/bilingual_book_maker",
|
||||
python_requires=">=3.7",
|
||||
install_requires=["bs4", "openai", "requests", "ebooklib", "rich", "tqdm"],
|
||||
classifiers=[
|
||||
"Programming Language :: Python :: 3",
|
||||
"License :: OSI Approved :: MIT License",
|
||||
"Operating System :: OS Independent",
|
||||
],
|
||||
entry_points={
|
||||
"console_scripts": ["bbook_maker = book_maker.cli:main"],
|
||||
},
|
||||
)
|
Loading…
x
Reference in New Issue
Block a user