Signed-off-by: lilium-saber <WR364999428@hotmail.com>
GDN
lilium-saber 1 year ago
parent ab2e06535a
commit 92907c90c4

@ -6,14 +6,19 @@ using System.Threading.Tasks;
namespace testRjgc.transToNet
{
interface StrToJson
interface Messiah
{
public abstract string RequestJsonPrivate(string input, string srcl, string dstl, string aid, string kkey);
public abstract string RequestJsonPrivateBaiDu(string input, string srcl, string dstl, string aid, string kkey);
public abstract string RequestJsonLanguageChange(string input, string srcl, string dstl);
public abstract string RequestJsonLanguageChangeBaiDu(string input, string srcl, string dstl);
public abstract string RequestJsonBaiDu(string input);
public abstract string RequestJsonXunFei(string input);
public abstract string RequestJsonPrivateXunFei(string input, string srcl, string dstl, string xid, string xkey);
public abstract string RequestJsonLanguageChangeXunFei(string input, string srcl, string dstl);
}
/*

@ -16,14 +16,22 @@ using System.Web;
namespace testRjgc.transToNet
{
internal class jsonNet : StrToJson
internal class jsonNet : Messiah
{
static string https = "http://api.fanyi.baidu.com/api/trans/vip/translate?";
static string appid = "20230925001829663";//20230925001829663,20230923001827495
static Random rd = new Random();
static string salt = rd.Next(100000).ToString();
static string key = "f7ZHpw28izQ1VU_ixoY5";//f7ZHpw28izQ1VU_ixoY5,yjvMNY33Qc1TYSBjTQYQ
//baidu
static string xunweb = "https://itrans.xf-yun.com/v1/its";
static string xunid = "1299c840";
static string xunsec = "M2Q4YzkzZTIwZjNkMGE2ZjkwZWMxNzZk";
static string xunkey = "828cb2dc915d28464a904bda5d7b01b3";
static string xunfl = "ja";
static string xundl = "cn";
static string xuntxt = "白上";
//static HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create("http://api.fanyi.baidu.com/api/trans/vip/translate?q=apple&from=en&to=zh&appid=20230925001829663&salt=1435660288&sign=c963bc2275c0fd1ed30da014c1ef1933");
@ -64,7 +72,7 @@ namespace testRjgc.transToNet
return sb.ToString();
}
public string RequestJsonPrivate(string input, string srcl, string dstl, string aid, string kkey)//自定义idkey以及源语言和目标语言
public string RequestJsonPrivateBaiDu(string input, string srcl, string dstl, string aid, string kkey)//自定义idkey以及源语言和目标语言
{
string sign = EncryptString(aid + input + salt + kkey);
@ -89,7 +97,7 @@ namespace testRjgc.transToNet
return s;
}
public string RequestJsonLanguageChange(string input, string srcl, string dstl)//可以自定义源语言与目标语言
public string RequestJsonLanguageChangeBaiDu(string input, string srcl, string dstl)//可以自定义源语言与目标语言
{
string sign = EncryptString(appid + input + salt + key);
@ -137,9 +145,22 @@ namespace testRjgc.transToNet
Trans_result result = temp1.trans_result[0];
string s = result.dst;
return s;
}
public string RequestJsonXunFei(string input)
{
return "error";
}
public string RequestJsonPrivateXunFei(string input, string srcl, string dstl, string xid, string xkey)
{
return "error";
}
public string RequestJsonLanguageChangeXunFei(string input, string srcl, string dstl)
{
return "error";
}
}
public class Trans_result
{

@ -0,0 +1,71 @@
using System.Drawing;
using System;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using System.Runtime.InteropServices;
using System.Windows.Forms;
namespace testRjgc.WinOcr
{
internal class OcrSofia : Sofia
{
static string path = Directory.GetCurrentDirectory() + "\\TempImage";
public OcrSofia() { }
public string WindowsOcrToGetStringAndTranslate(string name)
{
string retxt = "";
this.DirExists();
Image image = null;
MODI.Document modiDocument = new MODI.Document();
modiDocument.Create(path + "\\" + name + ".jpg");
modiDocument.OCR(MODI.MiLANGUAGES.miLANG_CHINESE_SIMPLIFIED, true, true);
MODI.Image modiImage = (MODI.Image)modiDocument.Images[0];
retxt = modiImage.Layout.Text;
return retxt;
}
public void DirExists()
{
if(Directory.Exists(path))
{
Directory.CreateDirectory(path);
}
}
/*
internal class OcrSofia : Sofia
{
public OcrSofia() { }
public string WindowsOcrToGetStringAndTranslate()
{
string result = "";
// 获取剪贴板中的图像
Image image = Clipboard.GetImage();
// 将图像保存到临时文件中
string tempFile = Path.GetTempFileName();
image.Save(tempFile, ImageFormat.Tiff);
// 使用Windows OCR引擎识别图像中的文本
MODI.Document modiDocument = new MODI.Document();
modiDocument.Create(tempFile);
modiDocument.OCR(MODI.MiLANGUAGES.miLANG_CHINESE_SIMPLIFIED, true, true);
MODI.Image modiImage = (MODI.Image)modiDocument.Images[0];
result = modiImage.Layout.Text;
// 删除临时文件
File.Delete(tempFile);
return result;
}
}
*/
}
}

@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace testRjgc.WinOcr
{
internal interface Sofia
{
public abstract string WindowsOcrToGetStringAndTranslate(string name);
}
}

@ -7,7 +7,7 @@ using System.Threading.Tasks;
namespace WpfApp1.translationKey
{
interface TranslationApiStr
interface TranslationApiStr//Mohammed
{
public abstract List<string> OutputTranslationS(string id);

@ -17,7 +17,7 @@ namespace WpfApp1.translationKey
public void InputTranslationPrivate(string name, string id, string key)
{
if(!Directory.Exists(pathTemp))
if(Directory.Exists(pathTemp))
{
Directory.CreateDirectory(pathTemp);
}

@ -58,7 +58,7 @@ namespace WpfApp1.translationKey
List<string> temp = new List<string> { };
if (Directory.Exists(temppath))
if (Directory.Exists(temppath))//诺不存在
{
temp.Add("ERROR");
return temp;

@ -16,8 +16,9 @@ namespace WpfApp1.translationKey
{
case 0://讯飞
{
temp.Add("");//APISecret
temp.Add("");//APIKey
temp.Add("1299c840");//id
temp.Add("M2Q4YzkzZTIwZjNkMGE2ZjkwZWMxNzZk");//APISecret
temp.Add("828cb2dc915d28464a904bda5d7b01b3");//APIKey
break;
}
case 1://百度

Loading…
Cancel
Save