转诊。
cp2trans的Python项目详细描述
cp2trans
从剪贴板翻译文本。
安装
此脚本是为Windows编写的。相信这是一个很难设置,但很容易使用的方法:)。
- Windows10上的Python37。
- 通过
pip install -U pip
升级pip。 - 从https://aws.amazon.com/cli/安装
aws-cli
,并通过aws configure
启动aws。 - 从https://github.com/ikegami-yukino/mecab/releases/tag/v0.996安装mecab。添加
/bin
目录$path。 - 通过mecab-ipadic-neologd制作附加词典。
因为在Windows10上很难构建,我建议在UbuntuWSL上构建它并复制下面的所有文件
/usr/lib/x86_64-linux-gnu/mecab/dic/mecab-ipadic-neologd
进入C:\neologd\
如果你想要最新的字典。 Here是2019-05-11的一本预建字典。 - 注意:我们使用
pydub
的ffmpeg绑定来播放tts mp3音频。如果要启用tts,请从以下位置下载ffmpeg https://ffmpeg.zeranoe.com/builds/或者忽略警告。我们不会节省MP3,所以你应该注意它的成本。 - 通过
pip install -r requirements.txt
安装需求。如果系统默认编码不是utf-8,则可以 安装romkan
包失败。通常chcp
和locale.setdefaultencoding()
都不能解决这个问题 问题。我建议手动下载romkan source code并替换第12行README = open(os.path.join(here, 'README.rst')).read()
到README = open(os.path.join(here, 'README.rst'), encoding="utf-8").read()
。然后运行python .\setup.py install
。 - 复制
config.ini.example
的文件并将其重命名为config.ini
。填写appid
和secretkey
,确保 ^已启用此应用程序的{}。 - 通过
python .\cp2trans\cp2trans.py
运行脚本,或通过python setup.py install
安装cp2trans
(这样就可以通过步骤8)。
用法
PS C:\cp2translate>python.\cp2trans.py-husage:cp2trans[-h][--passwdlog_file][-psection][-llog_file][-epassword][-v{0,1}][-mpattern][-slang_code][-tlang_code][-d][-iseconds][-aagth_path][-oagth_opts]ClipboardtoTranslate.optionalarguments:-h,--helpshowthishelpmessageandexit--passwdlog_fileChangepasswordofanencryptedlog_fileorencrypt/decryptlog_fileandexit.-psection,--profilesectionLoadprofiledoptionsfromthespecifiedsectionof"config.ini"file.Anyotheroptionsfromcommandlinewillbeignored.Seedetailsin"config.example.ini".-llog_file,--loglog_fileSaveandreadtranslationhistory from"log_file"tosaveAPIcalls.-epassword,--encryptpasswordEncryptlogfileifyoudon't want it too exposed ;P. Have to be specified while loading an encrypted log file. -v {0,1}, --voice {0,1} Voice of TTS. "0" for male and "1" for female. Unset for disable TTS. -m pattern, --match pattern Only TTS when match <pattern>. -s lang_code, --source lang_code Source language code. Romkan will only be shown with "ja". -t lang_code, --target lang_code Primary uses Youdao API and the secondary by AWS translate API. -d, --disable Disable AWS translate api in low network connection environment. Log won'tberecordedintodisk(butwillbeinmemory)ifset.-iseconds,--intervalsecondsTimeintervalinsecondstochecktheclipboard.-aagth_path,--agthagth_pathStart AGTHtexthook."agth_path"mustbespecified.Youmightalsohavetospecify-ooption.-oagth_opts,--optagth_optsExtraoptionspassedto"agth.exe".Seedetailsbythehelpbuttonof"agth.exe"window.