Giter VIP home page Giter VIP logo

dta's Introduction

Desktop Tools Assistant

Desktop Tools Assistant是一款仿BobPopClip.的屏幕取词、OCR、翻译、取色工具,使用Electron、Vite、Vue3开发。

图片识别、翻译功能可仅使用自建服务(paddocr + meta-ai fairseq nllb)

集成ahk2,自定义按键后可拥有与macos同样的按键体验

截图

主界面 翻译.png 查词

已接入的OCR

  • PaddleOCR 识别率还行,部署在自己的服务器比较放心。后面考虑集成本地版
    docker run --name ppdocr -p 8866:8866 -d drainkeng/paddleocr:2.6-cpu-latest
  • 百度文字识别OCR 备选方案

已接入语种识别

已接入文本翻译(已删除效果较差的接口)

配置文件

  • 自己申请接口后修改这部分,涉及到各种密钥,我就不提交这个文件了

  • 路径在electron/config.ts

  • 不加没法运行!!!!

import { IConfig } from '@/types'

export default {
	init: true,
	//  截图类型,shareX、html
	screenhost_type: 'shareX',
	//  滑词检索配置
	takeword: {
		//  启用
		enable: true,
		//  自动隐藏时间,单位:秒
		auto_hide_time: 1,
		//  跳过要处理的进程,进程名称、路径
		skip: ['MobaXterm_Personal_22.1.exe', 'D:\\JetBrains\\apps', 'C:\\Program Files\\PowerShell', 'WindowsTerminal.exe', 'explorer.exe']
	},
	//  翻译配置
	trans: {
		//  钉住窗口
		pinup: false,
		//  默认启动位置,未使用
		position: 'right-top',
		//  语言检测方式
		lang_testing: 'local',
		//  ocr识别方式
		current_ocr: 'paddocr',
		//  识图后复制到剪切板
		ocr_clipboard: true,
		//  单个翻译接口超时时间
		timeout: 15,
		//  本地ip前缀
		local_ip: '172.20.0.',
		//  ocr配置
		ocr: [
			{
				enable: true,
				name: 'baidu',
				label: '百度通用场景文本识别',
				token_url: 'https://aip.baidubce.com/oauth/2.0/token?grant_type=client_credentials',
				url: 'https://aip.baidubce.com/rest/2.0/ocr/v1/',
				client_id: '',
				client_secret: '',
				detect_direction: true,
				type: '标准' as '高精度' | '高精度含坐标' | '标准' | '标准含坐标',
				type_action: { 标准: 'general_basic', 标准含坐标: 'general', 高精度: 'accurate_basic', 高精度含坐标: 'accurate' }
			},
			{ enable: true, name: 'paddocr', label: '飞桨OCR', url: '你的地址' }
		],
		translate: [
			{ enable: true, name: 'youdao', label: '有道翻译', url: 'http://openapi.youdao.com/api', appKey: '', key: '' },
			{ enable: true, name: 'baidu', label: '百度翻译', url: 'https://fanyi-api.baidu.com/api/trans/vip/translate', appid: '', secret: '' },
			{ enable: true, name: 'google', label: '谷歌翻译', zh2en_enable: false, url: 'https://你的workers地址.workers.dev/trans', apiKey: '' },
			{ enable: true, name: 'tencent', label: '腾讯翻译', url: 'tmt.tencentcloudapi.com', region: 'ap-chengdu', secretId: '', secretKey: '' },
			{ enable: true, name: 'wechat', label: '微信翻译', url: 'https://api.weixin.qq.com/cgi-bin', appid: '', secret: '' },
			{ enable: true, name: 'caiyun', label: '彩云小译', url: 'http://api.interpreter.caiyunai.com/v1/translator', token: '' }
		],
		languages: [
			{ name: '中文', default: 'zh', wechat: 'zh_CN', youdao: 'zh-CHS', google: 'zh_CN' },
			{ name: '英语', default: 'en', wechat: 'en_US' },
			{ name: '日语', default: 'ja', wechat: '-' },
			{ name: '韩语', default: 'ko', baidu: 'kor', caiyun: '-', wechat: '-' },
			{ name: '俄语', default: 'ru', caiyun: '-', wechat: '-' },
			{ name: '德语', default: 'de', caiyun: '-', wechat: '-' },
			{ name: '法语', default: 'fr', baidu: 'fra', caiyun: '-', wechat: '-' }
		]
	}
} as IConfig

......

  • 飞桨OCR部署完成后的地址是host:port/predict/ocr_system.我自己代理了一层到cdn,要用的话记得改成你自己的url
  • google api调用建议使用CloudFlare的Workers,稳定免费,脚本如下:
unction
main(request)
{
	const { lang, text, key } = await request.json()
	const req = { "target": lang, "q": text }
	const response = await fetch(
		'https://translation.googleapis.com/language/translate/v2?key=' + key,
		{ body: JSON.stringify(req), method: 'POST', headers: { 'content-type': 'application/json;charset=UTF-8' } }
	)
	const { headers, status } = response
	if (status == "200" && headers.get('content-type').includes('application/json')) {
		const res = await response.json()
		if (res.data) {
			let translations = res.data.translations
			return (Array.isArray(translations) ? translations[0] : translations).translatedText
			// detectedSourceLanguage
		}
	}
	throw new Error("Failed response from Google Translate")
}

export default {
	async fetch(request, env) {
		if (request.method !== 'POST' || !request.url.endsWith('/trans')) {
			return new Response('', { status: 404, headers: { "Cache-Control": "no-cache" } })
		}
		let status = true
		let text = ''
		try {
			text = await main(request)
		} catch (e) {
			status = false
			text = e.message
		}
		return new Response(text, { status: status ? 200 : 400, headers: { "Cache-Control": "no-cache" } })
	}
}
  • 只支持了部分语言,有需要的自己加,文末有各平台语言编码对照链接
  • 只使用了常用的包,理论都能自己打包出来
  • 集成了AutoHotKey 2.0,做改键会更像mac,打包成dll了,放在pack/ahkh2x64.dll,改键脚本是pack/Mac.ahk

各平台语言编码

有道

彩云

google

腾讯

百度

end

dta's People

Contributors

danger-dream 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

Watchers

 avatar  avatar  avatar

dta's Issues

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.