Code Monkey home page Code Monkey logo

potplayer_translate_plug_in's Introduction

Jokes Card

Ashutosh's github activity graph

potplayer_translate_plug_in's People

Contributors

xu-hardy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

janot hongff666

potplayer_translate_plug_in's Issues

大佬能根据彩云小译的api, 做个potplayer字幕翻译插件吗....

创建 bash 脚本,xiaoyi.sh:
#!/bin/bash
tee xiaoyi.sh << END
DIRECTION=$1
SOURCE=$2

if test -f $HOME/.xiaoyi ; then
. $HOME/.xiaoyi
fi

BODY='{"source": ["'$SOURCE'"], "trans_type": "'$DIRECTION'", "replaced": true, "media": "text", "request_id": "demo" }'

export PYTHONIOENCODING=utf8
curl -s -X POST [http://api.interpreter.caiyunai.com/v1/translator](http://api.interpreter.caiyunai.com/v1/translator%5C)
-H 'Content-Type: application/json'
-H "X-Authorization: token 填自己的token"
-d "$BODY" | python -c "import sys, json; print json.load(sys.stdin)['target'][0]"
END
输入您想要翻译的英文句子并运行以下指令:
sh xiaoyi.sh en2zh "The sentence you want to translate."

创建 python 脚本:
import requests
import json

url = "http://api.interpreter.caiyunai.com/v1/translator"

token = "填自己的token"

payload = {
"source" : ["Lingocloud is the best translation service.",
"ColorfulClouds Weather is the best weather service."],
"trans_type" : "en2zh",
"request_id" : "demo",
}

headers = {
'content-type': "application/json",
'x-authorization': "token " + token,
}

response = requests.request("POST", url, data=json.dumps(payload), headers=headers)

print(response.text)
print(json.loads(response.text)['target'][0])
print(json.loads(response.text)['target'][1])
输出:
{"confidence":0.8,"target":["\u5f69\u4e91\u5c0f\u8bd1\u662f\u6700\u597d\u7684\u7ffb\u8bd1\u670d\u52a1\u3002",
"\u5f69\u4e91\u5929\u6c14\u662f\u6700\u597d\u7684\u6c14\u8c61\u670d\u52a1\u3002"],"rc":0}

彩云小译是最好的翻译服务。
彩云天气是最好的气象服务。

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.