前言
在工作中,程序狗需大量查看datasheet等英文文档,实际上看中文效率高一些,所以需要翻译PDF,对照查看,妈妈再也不用担心我的学习。
下述提供本地部署的PDF翻译工具,需要一点点命令行知识。
babeldoc翻译使用说明
babeldoc是一款开源的本地PDF翻译工具,沉浸式翻译员工开发的新翻译工具,支持调用大模型API翻译(deepseek、火山等),尚在更新,些许小bug,排版效果好。
github链接:github.com/funstory-ai/BabelDOC
翻译效果图:
(1)win10下部署说明:需要python3.10.0~3.12.0环境。
这里建议下载python3.12.0环境:https://www.python.org/downloads/release/python-3120/
安装python,并添加到环境变量。
(2)确认python环境已安装:打开命令行输入python即可。
(3)安装uv工具:根据提示加入环境变量。
pip install uv
(4)安装BabelDOC
:
uv tool install --python 3.12 BabelDOC
(5)输入下述命令,下载字体(可能需要翻墙,如果报错的话)。
babeldoc --help
(6)可以使用babeldoc进行翻译了。
默认使用bing翻译:
babeldoc --bing --files example.pdf
# multiple files
babeldoc --bing --files example1.pdf --files example2.pdf
#可以跟上增强型兼容选项,避免翻译格式空白异常
babeldoc --bing --files example.pdf --enhance-compatibility
使用config.toml文件指定ai翻译配置,及其他配置项:
qps设置并发,越大翻译越快,推荐128,如果翻译报错则减少并发量(跟api服务端并发量限制相关,推荐使用火山引擎的Doubao-1.5-pro进行翻译,翻译效果佳,价格合适)。相应修改openai-model、openai-base-url、openai-api-key即可。
[babeldoc]
#debug = true
lang-in = "en-US"
lang-out = "zh-CN"
qps = 16
openai = true
#openai-model = "ep-20250218161951-tjpcr" #lite
openai-model = "ep-20250218163426-6bxqk" #pro
openai-base-url = "https://ark.cn-beijing.volces.com/api/v3"
openai-api-key = "037d190d-4713-xxxx-xxxx-8aaf63f81cd3"
# All other options can also be set in the configuration file.
放置config文件、待翻译的pdf文件到同级目录。
命令行输入下述命令即可开始翻译。
babeldoc -c config.toml --files xapp1208-bitslip-logic.pdf --enhance-compatibility