转诊。

cp2trans的Python项目详细描述


cp2trans

从剪贴板翻译文本。

安装

此脚本是为Windows编写的。相信这是一个很难设置,但很容易使用的方法:)。

  1. Windows10上的Python37。
  2. 通过pip install -U pip升级pip。
  3. https://aws.amazon.com/cli/安装aws-cli,并通过aws configure启动aws。
  4. https://github.com/ikegami-yukino/mecab/releases/tag/v0.996安装mecab。添加/bin目录$path。
  5. 通过mecab-ipadic-neologd制作附加词典。 因为在Windows10上很难构建,我建议在UbuntuWSL上构建它并复制下面的所有文件 /usr/lib/x86_64-linux-gnu/mecab/dic/mecab-ipadic-neologd进入C:\neologd\如果你想要最新的字典。 Here是2019-05-11的一本预建字典。
  6. 注意:我们使用pydub的ffmpeg绑定来播放tts mp3音频。如果要启用tts,请从以下位置下载ffmpeg https://ffmpeg.zeranoe.com/builds/或者忽略警告。我们不会节省MP3,所以你应该注意它的成本。
  7. 通过pip install -r requirements.txt安装需求。如果系统默认编码不是utf-8,则可以 安装romkan包失败。通常chcplocale.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
  8. 复制config.ini.example的文件并将其重命名为config.ini。填写appidsecretkey,确保 ^已启用此应用程序的{}。
  9. 通过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.

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
ApachePOI如何通过java从excel文件中删除空白列?   linux到后台Java服务应用程序的简单发送/接收接口   java ActionBarPullToRefresh什么都没发生   java从millis获取错误的整数天   java相同的代码在两个不同的包上表现不同   java将每个新的char元素写入一个文件(如果被覆盖)   mysql如何在Java中通过外键链接的多个表中插入数据   java环境下mysql网络文件访问   java当使用构建器模式时,为什么我不应该重用builderobject来访问对象配置?   java jQueryServlet post异常失败   java应该使用什么逻辑来创建像《愤怒的小鸟》中那样的锁屏   java Android:在不滑动的情况下更改ViewPager中的片段   java在使用我的程序逻辑时获得空输出