提示:当前为新版开放平台,仅支持页数计费相关显示。旧版付费模式(积分模式),请切换旧版(http://open.fanyigou.com)使用,感谢您的理解!

文档翻译

接入流程

注册翻译狗开放平台 登陆并添加开发者信息 创建应用 参考文档完成部署 测试完成

接口规则

为了带给客户简单、一致且易用的开发体验,我们规范了接口规则,你需要根据规范配置相关内容,请参考“接口规则”,如token的生成规则状态码列表等请查看该文档。

接口调用流程

1.普通文档翻译流程

  • a. 上传文档进行翻译(详见文档上传接口
  • b. 查询翻译进度(详见任务查询进度接口
  • c. 下载译文(详见文档下载接口

2.文档检测页数后提交翻译流程

  • a. 上传文档检测页数(上传文件检测页数接口
  • b. 若a未返回文档页数,则c,否则d
  • c. 查询文档检测页数(任务查询进度接口),有页数返回则d
  • d. 把上述检测出页数的文档提交翻译(检测页数文件提交翻译接口)
  • e. 查询翻译进度(任务查询进度接口
  • f. 下载译文(下载接口

接口说明

文档上传接口

接口名称:uploadTranslate

接口完整路径:https://www.fanyigou.com/TranslateApi/api/uploadTranslate

请求方式:post(file参数请以 multipart/form-data 方式的表单 POST 提交)

注意:

1.上传格式:pdf、Microsoft Office(doc、docx、dot、dotx、dotm、docm、xml、odt)、WPS Office(wps、wpt)、xls、xlsx、et、ett、ppt、pptx、dps、dpt、txt、rtf;

2.上传文件最大50M(如有更高需求请联系销售);

3. 不支持图纸、纯图片文档,加密文件请先去除密码;

4.翻译完成后按页从主账号里扣费;

5.目前普通账户支持一条翻译通道(即只能同时进行一个文件的上传翻译),(如有更高需求请联系销售);

入参列表配置:

参数名称参数说明参数类型备注是否必填
appid应用的唯一识别标记String
token签名String见token生成规则
nonce_str随机字符串String
from源语言String见语言列表
to目标语言(不支持自动检测)String见语言列表
md5源文件md5Stringmd5小写
industryId行业代码int见行业列表
transImg文档内图片翻译int0:不翻译文档内图片(默认),1:翻译文档内图片。目前支持中、英、日、韩的文档内图片翻译。(如有需要请联系销售开通)
excelMode指定excel翻译模式int0:只翻译当前打开sheet(默认),1:翻译全部sheet(页数按全部sheet字符数来计算)
bilingualControl指定翻译模式int0:译文单独为一个文档(默认),1:双语对照(原文和译文在一个文档)

出参列表配置:

参数名称参数说明参数类型备注
code状态码int详见状态码列表
msg返回状态说明String
data返回数据结果集StringJson字符串

data结果集:

参数名称参数说明参数类型备注
tid翻译idString通过该id可查询翻译进度等

返回结果:

{"code": 100,"data": {"tid": 14587},"msg": "请求成功"}

文档下载接口

接口名称:downloadFile

接口完整路径:https://www.fanyigou.com/TranslateApi/api/downloadFile

接口说明:根据tid下载文档(任务完成才能下载)

入参列表配置:

参数名称参数说明参数类型备注是否必填
appid应用的唯一识别标记String
token签名String见token生成规则
nonce_str随机字符串String
dtype下载的文件类型(new):
2:翻译后的pdf文件,支持格式:word、pdf、img。
3:翻译后的word文件(支持格式:word、pdf);ppt文件(支持格式:img、ppt);excel文件(支持格式:excel)
6:转换完成文档
int
tid查询状态结果Idint上传源文件后可获取该ID

出参列表配置:

说明:1.判断Response Headers 中 detectLanguage 的值,若存在且不为空即为自动检测出的语言(可能为多种语言),仅供参考
2.判断Response Headers 中Content-Type 的值,若包含"application/octet-stream" 则可直接进行下载,否则即为以下返回值

参数名称参数说明参数类型备注
code状态码int详见状态码列表
msg返回状态说明String

返回结果:

{"code": 312,"msg": "该翻译不存在"}

任务查询进度接口

接口名称:queryTransProgress

接口完整路径:https://www.fanyigou.com/TranslateApi/api/queryTransProgress

接口说明:提交任务完成后可调用此接口实时查询翻译、转换进度或检测页数进度

入参列表配置:

参数名称参数说明参数类型备注是否必填
appid应用的唯一识别标记String
token签名String见token生成规则
nonce_str随机字符串String
tid查询状态结果Id int

出参列表配置:

参数名称参数说明参数类型备注
code状态码int详见状态码列表
msg返回状态说明String
data返回数据结果集StringJson字符串

data结果集:

参数名称参数说明参数类型备注
tid查询翻译idint通过该id可查询翻译进度等
title文件名String
docType文件类型String
fromLan源语言String
toLan目标语言String
detectLan检测语言String不为空即为自动检测出的主要语言,仅供参考
percent进度String
pageCount文件页数int
status状态int详见文件状态码,314为翻译完成,330为检测页数完成
msg状态说明String
createTime创建时间String
updateTime更新时间String

返回结果:

                                
                {
                    "code": 100,
                    "data": {
                        "createTime": "2018-03-27 16:57:51",
                        "docType": "docx",
                        "fromLan": "",
                        "msg": "正在翻译",
                        "pageCount": 1,
                        "percent": "99.00",
                        "status": 313,
                        "tid": 14587,
                        "title": "测试",
                        "toLan": "中文",
                        "updateTime": "2018-03-27 16:58:00"
                    },
                    "msg": "请求成功"
                }
                            

上传文件检测页数

接口名称:detectDocPage

接口完整路径:https://www.fanyigou.com/TranslateApi/api/detectDocPage

接口说明:用户调用接口进行 源文件上传,上传完成后可调用查询进度接口查询页数。注意:

1.上传格式:pdf、Microsoft Office(doc、docx、dot、dotx、dotm、docm、xml、odt)、WPS Office(wps、wpt)、xls、xlsx、et、ett、ppt、pptx、dps、dpt、txt、rtf

2.上传文件最大50M(如有更高需求请联系销售)

3.不支持图纸、纯图片文档,加密文件请先去除密码

4.该功能需联系客服开通

调用说明:请求方式:post, file参数请以 multipart/form-data 方式的表单 POST 提交

入参列表配置:

参数名称参数说明参数类型备注是否必填
appid应用的唯一识别标记String
token签名String见token生成规则
nonce_str随机字符串String
md5源文件md5Stringmd5小写
excelMode指定excel翻译模式int0:只翻译当前打开sheet(默认),1:翻译全部sheet(页数按全部sheet字符数来计算)

出参列表配置:

参数名称参数说明参数类型备注
code状态码int详见状态码列表
msg返回状态说明String
data返回数据结果集StringJson字符串

data结果集:

参数名称参数说明参数类型备注
tid翻译idint通过该id可查询任务进度等
page检测到的页数int检测页数(大于0即检测成功,等于0则转入后台检测,需要调用进度接口查询页数,返回页数大于0即为成功)

返回结果:

{"code": 100,"data": {"tid": 14587,"page",20},"msg": "请求成功"}

检测页数文件提交翻译

接口名称:submitForDetectDoc

接口完整路径:https://www.fanyigou.com/TranslateApi/api/submitForDetectDoc

接口说明:用户调用检测页数接口的文档提交翻译,注意:

同一个tid提交一次翻译即可。

调用说明:请求方式:get,post

入参列表配置:

参数名称参数说明参数类型备注是否必填
appid应用的唯一识别标记String
token签名String见token生成规则
nonce_str随机字符串String
tid检测文档页数接口返回的tidint
from源语言String见语言列表
to目标语言(不支持自动检测)String见语言列表
industryId行业代码int见行业列表
transImg文档内图片翻译int0:不翻译文档内图片(默认),1:翻译文档内图片。目前支持中、英、日、韩的文档内图片翻译。(如有需要请联系销售开通)
bilingualControl指定翻译模式int0:译文单独为一个文档(默认),1:双语对照(原文和译文在一个文档)

出参列表配置:

参数名称参数说明参数类型备注
code状态码int详见状态码列表
msg返回状态说明String
data返回数据结果集StringJson字符串

返回结果:

{"code": 100,"msg": "请求成功"}

文字翻译

接入流程

注册翻译狗开放平台 登陆并添加开发者信息 创建应用 参考文档完成部署 测试完成

接口规则

为了带给客户简单、一致且易用的开发体验,我们规范了接口规则,你需要根据规范配置相关内容,请参考“接口规则”,如token的生成规则状态码列表等请查看该文档。

接口说明

文字翻译接口

接口名称:trans

接口完整路径:https://www.fanyigou.com/TranslateApi/api/trans

接口说明:

1.待翻译文本字符长度不能超过2000;

2.语言方向:英、日、俄、韩、德、法、意 到中;中、日、俄、韩、德、法、意 到英

调用说明:请求方式:post

入参列表配置:

参数名称参数说明参数类型备注是否必填
appid应用的唯一识别标记String
token签名String见token生成规则
nonce_str随机字符串String
from源语言String
to目标语言String
text待翻译文本,需UTF-8编码String

出参列表配置:

参数名称参数说明参数类型备注
code状态码int详见状态码列表
msg返回状态说明String
data返回数据结果集StringJson字符串

data结果集:

参数名称参数说明参数类型备注
msg状态说明String
transResult翻译译文String
status任务状态int

返回结果:

{"code":0,"data":{"msg":"翻译成功","transResult":"Test text translation time ","status":314},"msg":"请求成功"}

格式转换

接入流程

注册翻译狗开放平台 登陆并添加开发者信息 创建应用 参考文档完成部署 测试完成

接口规则

为了带给客户简单、一致且易用的开发体验,我们规范了接口规则,你需要根据规范配置相关内容,请参考“接口规则”,如token的生成规则状态码列表等请查看该文档。

接口调用流程

1.上传文档进行转换(详见文档转换接口

2.查询转换进度(详见任务查询进度接口

3.下载转换文档(详见下载接口

接口说明

文档转换接口

接口名称:convert

接口完整路径:https://www.fanyigou.com/TranslateApi/api/convert

接口说明:用户调用接口进行 源文件上传,上传完成后会自动进行转换,通过tid可以查询转换的进度等数据。注意:

1.上传格式:pdf、doc、docx、ppt、pptx、xls、xlsx、hwp、caj、ofd

2.上传文件最大50M (如有更高需求请联系销售)

3.加密文件请先去除密码

4.转换完成后按页从主账号里扣费

调用说明:请求方式:post, file参数请以 multipart/form-data 方式的表单 POST 提交

入参列表配置:

参数名称参数说明参数类型备注是否必填
appid应用的唯一识别标记String
token签名String见token生成规则
nonce_str随机字符串String
from源文件的语言(扫描件需设置语言)String
conversionFormat转换的目标格式(目前支持pdf到其它格式的转换(excel,ppt,word,ofd),及其它格式(excel,ppt,word,hwp,caj,ofd)到pdf的转换) -1:word;-3:excel;-6:pptx,-8:pdf,-9:ofd。int
md5源文件md5String

出参列表配置:

参数名称参数说明参数类型备注
code状态码int详见状态码列表
msg返回状态说明String
data返回数据结果集StringJson字符串

data结果集:

参数名称参数说明参数类型备注
tid任务idString通过该id可查询进度等

返回结果:

{"code": 100,"data": {"tid": 14587},"msg": "请求成功"}

任务查询进度接口

接口名称:queryTransProgress

接口完整路径:https://www.fanyigou.com/TranslateApi/api/queryTransProgress

接口说明:提交任务完成后可调用此接口实时查询翻译、转换进度或检测页数进度

入参列表配置:

参数名称参数说明参数类型备注是否必填
appid应用的唯一识别标记String
token签名String见token生成规则
nonce_str随机字符串String
tid查询状态结果Id int

出参列表配置:

参数名称参数说明参数类型备注
code状态码int详见状态码列表
msg返回状态说明String
data返回数据结果集StringJson字符串

data结果集:

参数名称参数说明参数类型备注
tid查询转换idint通过该id可查询进度等
title文件名String
docType文件类型String
fromLan源语言String
toLan目标语言String
detectLan检测语言String不为空即为自动检测出的主要语言,仅供参考
percent进度String
pageCount文件页数int
status状态int详见文件状态码,314为转换完成
msg状态说明String
createTime创建时间String
updateTime更新时间String

返回结果:

                                
                {
                    "code": 100,
                    "data": {
                        "createTime": "2018-03-27 16:57:51",
                        "docType": "docx",
                        "fromLan": "",
                        "msg": "进行中",
                        "pageCount": 1,
                        "percent": "99.00",
                        "status": 313,
                        "tid": 14587,
                        "title": "测试",
                        "toLan": "中文",
                        "updateTime": "2018-03-27 16:58:00"
                    },
                    "msg": "请求成功"
                }
                            

下载接口

接口名称:downloadFile

接口完整路径:https://www.fanyigou.com/TranslateApi/api/downloadFile

接口说明:根据tid下载文档(任务完成才能下载)

入参列表配置:

参数名称参数说明参数类型备注是否必填
appid应用的唯一识别标记String
token签名String见token生成规则
nonce_str随机字符串String
dtype下载的文件类型(new):
2:翻译后的pdf文件,支持格式:word、pdf、img。
3:翻译后的word文件(支持格式:word、pdf);ppt文件(支持格式:img、ppt);excel文件(支持格式:excel)
6:转换完成文档
int
tid查询状态结果Idint上传源文件后可获取该ID

出参列表配置:

说明:1.判断Response Headers 中 detectLanguage 的值,若存在且不为空即为自动检测出的语言(可能为多种语言),仅供参考
2.判断Response Headers 中Content-Type 的值,若包含"application/octet-stream" 则可直接进行下载,否则即为以下返回值

参数名称参数说明参数类型备注
code状态码int详见状态码列表
msg返回状态说明String

返回结果:

{"code": 312,"msg": "该转换不存在"}

图片翻译

接入流程

注册翻译狗开放平台 登陆并添加开发者信息 创建应用 参考文档完成部署 测试完成

接口规则

为了带给客户简单、一致且易用的开发体验,我们规范了接口规则,你需要根据规范配置相关内容,请参考“接口规则”,如token的生成规则状态码列表等请查看该文档。

接口调用流程

1.上传图片进行翻译(详见图片上传接口

2.获取图片翻译进度(详见图片翻译获取进度接口

3.下载译文图片(详见图片翻译下载接口

接口说明

图片上传接口

接口名称:uploadTranslateImage

接口完整路径:https://www.fanyigou.com/TranslateApi/api/image/uploadTranslateImage

接口说明:用户调用接口进行 源文件上传,上传完成后会自动进行翻译,通过tid可以查询翻译的进度等数据。注意:

1.上传格式:jpg、jpeg、png、bmp

2.上传文件最大4M

3.支持15*15 - 2048*2048px尺寸内

4.翻译完成后按页从主账号里扣费

调用说明:请求方式:post, file参数请以 multipart/form-data 方式的表单 POST 提交

入参列表配置:

参数名称参数说明参数类型备注是否必填
appid应用的唯一识别标记String
token签名String见token生成规则
nonce_str随机字符串String
from源语言String见图片语言列表
to目标语言String见图片语言列表
md5源文件md5Stringmd5小写

出参列表配置:

参数名称参数说明参数类型备注
code状态码int详见状态码列表
msg返回状态说明String
data返回数据结果集StringJson字符串

data结果集:

参数名称参数说明参数类型备注
taskId翻译idString通过该id可查询翻译进度等

返回结果:

{"code": 100,"data": {"taskId": 14587},"msg": "请求成功"}

图片翻译获取进度接口

接口名称:queryImageTransProgress

接口完整路径:https://www.fanyigou.com/TranslateApi/api/image/queryImageTransProgress

接口说明:提交翻译完成后可调用此接口实时查询翻译进度或检测页数进度

入参列表配置:

参数名称参数说明参数类型备注是否必填
appid应用的唯一识别标记String
token签名String见token生成规则
nonce_str随机字符串String
tid查询状态结果Idint

出参列表配置:

参数名称参数说明参数类型备注
code状态码int详见状态码列表
msg返回状态说明String
data返回数据结果集StringJson字符串

data结果集:

参数名称参数说明参数类型备注
fromLan源语言String
toLan目标语言String
detectLan检测语言String不为空即为自动检测出的主要语言,仅供参考
percent任务进度String
pageCount文件页数int
status任务状态int0 是完成 1 进行中 -1 翻译失败
msg状态说明String
createTime创建时间String
updateTime更新时间String

返回结果:

{
        "msg": "请求成功",
        "code": 100,
        "data": {
            "tid": 13417,
            "createTime": "2022-10-26 11:21:02",
            "updateTime": "2022-10-26 11:30:35",
            "status": 0,
            "title": "5120791b2f0967b54e057dd8af5d87e",
            "pageCount": 1,
            "percent": "100.00",
            "fromLan": "中文","detectLan": "",
            "toLan": "英语",
            "docType": "png",
            "msg": "翻译成功",
            "originalCharCount": 0
        }
    }          
                        

图片翻译下载接口

接口名称:downloadImage

接口完整路径:https://www.fanyigou.com/TranslateApi/api/image/downloadImage

接口说明:根据tid下载文档(任务完成才能下载)

入参列表配置:

参数名称参数说明参数类型备注是否必填
appid应用的唯一识别标记String
token签名String见token生成规则
nonce_str随机字符串String
tid查询状态结果Idint上传源文件后可获取该ID

出参列表配置:

说明:1.判断Response Headers 中Content-Type 的值,若包含"application/octet-stream" 则可直接进行下载,否则即为以下返回值

参数名称参数说明参数类型备注
code状态码int详见状态码列表
msg返回状态说明String

返回结果:

{"code": 312,"msg": "该翻译不存在"}

OCR(图像识别)

接入流程

注册翻译狗开放平台 登陆并添加开发者信息 创建应用 参考文档完成部署 测试完成

接口规则

为了带给客户简单、一致且易用的开发体验,我们规范了接口规则,你需要根据规范配置相关内容,请参考“接口规则”,如token的生成规则状态码列表等请查看该文档。

接口说明

OCR上传接口

接口名称:ocrUploadImage

接口完整路径:https://www.fanyigou.com/TranslateApi/api/image/ocrUploadImage

接口说明:用户调用接口进行 源文件上传,上传完成后会自动进行识别并返回数据。注意:

1.上传格式:jpg、jpeg、png、bmp

2.上传文件最大4M

3.支持15*15 - 8192*8192px尺寸内

4.翻译完成后按次数从主账号里扣费

入参列表配置:

参数名称参数说明参数类型备注是否必填
appid应用的唯一识别标记String
token签名String见token生成规则
nonce_str随机字符串String
from源语言String见图片语言列表
md5源文件md5Stringmd5小写

出参列表配置:

参数名称参数说明参数类型备注
code状态码int详见状态码列表
msg返回状态说明String
data返回数据结果集StringJson字符串

data结果集:

参数名称参数说明参数类型备注
words_result_num识别文字行数Int
words_result识别文字Array[]
words识别文字内容String
location文字位置Object
top顶部Int
leftInt
widthInt
heightInt

返回结果:

{"msg":"请求成功","code":100,"data":{"words_result":[{"words":"X Headers","location":{"top":0,"left":47,"width":96," height":10}}],"words_result_num":9}} 

语音识别翻译

接入流程

注册翻译狗开放平台 登陆并添加开发者信息 创建应用 参考文档完成部署 测试完成

接口规则

为了带给客户简单、一致且易用的开发体验,我们规范了接口规则,你需要根据规范配置相关内容,请参考“接口规则”,如token的生成规则状态码列表等请查看该文档。

接口调用流程

1.获取websocket链接标识(详见语音识别获取链接标识接口

2.连接webscoket进行语音识别翻译

3.下载译文音频文件(详见获取译文音频链接接口

接口说明

语音识别获取链接标识接口

接口名称:getConnectionId

接口完整路径:https://www.fanyigou.com/TranslateApi/api/voice/online/getConnectionId

调用说明:请求方式:get,post

入参列表配置:

参数名称参数说明参数类型备注是否必填
appid应用的唯一识别标记String
token签名String见token生成规则
nonce_str随机字符串String
from源语言(目前支持中文或者英文)String见语言列表
to目标语言(目前支持英文或者中文)String见语言列表

出参列表配置:

参数名称参数说明参数类型备注
code状态码int详见状态码列表
msg返回状态说明String
data返回数据结果集Json字符串

data结果集:

参数名称参数说明参数类型备注
recordId音频文件翻译idInteger
connectionId用来websocket连接的connectionId

说明

连接webscoket进行语音识别翻译

完整路径:wss://www.fanyigou.com/TranslateApi/api/voice/trans/online/{connectionId}

{connectionId}: 获取connectionId进行websocket连接(详见语音识别获取链接标识接口

并在地址上拼接如下参数:

注意:

1.语音识别获取链接标识接口与当前的websocket传入的appid必须一致

2.connectionId的只有二十分钟有效期

3.connenctionId连接成功并发送音频数据后不能再使用当前connectionId进行二次连接

入参列表配置:

参数名称参数说明参数类型备注是否必填
appid应用的唯一识别标记String
token签名String见token生成规则
nonce_str随机字符串String

连接成功后:

1.发送采样率为16000,比特率为16bit,单声道的pcm格式数据

返回音频转换的原文文本{"state":"transing","transMsg":"转换的原文文本","msgType":0}

state":"transing" 表示当前正在翻译中,

音频转换原文内容为transMsg msgType为0表示为原文

返回音频转换的译文文本{"state":"transing","transMsg":"转换的译文文本","msgType":1}

2.录制结束

需要给服务器发送消息{"state":"recordend","transMsg":null,"msgType":null}

3.服务器翻译完成之后会返回翻译结果

翻译成功:{"state":"sucess","transMsg":null,"msgType":null}

翻译失败{"state":"fail","transMsg":null,"msgType":null}

如果返回翻译成功的则可以下载译文语音文件(详见获取译文音频链接接口

4.后端返回最终的翻译结果后,websocket连接可以关闭

5.注意:如果用户超过三十秒没有发送音频数据,超过最大实时语音的时长,或者余额不充足

服务器会返回

{"state":"receiveend","transMsg":null,"msgType":null}

结束翻译音频(之前发送的不受影响)

接口说明

获取译文音频链接接口

接口名称:getTransAudioLink

接口完整路径:https://www.fanyigou.com/TranslateApi/api/voice/online/getTransAudioLink

入参列表配置:

参数名称参数说明参数类型备注是否必填
appid应用的唯一识别标记String
token签名String见token生成规则
nonce_str随机字符串String
recordId音频文件翻译idInteger

出参列表配置:

参数名称参数说明参数类型备注
code状态码int详见状态码列表
msg返回状态说明String
data译文音频下载链接String

音频识别翻译

接入流程

注册翻译狗开放平台 登陆并添加开发者信息 创建应用 参考文档完成部署 测试完成

接口规则

为了带给客户简单、一致且易用的开发体验,我们规范了接口规则,你需要根据规范配置相关内容,请参考“接口规则”,如token的生成规则状态码列表等请查看该文档。

接口调用流程

1.上传音频文件(详见音频文件上传接口

2.查询音频翻译进度(详见音频翻译任务查询接口

3.下载译文文本(详见音频下载译文链接接口

接口说明

音频文件上传接口

接口名称:upload

接口完整路径:https://www.fanyigou.com/TranslateApi/api/voice/audio/upload

请求方式:post(file参数请以 multipart/form-data 方式的表单 POST 提交)

语音识别翻译支持音频格式:

1.pcm(pcm_s16le)、wav音频格式文件;

2.文件大小仅支持10min、10M以内文件;

3.采样率为16000,比特率为16bit;

4.单声道;

入参列表配置:

参数名称参数说明参数类型备注是否必填
appid应用的唯一识别标记String
token签名String见token生成规则
nonce_str随机字符串String
from源语言(目前支持中文或者英文)String见语言列表
to目标语言(目前支持英文或者中文)String见语言列表

出参列表配置:

参数名称参数说明参数类型备注
code状态码int详见状态码列表
msg返回状态说明String
data音频文件翻译idInteger通过该id可查询翻译进度等

音频翻译任务查询接口

接口名称:queryProgress

接口完整路径:https://www.fanyigou.com/TranslateApi/api/voice/audio/queryProgress

调用说明:请求方式:get,post

入参列表配置:

参数名称参数说明参数类型备注是否必填
appid应用的唯一识别标记String
token签名String见token生成规则
nonce_str随机字符串String
recordId音频文件翻译idInteger

出参列表配置:

参数名称参数说明参数类型备注
code状态码int详见状态码列表
msg返回状态说明String
data返回数据结果集Json字符串

data结果集:

参数名称参数说明参数类型备注
percent翻译进度String
status音频文件翻译Integer-1 上传失败 0 上传成功 6 正在翻译中 8 翻译成功 10 翻译失败

音频下载译文链接接口

接口名称:download

接口完整路径:https://www.fanyigou.com/TranslateApi/api/voice/audio/download

接口说明:请求方式:get,post

入参列表配置:

参数名称参数说明参数类型备注是否必填
appid应用的唯一识别标记String
token签名String见token生成规则
nonce_str随机字符串String
recordId音频文件翻译idInteger

出参列表配置:

参数名称参数说明参数类型备注
code状态码int详见状态码列表
msg返回状态说明String
data下载链接String

词典

接入流程

注册翻译狗开放平台 登陆并添加开发者信息 创建应用 参考文档完成部署 测试完成

接口规则

为了带给客户简单、一致且易用的开发体验,我们规范了接口规则,你需要根据规范配置相关内容,请参考“接口规则”,如token的生成规则状态码列表等请查看该文档。

接口说明

词典搜索接口

接口名称:dict/search

接口完整路径:https://www.fanyigou.com/TranslateApi/api/dict/search

入参列表配置:

参数名称参数说明参数类型备注是否必填
appid应用的唯一识别标记String
token签名String见token生成规则
nonce_str随机字符串String
word搜索词String词语,小于等于15个字符

出参列表配置:

参数名称参数说明参数类型备注
code状态码int详见状态码列表
msg返回状态说明String
data返回数据结果集StringJson字符串

data结果集:

返回结果:

{"msg":"请求成功","code":100,"data":{"dict":{"base":{"explain":{"word_means":[{"part":"n.","means":["入口,通道","(使用或见到的)机会/权利"]},{"part":"v.","means":["访问,存取(计算机信息)","到达,进入,使用"]}],"case_word":["ACCESS"]},"explain_zh":"","exchange":{"word_ing":["accessing"],"word_done":["accessed"],"word_past":["accessed"],"word_third":["accesses"],"word_pl":[]},"pron_zh":"","pron_am":{"text":"ˈækses","pronounce":""},"pron_en":{"text":"ˈækses","pronounce":""},"word":"access","pronounce":"https://qx-voice-dict.oss-cn-hangzhou.aliyuncs.com/word/en/access.wav?Expires=1693218092&OSSAccessKeyId=LTAI5tPjkAz1ACvr7rp9trNm&Signature=fTfIt675EJSNL%2Fva7GrY%2B5H014U%3D","chinese":false},"practical_sentences":[],"true_sentences":[{"tag":"四级","sentences":[]},{"tag":"六级","sentences":[]},{"tag":"高考","sentences":[{"text":"Depending on which role you choose, you could help to increase a community's access to safe drinking water, or help to protect valuable local cultures.","text_cn":"","source":"2019年高考英语北京卷 阅读理解 阅读A 原文"},{"text":"Designers have also created informal gathering places, and upgraded employees' access to heavily trafficked areas such as copy and coffee rooms.","text_cn":"","source":"2015年高考英语上海卷 选词填空 原文"},{"text":"Instead, computer users are developing stronger transactive memories; that is, people are learning how to organize huge quantities of information so that they are able to access it at a later date.","text_cn":"","source":"2015年高考英语安徽卷 阅读理解 阅读C 原文"},{"text":"It was really annoying; I couldn't get access to the data bank you had recommended.","text_cn":"","source":"2016年高考英语天津卷 单项填空 原文"},{"text":"One crucial factor is secure access to land.","text_cn":"","source":"2018年高考英语江苏卷 阅读理解 阅读C 原文"},{"text":"People have better access to health care than they used to, and they're living longer as a result.","text_cn":"","source":"2017年高考英语北京卷 单项填空 原文"},{"text":"Some also contain cd-roms and access to special online features.","text_cn":"","source":"2015年高考英语湖南卷 任务型读写 原文"},{"text":"Thus I have been allowed to gain access to their living environment.","text_cn":"","source":"2016年高考英语四川卷 阅读理解 阅读C 原文"},{"text":"Thus, the keyboard can determine people's identities, and by extension, whether they should be given access to the computer it's connected to—regardless of whether someone gets the password right.","text_cn":"","source":"2019年高考英语全国卷I 阅读理解 阅读C 原文"},{"text":"We need a better way to access information.","text_cn":"","source":"2015年高考英语安徽卷 阅读理解 阅读C 选项"}]},{"tag":"考研","sentences":[{"text":"Not only did they develop such a device but by the turn of the millennium they had also managed to embed it in a worldwide system accessed by billions of people every day.","text_cn":"","source":"出自-2012年考研阅读原文"},{"text":"When we don't understand the value of mental health and we don't know how to gain access to it, mental health will remain hidden from us.","text_cn":"","source":"出自-2016年考研翻译原文"},{"text":"The charter’s main tool of enforcement is to deny access for designers and modeling agencies to Copenhagen Fashion Week ( ' , CFW), which is run by the Danish Fashion Institute.","text_cn":"","source":"出自-2016年考研阅读原文"},{"text":"Rather officials must avoid double standards, or different types of access for average people and the wealthy.","text_cn":"","source":"出自-2017年考研阅读原文"},{"text":"Merely helping a gift-giver gain access to other officials, unless done with clear intent to pressure those officials, is not corruption, the justices found.","text_cn":"","source":"出自-2017年考研阅读原文"},{"text":"Favoritism in official access can fan public perceptions of corruption.","text_cn":"","source":"出自-2017年考研阅读原文"},{"text":"But the ruling reinforces the need for citizens and their elected representatives, not the courts, to ensure equality of access to government.","text_cn":"","source":"出自-2017年考研阅读原文"},{"text":"But it did so while holding its nose at the ethics of his conduct, which included accepting gifts such as a Rolex watch and a Ferrari automobile from a company seeking access to government.","text_cn":"","source":"出自-2017年考研阅读原文"},{"text":"But it did so while holding its nose at the ethics of his conduct, which included accepting gifts such as a Rolex watch and a Ferrari Automobile from a company seeking access to government.","text_cn":"","source":"2017年考研真题(英语一)阅读理解 Section Ⅱ"},{"text":"Critics make three main arguments against gene patents: a gene is a product of nature, so it may not be patented; gene patents suppress innovation rather than reward it; and patents'monopolies restrict access to genetic tests such as Myriad's.","text_cn":"","source":"2012年考研真题(英语二)阅读理解 Section Ⅱ"},{"text":"In Britain the move towards open access publishing has been driven by funding bodies.","text_cn":"","source":"2020年考研真题(英语一)阅读理解 Section Ⅱ"},{"text":"It can't when so many more employers have so much more access to so much more above average cheap foreign labor, cheap robotics, cheap software, cheap automation and cheap genius.","text_cn":"","source":"2013年考研真题(英语二)阅读理解 Section Ⅱ"},{"text":"Merely helping a gift-giver gain access to other officials, unless done with clear intent to pressure those officials, is not corruption, the Justices found.","text_cn":"","source":"2017年考研真题(英语一)阅读理解 Section Ⅱ"},{"text":"More than half of all British scientific research is now published under open access terms: either freely available from the moment of publication, or paywalled for a year or more so that the publishers can make a profit before being placed on general rel","text_cn":"","source":"2020年考研真题(英语一)阅读理解 Section Ⅱ"},{"text":"The charter's main tool of enforcement is to deny access for designers and modeling agencies to Copenhagen Fashion Week, which is run by the Danish Fashion Institute.","text_cn":"","source":"2016年考研真题(英语一)阅读理解 Section Ⅱ"},{"text":"The Dutch giant Elsevier, which claims to publish 25% of the scientific papers produced in the world, made profits of more than £900m last year, while UK universities alone spent more than £210m in 2016 to enable researchers to access their own publicly f","text_cn":"","source":"2020年考研真题(英语一)阅读理解 Section Ⅱ"},{"text":"The fact that this is not an uncommon occurrence means that dishonest persons might be able to access bank accounts in electronic payments systems and steal from someone else's accounts.","text_cn":"","source":"2013年考研真题(英语二)完形填空 Section Ⅰ"},{"text":"The most drastic, and thoroughly illegal, reaction has been the emergence of Sci-Hub, a kind of global photocopier for scientific papers, set up in 2012, which now claims to offer access to every paywalled article published since 2015.","text_cn":"","source":"2020年考研真题(英语一)阅读理解 Section Ⅱ"},{"text":"There are concerns that government, employers, and marketers might be able to access these data, thereby violating our privacy.","text_cn":"","source":"2013年考研真题(英语二)完形填空 Section Ⅰ"},{"text":"We often hear media reports that an unauthorized hacker has been able to access a computer database and to alter information stored there.","text_cn":"","source":"2013年考研真题(英语二)完形填空 Section Ⅰ"}]}],"ee_means":[],"roots_affixes":[],"phrases":[],"synonym":[{"part":"n.","word_means":[{"mean":"接近的机会","words":["of","way","entry","approach"]}]},{"part":"","word_means":[{"mean":"其他释义","words":["advent","retirement","admission","course","license","retreat","passport","accession","approach","door"]}]}],"antonym":[{"part":"n.","word_means":[{"mean":"接近;进入","words":["retirement","retreat"]}]}],"industry_dict":[],"synonym_explain":[],"collins":[{"entries":[{"define":"If you have access to a building or other place, you are able or allowed to go into it.","trans":"进入(权);通道;入径","part":"N-UNCOUNT","sentences":[{"origin":"The facilities have been adapted to give access to wheelchair users.","trans":"这些设施已经改造过以方便轮椅使用者进入。"},{"origin":"Scientists have only recently been able to gain access to the area...","trans":"科学家直到最近才得以进入该地区。"}]},{"define":"If you have access to something such as information or equipment, you have the opportunity or right to see it or use it.","trans":"查阅(或使用)的机会(或权利)","part":"N-UNCOUNT","sentences":[{"origin":"...a Code of Practice that would give patients right of access to their medical records.","trans":"允许病人查看自己病历的职业准则"},{"origin":"...whether one has access to a dish and the other accoutrements needed to watch satellite TV.","trans":"是否能使用碟型卫星天线以及其他观看卫星电视所需要的装备"}]},{"define":"If you have access to a person, you have the opportunity or right to see them or meet them.","trans":"接近(或面见)的机会(或权利)","part":"N-UNCOUNT","sentences":[{"origin":"He was not allowed access to a lawyer.","trans":"他未被获准见律师。"},{"origin":"My ex-wife deliberately sabotages my access to the children.","trans":"我的前妻蓄意阻挠我见孩子。"}]},{"define":"If you access something, especially information held on a computer, you succeed in finding or obtaining it.","trans":"存取,访问(计算机信息)","part":"VERB","sentences":[{"origin":"You've illegally accessed and misused confidential security files.","trans":"你已经非法访问并盗用了机密的安全文件。"}]}]}]}}}

回调通知

接口说明

目前文档翻译完成和格式转换完成支持回调(回调通知)

回调说明:翻译任务、转换任务,失败或成功时会发起回调

请求方式:post, application/json

目前回调地址需要后台设置,后续会开放设置

回调接口处理完成后须返回“success”字符串

回调参数列表:

参数名称参数说明参数类型备注
tid查询任务idint通过该id可查询任务进度等
title文件名String
docType文件类型String
fromLan源语言String
toLan目标语言String
detectLan检测语言String不为空即为自动检测出的主要语言,仅供参考
percent任务进度String
pageCount文件页数int
status任务状态int详见文件任务状态码
msg状态说明String
createTime创建时间String
updateTime更新时间String
type任务类型int1:文档翻译(默认),4:文档转换

回调JSON示例:

            {
                "createTime":"2021-08-25 14:27:47",
                "detectLan":"",
                "docType":"pdf",
                "fromLan":"中文",
                "msg":"完成",
                "pageCount":1,
                "percent":"100.00",
                "status":314,
                "tid":19432525,
                "title":"test",
                "toLan":"英语",
                "updateTime":"2021-08-25 14:27:47",
                "type":0
            }

账户相关

接口说明

获取账户信息接口

接口名称:getAccount

接口完整路径:https://www.fanyigou.com/TranslateApi/api/getAccount

接口说明:获取账户信息

入参列表配置:

参数名称参数说明参数类型备注是否必填
appid应用的唯一识别标记String
token签名String见token生成规则
nonce_str随机字符串String
type资源包类型 1.文档翻译 2.文字翻译 3.图片翻译 4.格式转换int 默认值1

出参列表:

参数名称参数说明参数类型备注
code状态码int详见状态码列表
msg返回状态说明String
data返回数据结果集StringJson字符串

data结果集:

参数名称参数说明参数类型备注
deductType0:按积分计费,1:按页计费int
balance余额int

返回结果:

{"code":100,"data":{"deductType":1,"balance":137684},"msg":"请求成功"}

安全规范

1、token的生成规则

签名生成的通用步骤如下:

第一步,设所有发送或者接收到的数据为集合M(包括平台生成的privatekey),将集合M内非空参数值的参数按照参数名ASCII码从小到大排序(字典序),使用URL键值对的格式(即key1=value1&key2=value2…)拼接成字符串stringA。

特别注意以下重要规则:

◆ 参数名ASCII码从小到大排序(字典序);
◆ 如果参数的值为空不参与签名;
◆ 参数名区分大小写;
◆ 验证调用返回或主动通知签名时,传送的token参数不参与签名,将生成的签名与该token值作校验。
◆ 接口可能增加字段,验证签名时必须支持增加的扩展字段

第二步,对stringA进行MD5运算,再将得到的字符串所有字符转换为大写,得到token值。
◆ privatekey获取:

举例:

假设传送的参数如下:

            appid:1522125815142
            nonce_str:ibuaiVcKdpRxkhJA
            from : en
            to : zh
            md5 : 5b21f2eeda4726c74274fc27a53bac74
    
            第一步:对参数按照key=value的格式(包括privatekey),并按照参数名ASCII字典序排序如下:
                                
            stringA="appid=1522125815142&from=en&md5=5b21f2eeda4726c74274fc27a53bac74&nonce_str=ibuaiVcKdpRxkhJA&privatekey=4892ef64ewf5sffdf&to=zh";
    
            第二步:加密:
    
            token=MD5(stringA).toUpperCase()="31956D481EFF09D7F3EB7C1312BC61E0" 
    
            最终得到最终发送的数据:
            appid:1522125815142
            nonce_str:ibuaiVcKdpRxkhJA
            from : en
            to : zh
            md5 : 5b21f2eeda4726c74274fc27a53bac74
            token : 31956D481EFF09D7F3EB7C1312BC61E0
                        

2、生成随机数算法

API接口协议中包含字段nonce_str,主要保证签名不可预测。我们推荐生成随机数算法如下:调用随机数函数生成,将得到的值转换为字符串。

协议规则

用户接入API时,调用API必须遵循以下规则:

提交方式统一采用POST方法提交,文件上传类接口使用multipart/form-data提交,
其它接口使用application/x-www-form-urlencoded提交,暂不支持使用json格式参数提交
字符编码统一采用UTF-8字符编码
签名算法MD5,后续会兼容SHA1、SHA256等。
签名要求请求需要校验签名,详细方法请参考安全规范-签名算法
判断逻辑先判断协议字段返回,再判断业务返回

语言列表

语言代码语言
"" 或 auto自动检测
zh中文
jp日语
th泰语
fra法语
en英语
spa西班牙语
kor韩语
tr土耳其语
vie越南语
ms马来语
de德语
ru俄语
ara阿拉伯语
est爱沙尼亚语
be白俄罗斯语
bul保加利亚语
hi印地语
is冰岛语
tl菲律宾语
fin芬兰语
nl荷兰语
ca加泰罗尼亚语
cs捷克语
hr克罗地亚语
lv拉脱维亚语
lt立陶宛语
rom罗马尼亚语
no挪威语
pt葡萄牙语
swe瑞典语
sr塞尔维亚语
eo世界语
sk斯洛伐克语
slo斯洛文尼亚语
sw斯瓦希里语
uk乌克兰语
iw希伯来语
el希腊语
hu匈牙利语
hy亚美尼亚语
it意大利语
id印尼语
sq阿尔巴尼亚语
am阿姆哈拉语
az阿塞拜疆语
eu巴斯克语
bn孟加拉语
bs波斯尼亚语
gl加利西亚语
ka格鲁吉亚语
gu古吉拉特语
ig伊博语
ga爱尔兰语
zu祖鲁语
kn卡纳达语
kk哈萨克语
ky吉尔吉斯语
lb卢森堡语
mk马其顿语
mt马耳他语
mi毛利语
mr马拉提语
ne尼泊尔语
pa旁遮普语
si僧加罗语
ta泰米尔语
te泰卢固语
ur乌尔都语
uz乌兹别克语
cy威尔士语
yo约鲁巴语
cht中文繁体

状态码列表

系统状态码:

状态码状态描述
100请求成功
101没有访问权限,请检查token是否正确
102业务停机
103账户不存在
104账户异常
105系统错误
106参数异常
107黑名单管控
108访问地址频率过高
109该应用不存在
110该应用尚未启用
111无该功能权限

文档状态码:

状态码状态描述
300参数为空
301文件为空
302文件类型不支持
303文件MD5不匹配
304可用积分不足
305文档已加密或被保护
306文档不能识别
307文档损坏
309文档无法成功读取或读取超时,请将文件转换成其他版本的word或pdf后再次尝试
310自动处理超时,等待人工处理
311文件大小超过限制(50M)
312该翻译不存在
313进行中
314翻译完成
315正在传递
316处理超时
317已取消
318该文件不存在
319已删除
320翻译通道已被占用(不能上传进行翻译,需等待正在翻译的文件翻译结束)
321没有读取到需要翻译的内容
322图片文件大小超过限制(20M)
323图片文件像素超过限制(1000万)
324图片文件解析失败
325正在人工处理
326重复翻译
327文档页数超限
328图片生成失败
329该文档状态异常
330检测页数完成
331CAT页数超限
332页数无法识别
333翻译引擎错误
334字符超限
335获取不到页数信息
353文本数量超过限制
354音频文件时长超过限制
355音频文件大小超过限制
356不支持翻译当前音频格式
357音频翻译试用次数已经用完了
600超出或低于允许字符数
601检测字符数失败
602提交失败
603检测失败
700未查询到匹配词库

行业列表

行业代码行业
1法律
2金融
3农林牧渔
4医药卫生
5建筑建材
6冶金矿产
7石油化工
8水利水电
9交通运输
10信息产业
11机械机电
12轻工食品
13服装纺织
14专业服务
15安全防护
16环保绿化
17旅游休闲
18办公文教
19电子电工
20玩具礼品
21家居用品
22物资
23包装
24体育
25办公
26其他

JAVA-SDK调用说明

环境说明

运行环境:JDK8

操作步骤

在项目的pom.xml的dependencies中加入以下内容:

    <dependency>

        <groupId>com.qingxun</groupId>

        <artifactId>java-sdk-api</artifactId>

        <version>0.0.5</version>

    <dependency>         
                                            
示例代码
package com.qingxun.javasdkapi.examples;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.qingxun.javasdkapi.clients.DocTransOpenApiClient;
import com.qingxun.javasdkapi.request.DownloadFileRequest;
import com.qingxun.javasdkapi.request.QueryTransProgressRequest;
import com.qingxun.javasdkapi.request.UploadTransRequest;
import com.qingxun.javasdkapi.response.DownloadFileResponse;
import com.qingxun.javasdkapi.response.QueryTransProgressResponse;
import com.qingxun.javasdkapi.response.UploadTransResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.File;
import java.io.FileNotFoundException;

/**
* 文档翻译
*/
public class DocTransOpenApiClientDemo extends CommonDemo {


private final static String uploadFilePath = "需要上传的文件路径";
private final static String appId = "您的appId";
private final static String privateKey = "您的privateKey";
private final static String fromLan = "文件的原语言";
private final static String toLan = "文件的目标语言";
private final static String saveTransDirPath = "保存翻译后的文件目录名称";
private final static String saveTransFileName = "保存翻译后的文件名称";
/**
    * 下载的文件类型(new):
    * 2:翻译后的pdf文件,支持格式:word、pdf、img。
    * 3:翻译后的word文件(支持格式:word、pdf);ppt文件(支持格式:img、ppt);excel文件(支持格式:excel)
    * 6:转换完成文档
    */
private final static Integer dType = 3;

private final static Logger log = LoggerFactory.getLogger(DocTransOpenApiClientDemo.class);

private static DocTransOpenApiClient docTransOpenApiClient = new DocTransOpenApiClient(appId, privateKey);


public static UploadTransResponse upload(String path) {
    File file = new File(path);
    UploadTransRequest uploadTransRequest = new UploadTransRequest.Builder()
            .setFrom(fromLan)
            .setTo(toLan).setFile(file)
            .builder();
    return docTransOpenApiClient.excute(uploadTransRequest);
}

public static QueryTransProgressResponse queryTransProgress(Integer docId) {
    QueryTransProgressRequest queryTransProgressRequest = new QueryTransProgressRequest.Builder().setTid(docId).builder();
    return docTransOpenApiClient.excute(queryTransProgressRequest);
}

public static DownloadFileResponse downloadFile(Integer docId, Integer dType) {
    DownloadFileRequest downloadFileRequest = new DownloadFileRequest.Builder().setTid(docId).setDtype(dType).builder();
    return docTransOpenApiClient.excute(downloadFileRequest);
}

public static void main(String[] args) throws FileNotFoundException, JsonProcessingException {
    ObjectMapper objectMapper = new ObjectMapper();
    QueryTransProgressResponse queryTransProgressResponse;
    UploadTransResponse uploadTransResponse = upload(uploadFilePath);
    log.info("文档翻译上传结果: {}",objectMapper.writeValueAsString(uploadTransResponse));
    if (uploadTransResponse != null && uploadTransResponse.getTid() > 0) {
        boolean flag = true;
        while (flag) {
            queryTransProgressResponse = queryTransProgress(uploadTransResponse.getTid());
            log.info("文档翻译查询进度: {}",objectMapper.writeValueAsString(queryTransProgressResponse));
            if (queryTransProgressResponse.getStatus().equals(314)) {
                //下载格式转换后的文件
                DownloadFileResponse response = downloadFile(queryTransProgressResponse.getTid(), dType);
                //保存格式转换后得到的文件
                bytesToFile(response.getBytes(), saveTransDirPath, saveTransFileName + response.getDocType());
                return;
            }
            if (queryTransProgressResponse.getStatus().equals(313)) {
                flag = true;
            } else {
                flag = false;
            }
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }

    }
}
}
                                    
文档翻译示例代码
package com.qingxun.javasdkapi.examples;


import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.qingxun.javasdkapi.clients.DocTransOpenApiClient;
import com.qingxun.javasdkapi.request.*;
import com.qingxun.javasdkapi.response.*;
import com.qingxun.javasdkapi.utils.HttpClientUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;

/**
* 文档翻译
*/
public class DocTransOpenApiClientDemo extends CommonDemo {


    private final static String uploadFilePath = "需要上传的文件路径";
    private final static String appId = "您的appId";
    private final static String privateKey = "您的privateKey";
    private final static String fromLan = "文件的原语言";
    private final static String toLan = "文件的目标语言";
    private final static String saveTransDirPath = "保存翻译后的文件目录名称";
    private final static String saveTransFileName = "保存翻译后的文件名称";
    //文件名称,传入文件流的时候必须传
    private final static String docName = "你的文件全名名称";

    /**
        * 下载的文件类型(new):
        * 2:翻译后的pdf文件,支持格式:word、pdf、img。
        * 3:翻译后的word文件(支持格式:word、pdf);ppt文件(支持格式:img、ppt);excel文件(支持格式:excel)
        * 6:转换完成文档
        */
    private final static Integer dType = 3;

    private final static Logger log = LoggerFactory.getLogger(DocTransOpenApiClientDemo.class);

    private static DocTransOpenApiClient docTransOpenApiClient = new DocTransOpenApiClient(appId, privateKey);

    //可以自定义请求接口的工具类使用更符合自己生产环境或者更高效的工具类,目前只支持传入文件流(FileStream)的方式而不是传入文件(file)的方式
    //private static DocTransOpenApiClient docTransOpenApiClient = new DocTransOpenApiClient(appId, privateKey,new HttpClientUtil());

    public static UploadTransResponse upload(String path) {
        UploadTransRequest uploadTransRequest = null;

            uploadTransRequest = new UploadTransRequest.Builder()
                    .setFrom(fromLan)
                    .setTo(toLan)
                    //传入文件或者文件流都可
                    .setFile(new File(path))
                    //.setFileStream(new FileInputStream(path)).setFileName(docName)
                    .builder();
        return docTransOpenApiClient.excute(uploadTransRequest);
    }

    public static QueryTransProgressResponse queryTransProgress(Integer docId) {
        QueryTransProgressRequest queryTransProgressRequest = new QueryTransProgressRequest.Builder().setTid(docId).builder();
        return docTransOpenApiClient.excute(queryTransProgressRequest);
    }

    public static DownloadFileResponse downloadFile(Integer docId, Integer dType) {
        DownloadFileRequest downloadFileRequest = new DownloadFileRequest.Builder().setTid(docId).setDtype(dType).builder();
        return docTransOpenApiClient.excute(downloadFileRequest);
    }

    public  static DetectDocPageResponse detected(String path) throws FileNotFoundException {
        DetectDocPageRequest detectDocPageRequest  = new DetectDocPageRequest.Builder()
                .setFileStream(new FileInputStream(path)).setFileName(docName)
                ////传入文件或者文件流都可
                //.setFile(new File(path))
                .builder();

        return docTransOpenApiClient.excute(detectDocPageRequest);
    }

    public static SubmitForDetectDocResponse submitForDetectDoc(Integer tid){
        SubmitForDetectDocRequest submitForDetectDocRequest = new SubmitForDetectDocRequest.Builder().setTid(tid)
                .setFrom(fromLan)
                .setTo(toLan).builder();
        return docTransOpenApiClient.excute(submitForDetectDocRequest);

    }

    public static void transForDeteDocPage() throws FileNotFoundException, JsonProcessingException {
        ObjectMapper objectMapper = new ObjectMapper();
        DetectDocPageResponse docPageResponse  = detected(uploadFilePath);
        QueryTransProgressResponse queryTransProgressResponse;
        log.info("文档上传上传结果: {}",objectMapper.writeValueAsString(docPageResponse));
        if (docPageResponse.getTid()!=null){
            SubmitForDetectDocResponse submitForDetectDocResponse = submitForDetectDoc(docPageResponse.getTid());
            log.info("文档翻译上传结果: {}",objectMapper.writeValueAsString(submitForDetectDocResponse));
            boolean flag = true;
            while (flag) {
                try {
                    queryTransProgressResponse = queryTransProgress(docPageResponse.getTid());
                    log.info("文档翻译查询进度: {}", objectMapper.writeValueAsString(queryTransProgressResponse));
                    if (queryTransProgressResponse.getStatus().equals(314)) {
                        //下载格式转换后的文件
                        DownloadFileResponse response = downloadFile(queryTransProgressResponse.getTid(), dType);
                        //保存格式转换后得到的文件
                        bytesToFile(response.getBytes(), saveTransDirPath, saveTransFileName + response.getDocType());
                        return;
                    }
                    if (queryTransProgressResponse.getStatus().equals(313)) {
                        flag = true;
                    } else {
                        flag = false;
                    }
                    try {
                        Thread.sleep(1000);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }catch (Exception e){
                    e.printStackTrace();
                }
            }
        }

    }


    public   static void trans()throws FileNotFoundException, JsonProcessingException {
        ObjectMapper objectMapper = new ObjectMapper();
        QueryTransProgressResponse queryTransProgressResponse;
        UploadTransResponse uploadTransResponse = upload(uploadFilePath);
        log.info("文档翻译上传结果: {}",objectMapper.writeValueAsString(uploadTransResponse));
        if (uploadTransResponse != null && uploadTransResponse.getTid() > 0) {
            boolean flag = true;
            while (flag) {
                try {
                    queryTransProgressResponse = queryTransProgress(uploadTransResponse.getTid());
                    log.info("文档翻译查询进度: {}", objectMapper.writeValueAsString(queryTransProgressResponse));
                    if (queryTransProgressResponse.getStatus().equals(314)) {
                        //下载格式转换后的文件
                        DownloadFileResponse response = downloadFile(queryTransProgressResponse.getTid(), dType);
                        //保存格式转换后得到的文件
                        bytesToFile(response.getBytes(), saveTransDirPath, saveTransFileName + response.getDocType());
                        return;
                    }
                    if (queryTransProgressResponse.getStatus().equals(313)) {
                        flag = true;
                    } else {
                        flag = false;
                    }
                    try {
                        Thread.sleep(1000);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }catch (Exception e){
                    e.printStackTrace();
                }
            }

        }
    }


    public static void main(String[] args) throws FileNotFoundException, JsonProcessingException {
        trans();
        //transForDeteDocPage();
    }
}                 
                                    
文字翻译示例代码
package com.qingxun.javasdkapi.examples;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.qingxun.javasdkapi.clients.TextTransOpenApiClient;
import com.qingxun.javasdkapi.request.TextTransRequest;
import com.qingxun.javasdkapi.response.TextTransResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * 文字翻译
 */

public class TextTransOpenApiClientDemo {


    private final static String appId = "您的appId";
    private final static String privateKey = "您的privateKey";
    private final static String fromLan = "文字的原语言";
    private final static String toLan = "文字的目标语言";
    private final static String content="需要翻译的文字内容";

    private static TextTransOpenApiClient textTransOpenApiClient = new TextTransOpenApiClient(
            appId,privateKey);

    private static  final Logger log = LoggerFactory.getLogger(TextTransOpenApiClientDemo.class);
    private static  final ObjectMapper objectMapper = new ObjectMapper();

    public static TextTransResponse transText(String content){
        TextTransRequest transRequest = new TextTransRequest.Builder().setText(content)
                .setFrom(fromLan).setTo(toLan).builder();
        return textTransOpenApiClient.excute(transRequest);
    }


    public static void main(String[] args) throws JsonProcessingException {
        //文字翻译
        TextTransResponse response =  transText(content);
        log.info("文本翻译结果{}",objectMapper.writeValueAsString(response));
    }

}
                                    
格式转换示例代码
package com.qingxun.javasdkapi.examples;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.qingxun.javasdkapi.clients.DocConvertOpenApiClient;
import com.qingxun.javasdkapi.request.ConvertRequest;
import com.qingxun.javasdkapi.request.DownloadFileRequest;
import com.qingxun.javasdkapi.request.QueryTransProgressRequest;
import com.qingxun.javasdkapi.response.ConvertResponse;
import com.qingxun.javasdkapi.response.DownloadFileResponse;
import com.qingxun.javasdkapi.response.QueryTransProgressResponse;
import com.qingxun.javasdkapi.utils.HttpClientUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;

/**
* 格式转换
*/
public class DocConvertOpenApiClientDemo extends CommonDemo {

    private final static String appId = "您的appId";
    private final static String privateKey = "您的privateKey";
    private final static String convertFilePath = "需要格式转换的文件";
    private final static String saveConvertedDirPath = "保存转换后的文件目录名称";
    private final static String saveConvertedFileName = "保存转换后的文件名称";
    //转换的目标格式 -1:word;-3:excel;-6:pptx,-8:pdf,-9:ofd。
    private final static Integer conversionformat = -8;
    //文件名称,传入文件流的时候必须传
    private final static String docName = "你的文件全名名称";
    /**
    * 下载的文件类型(new):
    * 2:翻译后的pdf文件,支持格式:word、pdf、img。
    * 3:翻译后的word文件(支持格式:word、pdf);ppt文件(支持格式:img、ppt);excel文件(支持格式:excel)
    * 6:转换完成文档
    */
    private final static Integer dType =6;
    //源文件的语言(扫描件需设置语言)
    private final static  String fromLan="zh";

    private final static Logger log = LoggerFactory.getLogger(DocConvertOpenApiClientDemo.class);

    private final static ObjectMapper objectMapper = new ObjectMapper();

    private static DocConvertOpenApiClient docConvertOpenApiClient = new DocConvertOpenApiClient(appId, privateKey);

    //可以自定义请求接口的工具类使用更符合自己生产环境或者更高效的工具类,目前只支持传入文件流(FileStream)的方式而不是传入文件(file)的方式
    //private static DocConvertOpenApiClient docConvertOpenApiClient = new DocConvertOpenApiClient(appId, privateKey,new HttpClientUtil());

    public static ConvertResponse convertFile(String filePath) {
        ConvertRequest convertRequest = null;
        try {
            convertRequest = new ConvertRequest.Builder()
                    .setFile(new File(filePath))
                    //传入文件/文件流都可
                    //.setFileStream(new FileInputStream(filePath)).setFileName(docName)
                    .setFrom(fromLan)
                    .setConversionFormat(conversionformat)
                    .builder();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return docConvertOpenApiClient.excute(convertRequest);
    }

    public static QueryTransProgressResponse queryTransProcess(Integer tid) {
        QueryTransProgressRequest queryTransProgressRequest = new QueryTransProgressRequest.Builder().setTid(tid).builder();
        return docConvertOpenApiClient.excute(queryTransProgressRequest);
    }

    public static DownloadFileResponse downloadFile(Integer tid, Integer dtype) {
        DownloadFileRequest downloadFileRequest = new DownloadFileRequest.Builder().setTid(tid).setDtype(dtype).builder();
        return docConvertOpenApiClient.excute(downloadFileRequest);

    }


    public static void main(String[] args) throws JsonProcessingException {
        ConvertResponse convertResponse = convertFile(convertFilePath);
        log.info("转换文件结果{}", objectMapper.writeValueAsString(convertResponse));
        QueryTransProgressResponse queryTransProgressResponse;
        boolean flag = true;
        while (flag) {
            //查询格式转换后的转换进度
            queryTransProgressResponse = queryTransProcess(convertResponse.getTid());
            log.info("查询转换文件进度结果{}", objectMapper.writeValueAsString(queryTransProgressResponse));
            if (queryTransProgressResponse == null) {
                return;
            }
            if (queryTransProgressResponse.getStatus().equals(314)) {
                //下载格式转换后的文件
                DownloadFileResponse response = downloadFile(convertResponse.getTid(), dType);
                //保存格式转换后得到的文件
                bytesToFile(response.getBytes(), saveConvertedDirPath, saveConvertedFileName + response.getDocType());
                return;
            }
            if (queryTransProgressResponse.getStatus().equals(313)) {
                flag = true;
            } else {
                flag = false;
            }
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }

    }
}                         
                                    
图片翻译示例代码
package com.qingxun.javasdkapi.examples;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.qingxun.javasdkapi.clients.ImageTransOpenApiClient;
import com.qingxun.javasdkapi.request.DownloadImageRequest;
import com.qingxun.javasdkapi.request.QueryTransImageProgressRequest;
import com.qingxun.javasdkapi.request.UploadTransImageRequest;
import com.qingxun.javasdkapi.response.DownloadImageResponse;
import com.qingxun.javasdkapi.response.QueryTransImageProgressResponse;
import com.qingxun.javasdkapi.response.UploadTransImageResponse;
import com.qingxun.javasdkapi.utils.HttpClientUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;

/**
* 图片翻译
*/
public class ImageTransOpenApiClientDemo extends CommonDemo {

    private final static String uploadFilePath = "需要翻译的图片路径";
    private final static String appId = "您的appId";
    private final static String privateKey = "您的privateKey";
    private final static String fromLan = "图片的原语言";
    private final static String toLan = "图片的目标语言";
    private final static String saveTransDirPath = "保存翻译后的文件目录名称";
    private final static String saveTransFileName = "保存翻译后的文件名称";
    // 文件名称,传入文件流的时候必须传
    private final static String docName = "你的文件全名名称";
    /**
    * 下载的文件类型(new):
    * 2:翻译后的pdf文件,支持格式:word、pdf、img。
    * 3:翻译后的word文件(支持格式:word、pdf);ppt文件(支持格式:img、ppt);excel文件(支持格式:excel)
    * 6:转换完成文档
    */
    private final static Integer dType = 3;
    //private final static String saveTransFileName = "保存翻译后的文件名称";


    private final static Logger log = LoggerFactory.getLogger(ImageTransOpenApiClientDemo.class);

    private static ImageTransOpenApiClient imageTransOpenApiClient = new ImageTransOpenApiClient(appId,privateKey);
    //也可以自定义请求接口的工具类使用更符合自己生产环境或者更高效的工具类,目前只支持传入文件流(FileStream)的方式而不是传入文件(file)的方式
    //private static ImageTransOpenApiClient imageTransOpenApiClient = new ImageTransOpenApiClient(appId,privateKey,new HttpClientUtil());

    public static DownloadImageResponse downloadFile(Integer tid) {
        DownloadImageRequest downloadFileRequest = new DownloadImageRequest.Builder()
                .setTid(tid).builder();

        return imageTransOpenApiClient.excute(downloadFileRequest);
    }

    public static  UploadTransImageResponse uploadImage(String filePath) throws FileNotFoundException {
        UploadTransImageRequest uploadTransImageRequest = new UploadTransImageRequest.Builder()
                //md5参数会自动计算
                //传入文件或者文件流都可
                //.setFileStream(new FileInputStream(filePath)).setFileName(docName)
                .setFile(new File(filePath))
                .setFrom(fromLan).setTo(toLan).builder();

        return imageTransOpenApiClient.excute(uploadTransImageRequest);
    }


    public static QueryTransImageProgressResponse queryTransImageProgress(Integer tid){
        QueryTransImageProgressRequest queryTransImageProgressRequest = new QueryTransImageProgressRequest.Builder().setTid(tid).builder();
        return imageTransOpenApiClient.excute(queryTransImageProgressRequest);
    }


    public static void main(String[] args) throws JsonProcessingException, FileNotFoundException {
        ObjectMapper objectMapper = new ObjectMapper();
        QueryTransImageProgressResponse queryTransProgressResponse;
        UploadTransImageResponse uploadTransResponse = uploadImage(uploadFilePath);
        log.info("图片翻译上传结果: {}",objectMapper.writeValueAsString(uploadTransResponse));
        if (uploadTransResponse != null && uploadTransResponse.getTid() > 0) {
            boolean flag = true;
            while (flag) {
                queryTransProgressResponse = queryTransImageProgress(uploadTransResponse.getTid());
                log.info("图片翻译查询进度: {}",objectMapper.writeValueAsString(queryTransProgressResponse));
                if (queryTransProgressResponse.getStatus().equals(0)) {
                    //下载图片翻译后的文件
                    DownloadImageResponse response = downloadFile(uploadTransResponse.getTid());
                    //保存图片翻译后得到的文件
                    bytesToFile(response.getBytes(), saveTransDirPath, saveTransFileName);
                    return;
                }
                if (queryTransProgressResponse.getStatus().equals(1)) {
                    flag = true;
                }
                if(queryTransProgressResponse.getStatus().equals(-1)) {
                    flag = false;
                }
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }

        }

    }
}               
                                    
OCR(图像识别)示例代码
package com.qingxun.javasdkapi.examples;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.qingxun.javasdkapi.clients.ImageOcrOpenApiClient;
import com.qingxun.javasdkapi.request.OcrUploadTransRequest;
import com.qingxun.javasdkapi.response.OcrImageUploadResponse;
import com.qingxun.javasdkapi.utils.HttpClientUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;

/**
* OCR(图像识别)
*/
public class ImageOcrOpenApiClientDemo {


    private final static String uploadFilePath = "需要翻译的图片路径";
    private final static String appId = "您的appId";
    private final static String privateKey = "您的privateKey";
    private final static String fromLan = "图片的原语言";
    //文件名称,传入文件流的时候必须传
    private final static String docName = "你的文件全名名称";

    private final static Logger log = LoggerFactory.getLogger(ImageOcrOpenApiClientDemo.class);

    private final static ObjectMapper objectMapper = new ObjectMapper();

    private static ImageOcrOpenApiClient imageTransOpenApiClient = new ImageOcrOpenApiClient(
            appId, privateKey);

    //可以自定义请求接口的工具类使用更符合自己生产环境或者更高效的工具类,目前只支持传入文件流(FileStream)的方式而不是传入文件(file)的方式
    //private static ImageOcrOpenApiClient imageTransOpenApiClient = new ImageOcrOpenApiClient(appId, privateKey,new HttpClientUtil());


    public static OcrImageUploadResponse upload(String filePath) throws FileNotFoundException {
        OcrUploadTransRequest ocrUploadTransRequest = null;
            ocrUploadTransRequest = new OcrUploadTransRequest.Builder()
                    //传入文件或者文件流都可
                    .setFile(new File(filePath))
                    //.setFileStream(new FileInputStream(filePath)).setFileName(docName)
                    .setFrom(fromLan).builder();

        return imageTransOpenApiClient.excute(ocrUploadTransRequest);
    }


    public static void main(String[] args) throws JsonProcessingException, FileNotFoundException {
        OcrImageUploadResponse ocrImageUploadResponse = upload(uploadFilePath);
        log.info(objectMapper.writeValueAsString(ocrImageUploadResponse));
    }

}                                  
                                    
语音识别翻译示例代码
package com.qingxun.javasdkapi.examples;

import cn.hutool.core.util.ArrayUtil;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.qingxun.javasdkapi.clients.OnlineVoiceTransOpenApiClient;
import com.qingxun.javasdkapi.clients.OnlineVoiceTransWebSocketClient;
import com.qingxun.javasdkapi.request.OnlineVoiceGetConnecionIdRequest;
import com.qingxun.javasdkapi.request.OnlineVoiceGetDownloadUrlRequest;
import com.qingxun.javasdkapi.response.OnlineMsg;
import com.qingxun.javasdkapi.response.OnlineVoiceGetConnectionIdResponse;
import com.qingxun.javasdkapi.response.OnlineVoiceGetDownloadUrlResponse;
import org.apache.commons.lang3.StringUtils;
import org.java_websocket.handshake.ServerHandshake;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.FileInputStream;
import java.io.IOException;
import java.net.URISyntaxException;

/**
 * 语音识别翻译
 */
public class OnlineVoiceTransOpenApiClientDemo {

    private final static String appId = "您的appId";
    private final static String privateKey = "您的privateKey";
    private final static String fromLan = "语音的原语言";
    private final static String toLan = "语音的目标语言";

    private final static OnlineVoiceTransOpenApiClient onlineVoiceTransOpenApiClient = new OnlineVoiceTransOpenApiClient(appId, privateKey);

    private final static Logger log = LoggerFactory.getLogger(OnlineVoiceTransOpenApiClientDemo.class);

    private final static ObjectMapper objectMapper = new ObjectMapper();

    public static OnlineVoiceGetConnectionIdResponse getConnectionId() {
        OnlineVoiceGetConnecionIdRequest onlineVoiceGetConnecionIdRequest = new OnlineVoiceGetConnecionIdRequest.Builder().setFrom(fromLan)
                .setTo(toLan).builder();
        return onlineVoiceTransOpenApiClient.excute(onlineVoiceGetConnecionIdRequest);
    }

    public static OnlineVoiceGetDownloadUrlResponse getDownloadUrl(Integer recordId) {
        OnlineVoiceGetDownloadUrlRequest onlineVoiceGetDownloadUrlRequest = new OnlineVoiceGetDownloadUrlRequest.Builder().setRecordId(recordId).builder();
        return onlineVoiceTransOpenApiClient.excute(onlineVoiceGetDownloadUrlRequest);
    }


    //自定义在线语音处理逻辑
    static class OnlineHandler extends OnlineVoiceTransWebSocketClient.AbstractOnlineVoiceHandler {

        private Integer recordId;

        private String websocketUrl;

        public OnlineHandler(Integer recordId,String websocketUrl) {
            this.recordId = recordId;
            this.websocketUrl = websocketUrl;
        }

        @Override
        public void handMessage(OnlineMsg onlineMsg) {
            try {
                log.info("接收到内容{}",objectMapper.writeValueAsString(onlineMsg));
            } catch (JsonProcessingException e) {
                e.printStackTrace();
            }
            if (onlineMsg == null) {
                return;
            }
            if (onlineMsg.getState().equals("transing")) {
                if (onlineMsg.getMsgType() != null && onlineMsg.getMsgType() == 0) {
                    log.info("语音识别 原文:{}", onlineMsg.getTransMsg());
                }
                if (onlineMsg.getMsgType() != null && onlineMsg.getMsgType() == 1) {
                    log.info("语音识别 译文:{}", onlineMsg.getTransMsg());
                }
            }
            if (onlineMsg.getState().equals("receiveend")) {
                log.info("由于余额不足或者长时间未发送语音数据导致服务器拒绝接受在线语音数据");
            }
            if (onlineMsg.getState().equals("sucess")) {
                log.info("在线语音全部转写翻译成功");
                //下载译文音频
                OnlineVoiceGetDownloadUrlResponse onlineVoiceGetDownloadUrlResponse = getDownloadUrl(recordId);
                try {
                    log.info("译文音频的下载链接{}", objectMapper.writeValueAsString(onlineVoiceGetDownloadUrlResponse));
                } catch (JsonProcessingException e) {
                    e.printStackTrace();
                }

            }

        }

        @Override
        public void handleOpen(ServerHandshake serverHandshake) {
            log.info("{}连接成功",websocketUrl);

        }

        @Override
        public void handleClose(int i, String s, boolean b) {
            log.info("连接关闭{} {} {}",i,s,b);
        }

        @Override
        public void handleError(Exception e) {
            e.printStackTrace();

        }
    }

    public static void main(String[] args) throws URISyntaxException, IOException, InterruptedException {

        OnlineVoiceGetConnectionIdResponse response = getConnectionId();
        log.info("获取connectionId结果{}",objectMapper.writeValueAsString(response));
        if (null == response || response.getRecordId() == null || StringUtils.isEmpty(response.getConnectionId())) {
            log.error("获取connectionId失败");
        }
        String url = onlineVoiceTransOpenApiClient.getConnectionWebSocketUrl(response.getConnectionId());
        log.info("连接地址{}",url);
        OnlineHandler onlineHandler = new OnlineHandler(response.getRecordId(),url);
        //在线语音websocket连接
        OnlineVoiceTransWebSocketClient onlineVoiceTransWebSocketClient = new OnlineVoiceTransWebSocketClient(url, onlineHandler);
        onlineVoiceTransWebSocketClient.connect();
        //模拟发送在线语音
        FileInputStream inputStream = new FileInputStream("/Users/cedric/Downloads/test.wav");
        int bufferSize = 2560;
        byte[] b = new byte[bufferSize];
        int len;
        int all = 0;
        while (!onlineVoiceTransWebSocketClient.isOpen()) {
            Thread.sleep(1000);
        }
        try {
            while ((len = inputStream.read(b)) > 0) {
                all += 1;
                log.info("发送了{}字节,共发送{}次,需要发送{}次", len, all, (inputStream.available() / 2560));
                //发送语音数据
                onlineVoiceTransWebSocketClient.send(ArrayUtil.sub(b, 0, len));
            }
        } finally {
            if (inputStream != null) {
                inputStream.close();
            }
        }
        onlineVoiceTransWebSocketClient.send("{\"state\":\"recordend\",\"transMsg\":null,\"msgType\":null}");

        Thread.sleep(600000L);

    }


}
                                    
音频识别翻译示例代码
package com.qingxun.javasdkapi.examples;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.qingxun.javasdkapi.clients.AudioTransOpenApiClient;
import com.qingxun.javasdkapi.request.AudioGetDownloadUrlRequest;
import com.qingxun.javasdkapi.request.AudioQueryProgressRequest;
import com.qingxun.javasdkapi.request.AudioUploadTransRequest;
import com.qingxun.javasdkapi.response.AudioGetDownloadUrlResponse;
import com.qingxun.javasdkapi.response.AudioQueryProcessResponse;
import com.qingxun.javasdkapi.response.AudioUploadTransResponse;
import com.qingxun.javasdkapi.utils.HttpClientUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;

/**
* 音频识别翻译
*/
public class AudioTransOpenApiClientDemo {


    private final static String uploadFilePath = "需要上传的音频文件路径";
    private final static String appId = "您的appId";
    private final static String privateKey = "您的privateKey";
    private final static String fromLan = "音频文件的原语言";
    private final static String toLan = "音频文件的目标语言";
    //文件名称,传入文件流的时候必须传
    private final static String docName = "你的文件全名名称";

    private final static Logger log = LoggerFactory.getLogger(DocConvertOpenApiClientDemo.class);
    private final static ObjectMapper objectMapper = new ObjectMapper();


    private static AudioTransOpenApiClient audioTransOpenApiClient = new AudioTransOpenApiClient(appId, privateKey);

    //可以自定义请求接口的工具类使用更符合自己生产环境或者更高效的工具类,目前只支持传入文件流的方式而不是传入文件的方式
    //private static AudioTransOpenApiClient audioTransOpenApiClient = new AudioTransOpenApiClient(appId, privateKey,new HttpClientUtil());


    public static AudioUploadTransResponse uploadAudio(String filePath) throws FileNotFoundException {
        AudioUploadTransRequest audioUploadTransRequest = null;
        audioUploadTransRequest = new AudioUploadTransRequest.Builder()
                .setFrom(fromLan).setTo(toLan)
                //传入文件或者文件流都可
                //.setFile(new File(filePath))
                .setFileStream(new FileInputStream(filePath)).setFileName(docName)
                .builder();
        return audioTransOpenApiClient.excute(audioUploadTransRequest);
    }


    public static AudioQueryProcessResponse getTransProgress(Integer recordId) {
        AudioQueryProgressRequest audioUploadTransRequest = new AudioQueryProgressRequest.Builder().setRecordId(recordId).builder();
        return audioTransOpenApiClient.excute(audioUploadTransRequest);
    }


    public static AudioGetDownloadUrlResponse getDownloadUrl(Integer recordId) {
        AudioGetDownloadUrlRequest audioGetDownloadUrlRequest = new AudioGetDownloadUrlRequest.Builder().setRecordId(recordId).builder();
        return audioTransOpenApiClient.excute(audioGetDownloadUrlRequest);
    }


    public static void main(String[] args) throws JsonProcessingException, FileNotFoundException {
        //音频文件上传
        AudioUploadTransResponse audioUploadTransResponse = uploadAudio(uploadFilePath);
        if (audioUploadTransResponse != null && audioUploadTransResponse.getRecordId() > 0) {
            AudioQueryProcessResponse audioQueryProcessResponse = null;
            while (true) {
                //每三秒查询进度
                audioQueryProcessResponse = getTransProgress(audioUploadTransResponse.getRecordId());
                if (null == audioQueryProcessResponse) {
                    return;
                }
                log.info("查询进度结果{}", objectMapper.writeValueAsString(audioQueryProcessResponse));
                if (audioQueryProcessResponse.getStatus().equals("8")) {
                    AudioGetDownloadUrlResponse audioGetDownloadUrlResponse = getDownloadUrl(audioUploadTransResponse.getRecordId());
                    log.info("获取下载链接{}", objectMapper.writeValueAsString(audioGetDownloadUrlResponse));
                }
                try {
                    Thread.sleep(3000L);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        }
    }

}                         
                                    
词典示例代码
package com.qingxun.javasdkapi.examples;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.qingxun.javasdkapi.clients.DictSearchOpenApiClient;
import com.qingxun.javasdkapi.request.DictSearchRequest;
import com.qingxun.javasdkapi.response.DictSearchResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;


/**
 * 词典
 */
public class DictSearchOpenApiClientDemo {


    private final static String appId = "您的appId";
    private final static String privateKey = "您的privateKey";
    private final static String content = "需要搜索的文字内容";


    private static DictSearchOpenApiClient dictSearchOpenApiClient = new DictSearchOpenApiClient(
            appId, privateKey);

    private static final Logger log = LoggerFactory.getLogger(DictSearchOpenApiClientDemo.class);
    private static final ObjectMapper objectMapper = new ObjectMapper();

    public static DictSearchResponse dictSearch(String word) {
        DictSearchRequest dictRequest = new DictSearchRequest.Builder().setWord(word).builder();
        return dictSearchOpenApiClient.excute(dictRequest);
    }


    public static void main(String[] args) throws JsonProcessingException {
        //词典-词库搜索
        DictSearchResponse response = dictSearch(content);
        log.info("词库搜索结果{}", objectMapper.writeValueAsString(response));
    }

}
                                    
获取账户信息示例代码
package com.qingxun.javasdkapi.examples;


import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.qingxun.javasdkapi.clients.AccountsOpenApiClient;
import com.qingxun.javasdkapi.request.GetAccountRequest;
import com.qingxun.javasdkapi.response.GetAccountResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * 账户相关
 */
public class AccountsOpenApiClientDemo {

    private final static String appId = "您的appId";

    private final static String privateKey = "您的privateKey";

    /**
     * 资源包类型 1.文档翻译 2.文字翻译 3.图片翻译 4.格式转换
     */
    private final static Integer type=2;

    private final static Logger log = LoggerFactory.getLogger(DocConvertOpenApiClientDemo.class);

    private final static ObjectMapper objectMapper = new ObjectMapper();

    private static AccountsOpenApiClient accountsOpenApiClient = new AccountsOpenApiClient(appId, privateKey);

    public static GetAccountResponse getAccount(Integer type) {
        GetAccountRequest getAccountRequest = new GetAccountRequest.Builder()
                .setType(type)
                .builder();

        return accountsOpenApiClient.excute(getAccountRequest);
    }

    public static void main(String[] args) throws JsonProcessingException {
        //获取账户信息接口
        GetAccountResponse getAccountResponse = getAccount(type);
        log.info("获取账号信息{}",objectMapper.writeValueAsString(getAccountResponse));


    }
}
                                    

PHP-SDK调用说明

环境说明

PHP 7.1+

cURL extension

操作步骤

使用Composer来管理项目依赖项,请在项目的根目录中运行以下命令:

composer require fanyigou/api-sdk-php

在Composer依赖管理器安装完成后,在您的PHP代码中导入该依赖项:

require_once __DIR__ . '/vendor/autoload.php'
示例代码
文件上传
    <?php
    include_once __DIR__.'/vendor/autoload.php';
    
    use Fanyigou\ApiSdkPhp\Dispatch;
    use Fanyigou\ApiSdkPhp\DispatchException;
    
    $appKey = '您的应用ID';
    $secKey = '您的密钥';
    
    $dispatch = new Dispatch(['app_key' => $appKey, 'sec_key' => $secKey]);
    
    $filePath = '文档路径'; //文档路径
    
    $params = [
    'from' => 'en',
    'to' => 'zh',
    ];
    
    try {
        $result = $dispatch->uploadTranslate($params, $filePath);
        print_r($result);
    } catch (DispatchException $e) {
        print_r($e->getMessage());
    }
                                        
文档翻译示例代码
  • 1. 上传示例代码
  • 2. 上传文件检测页数示例代码
  • 3. 检测页数文件提交翻译示例代码
  • 4. 获取进度示例代码
  • 5. 下载示例代码
上传示例代码
<?php
/**
 * 上传 
1.上传格式:pdf、Microsoft Office(doc、docx、dot、dotx、dotm、docm、xml、odt)、WPSOffice(wps、wpt)、xls、xlsx、et、ett、ppt、pptx、dps、dpt、txt、rtf;

2.上传文件最大50M(如有更高需求请联系销售);

3. 不支持图纸、纯图片文档,加密文件请先去除密码;

4.翻译完成后按页从主账号里扣费;

5.目前普通账户支持一条翻译通道(即只能同时进行一个文件的上传翻译),(如有更高需求请联系销售);
 * uploadTranslate.php
 * Create on 2023/3/24 17:51
 * Create by lihailiang@fanyigou.com
 */
include_once __DIR__.'/../vendor/autoload.php';

use Fanyigou\ApiSdkPhp\Dispatch;
use Fanyigou\ApiSdkPhp\DispatchException;

$appKey = '您的应用ID';
$secKey = '您的密钥';

$dispatch = new Dispatch(['app_key' => $appKey, 'sec_key' => $secKey]);

$filePath = __DIR__.'/file/1746-5354-8-1-53.pdf'; //文档路径

$params = [
    'from' => '文件的源语言',
    'to' => '文件的目标语言',
];

try {
    $result = $dispatch->uploadTranslate($params, $filePath);
    print_r($result);
} catch (DispatchException $e) {
    print_r($e->getMessage());
}

                                    
上传文件检测页数示例代码
<?php
/**
 * 上传文件检测页数
1.上传格式:pdf、Microsoft Office(doc、docx、dot、dotx、dotm、docm、xml、odt)、WPS Office(wps、wpt)、xls、xlsx、et、ett、ppt、pptx、dps、dpt、txt、rtf

2.上传文件最大50M(如有更高需求请联系销售)

3.不支持图纸、纯图片文档,加密文件请先去除密码

4.该功能需联系客服开通

调用说明:请求方式:post, file参数请以 multipart/form-data 方式的表单 POST 提交
 * detectDocPage.php
 * Create on 2023/3/24 17:51
 * Create by lihailiang@fanyigou.com
 */
include_once __DIR__.'/../vendor/autoload.php';

use Fanyigou\ApiSdkPhp\Dispatch;
use Fanyigou\ApiSdkPhp\DispatchException;

$appKey = '您的应用ID';
$secKey = '您的密钥';

$dispatch = new Dispatch(['app_key' => $appKey, 'sec_key' => $secKey]);

$filePath = __DIR__.'/file/1746-5354-8-1-53.pdf'; //文档路径

$params = [
    'excelMode' => 0, // 0:只翻译当前打开sheet(默认),1:翻译全部sheet(页数按全部sheet字符数来计算)
];

try {
    $result = $dispatch->detectDocPage($filePath);
    print_r($result);
} catch (DispatchException $e) {
    print_r($e->getMessage());
}


                                    
检测页数文件提交翻译示例代码
<?php
/**
* 检测页数文件提交翻译
* 同一个tid提交一次翻译即可。
* submitForDetectDoc.php
* Create on 2023/3/24 17:51
* Create by lihailiang@fanyigou.com
*/
include_once __DIR__.'/../vendor/autoload.php';

use Fanyigou\ApiSdkPhp\Dispatch;
use Fanyigou\ApiSdkPhp\DispatchException;

$appKey = '您的应用ID';
$secKey = '您的密钥';

$dispatch = new Dispatch(['app_key' => $appKey, 'sec_key' => $secKey]);

$params = [
    'from' => '文件的源语言',
    'to' => '文件的目标语言',
    'tid' => '检测文档页数接口返回的tid', // 检测文档页数接口返回的tid
    'industryId' => '行业代码',
    'transImg' => '文档内图片翻译', // 0:不翻译文档内图片(默认),1:翻译文档内图片。目前支持中、英、日、韩的文档内图片翻译。(如有需要请联系销售开通)
    'bilingualControl' => '指定翻译模式' // 0:译文单独为一个文档(默认),1:双语对照(原文和译文在一个文档)
];

try {
    $result = $dispatch->submitForDetectDoc($params);
    print_r($result);
} catch (DispatchException $e) {
    print_r($e->getMessage());
}                                        


                                    
获取进度示例代码
<?php
/**
 * 获取进度
 * 提交任务完成后可调用此接口实时查询翻译、转换进度或检测页数进度
 * queryTransProgress.php
 * Create on 2023/3/24 17:51
 * Create by lihailiang@fanyigou.com
 */
include_once __DIR__.'/../vendor/autoload.php';

use Fanyigou\ApiSdkPhp\Dispatch;
use Fanyigou\ApiSdkPhp\DispatchException;

$appKey = '您的应用ID';
$secKey = '您的密钥';

$dispatch = new Dispatch(['app_key' => $appKey, 'sec_key' => $secKey]);

$params = [
    'tid' => '查询状态结果Id', // 查询状态结果Id
];

try {
    $result = $dispatch->queryTransProgress($params);
    print_r($result);
} catch (DispatchException $e) {
    print_r($e->getMessage());
}
                                    
下载示例代码
<?php
/**
 * 下载
1.判断Response Headers 中 detectLanguage 的值,若存在且不为空即为自动检测出的语言(可能为多种语言),仅供参考
2.判断Response Headers 中Content-Type 的值,若包含"application/octet-stream" 则可直接进行下载,否则即为以下返回值
 * downloadFile.php
 * Create on 2023/3/24 17:51
 * Create by lihailiang@fanyigou.com
 */
include_once __DIR__.'/../vendor/autoload.php';

use Fanyigou\ApiSdkPhp\Dispatch;
use Fanyigou\ApiSdkPhp\DispatchException;

$appKey = '您的应用ID';
$secKey = '您的密钥';

$dispatch = new Dispatch(['app_key' => $appKey, 'sec_key' => $secKey]);

$params = [
    'tid' => '查询状态结果Id', // 查询状态结果Id
    'dtype' => '下载的文件类型',
//     下载的文件类型(new):
//      2:翻译后的pdf文件,支持格式:word、pdf、img。
//      3:翻译后的word文件(支持格式:word、pdf);ppt文件(支持格式:img、ppt);excel文件(支持格式:excel)
//      6:转换完成文档
];

try {
    $result = $dispatch->downloadFile($params);
    print_r($result);
} catch (DispatchException $e) {
    print_r($e->getMessage());
}



                                    
文字翻译示例代码
<?php
/**
    * 文字翻译
1.待翻译文本字符长度不能超过2000;
2.语言方向:英、日、俄、韩、德、法、意 到中;中、日、俄、韩、德、法、意 到英
    * text.php
    * Create on 2023/3/24 17:51
    * Create by lihailiang@fanyigou.com
    */
include_once __DIR__.'/../vendor/autoload.php';

use Fanyigou\ApiSdkPhp\Dispatch;
use Fanyigou\ApiSdkPhp\DispatchException;

$appKey = '您的应用ID';
$secKey = '您的密钥';

$dispatch = new Dispatch(['app_key' => $appKey, 'sec_key' => $secKey]);

$params   = [
    'from' => '文件的源语言',
    'to' => '文件的目标语言',
    'text' => '待翻译文本,需UTF-8编码'
];

try {
    $result = $dispatch->text($params);
    print_r($result);
} catch (DispatchException $e) {
    print_r($e->getMessage());
}
                                        
                                    
格式转换示例代码
  • 1. 文档转换示例代码
  • 2. 获取进度示例代码
  • 3. 下载示例代码
文档转换示例代码
<?php
/**
 * 文档转换
接口说明:用户调用接口进行 源文件上传,上传完成后会自动进行转换,通过tid可以查询转换的进度等数据。注意:

1.上传格式:pdf、doc、docx、ppt、pptx、xls、xlsx、hwp、caj、ofd

2.上传文件最大50M (如有更高需求请联系销售)

3.加密文件请先去除密码

4.转换完成后按页从主账号里扣费

调用说明:请求方式:post, file参数请以 multipart/form-data 方式的表单 POST 提交
 * convert.php
 * Create on 2023/3/24 17:51
 * Create by lihailiang@fanyigou.com
 */
include_once __DIR__.'/../vendor/autoload.php';

use Fanyigou\ApiSdkPhp\Dispatch;
use Fanyigou\ApiSdkPhp\DispatchException;

$appKey = '您的应用ID';
$secKey = '您的密钥';

$dispatch = new Dispatch(['app_key' => $appKey, 'sec_key' => $secKey]);

$filePath = __DIR__.'/file/1746-5354-8-1-53.pdf'; //文档路径

$params = array(
    'from' => '扫描件需设置语言', // 扫描件需设置语言
    'conversionFormat' => -1 // 文档转换类型
//    转换的目标格式(目前支持pdf到其它格式的转换(excel,ppt,word,ofd),及其它格式(excel,ppt,word,hwp,caj,ofd)到pdf的转换) -1:word;-3:excel;-6:pptx,-8:pdf,-9:ofd。
);

try {
    $result = $dispatch->convert($params, $filePath);
    print_r($result);
} catch (DispatchException $e) {
    print_r($e->getMessage());
}
                                    
获取进度示例代码
<?php
/**
 * 获取进度
 * 提交任务完成后可调用此接口实时查询翻译、转换进度或检测页数进度
 * queryTransProgress.php
 */
include_once __DIR__.'/../vendor/autoload.php';

use Fanyigou\ApiSdkPhp\Dispatch;
use Fanyigou\ApiSdkPhp\DispatchException;

$appKey = '您的应用ID';
$secKey = '您的密钥';

$dispatch = new Dispatch(['app_key' => $appKey, 'sec_key' => $secKey]);

$params = [
    'tid' => '查询状态结果Id', // 查询状态结果Id
];

try {
    $result = $dispatch->queryTransProgress($params);
    print_r($result);
} catch (DispatchException $e) {
    print_r($e->getMessage());
}
                                    
下载示例代码
<?php
/**
 * 下载
1.判断Response Headers 中 detectLanguage 的值,若存在且不为空即为自动检测出的语言(可能为多种语言),仅供参考
2.判断Response Headers 中Content-Type 的值,若包含"application/octet-stream" 则可直接进行下载,否则即为以下返回值
 * downloadFile.php
 * Create on 2023/3/24 17:51
 * Create by lihailiang@fanyigou.com
 */
include_once __DIR__.'/../vendor/autoload.php';

use Fanyigou\ApiSdkPhp\Dispatch;
use Fanyigou\ApiSdkPhp\DispatchException;

$appKey = '您的应用ID';
$secKey = '您的密钥';

$dispatch = new Dispatch(['app_key' => $appKey, 'sec_key' => $secKey]);

$params = [
    'tid' => '查询状态结果Id', // 查询状态结果Id
    'dtype' => '下载的文件类型',
//     下载的文件类型(new):
//      2:翻译后的pdf文件,支持格式:word、pdf、img。
//      3:翻译后的word文件(支持格式:word、pdf);ppt文件(支持格式:img、ppt);excel文件(支持格式:excel)
//      6:转换完成文档
];

try {
    $result = $dispatch->downloadFile($params);
    print_r($result);
} catch (DispatchException $e) {
    print_r($e->getMessage());
}
                                    
图片翻译示例代码
  • 1. 上传示例代码
  • 2. 获取进度示例代码
  • 3. 下载示例代码
图片上传示例代码
<?php
/**
 * 图片上传
接口说明:用户调用接口进行 源文件上传,上传完成后会自动进行翻译,通过tid可以查询翻译的进度等数据。注意:
1.上传格式:jpg、jpeg、png、bmp
2.上传文件最大4M
3.支持15*15 - 2048*2048px尺寸内
4.翻译完成后按页从主账号里扣费
调用说明:请求方式:post, file参数请以 multipart/form-data 方式的表单 POST 提交
 * uploadTranslateImage.php
 * Create on 2023/3/24 17:51
 * Create by lihailiang@fanyigou.com
 */
include_once __DIR__.'/../vendor/autoload.php';

use Fanyigou\ApiSdkPhp\Dispatch;
use Fanyigou\ApiSdkPhp\DispatchException;

$appKey = '您的应用ID';
$secKey = '您的密钥';

$dispatch = new Dispatch(['app_key' => $appKey, 'sec_key' => $secKey]);

$filePath = __DIR__.'/file/WechatIMG263.png'; //文档路径

$params = [
    'from' => '文件的源语言',
    'to' => '文件的目标语言',
];

try {
    $result = $dispatch->uploadTranslateImage($params, $filePath);
    print_r($result);
} catch (DispatchException $e) {
    print_r($e->getMessage());
}
                                    
图片翻译获取进度示例代码
<?php
/**
 * 图片翻译获取进度
 * queryImageTransProgress.php
 * Create on 2023/3/24 17:51
 * Create by lihailiang@fanyigou.com
 */
include_once __DIR__.'/../vendor/autoload.php';

use Fanyigou\ApiSdkPhp\Dispatch;
use Fanyigou\ApiSdkPhp\DispatchException;

$appKey = '您的应用ID';
$secKey = '您的密钥';

$dispatch = new Dispatch(['app_key' => $appKey, 'sec_key' => $secKey]);

$params = [
    'tid' => '查询状态结果Id', // 查询状态结果Id
];

try {
    $result = $dispatch->queryImageTransProgress($params);
    print_r($result);
} catch (DispatchException $e) {
    print_r($e->getMessage());
}

                                    
图片翻译下载示例代码
<?php
/**
 * 图片翻译下载
 * 1.判断Response Headers 中Content-Type 的值,若包含"application/octet-stream" 则可直接进行下载,否则即为以下返回值
 * downloadImage.php
 * Create on 2023/3/24 17:51
 * Create by lihailiang@fanyigou.com
 */
include_once __DIR__.'/../vendor/autoload.php';

use Fanyigou\ApiSdkPhp\Dispatch;
use Fanyigou\ApiSdkPhp\DispatchException;

$appKey = '您的应用ID';
$secKey = '您的密钥';

$dispatch = new Dispatch(['app_key' => $appKey, 'sec_key' => $secKey]);

$params = [
    'tid' => '查询状态结果Id', // 查询状态结果Id
];

try {
    $result = $dispatch->downloadImage($params);
    print_r($result);
} catch (DispatchException $e) {
    print_r($e->getMessage());
}
                                    
OCR(图像识别)示例代码
<?php
/**
 * OCR(图像识别)
接口说明:用户调用接口进行 源文件上传,上传完成后会自动进行识别并返回数据。注意:
1.上传格式:jpg、jpeg、png、bmp
2.上传文件最大4M
3.支持15*15 - 8192*8192px尺寸内
4.翻译完成后按次数从主账号里扣费
 * ocrUploadImage.php
 * Create on 2023/3/24 17:51
 * Create by lihailiang@fanyigou.com
 */
include_once __DIR__.'/../vendor/autoload.php';

use Fanyigou\ApiSdkPhp\Dispatch;
use Fanyigou\ApiSdkPhp\DispatchException;

$appKey = '您的应用ID';
$secKey = '您的密钥';

$dispatch = new Dispatch(['app_key' => $appKey, 'sec_key' => $secKey]);

$filePath = __DIR__.'/file/WechatIMG263.png'; //文档路径

$params = [
    'from' => '文件的源语言',
];

try {
    $result = $dispatch->ocrUploadImage($params, $filePath);
    print_r($result);
} catch (DispatchException $e) {
    print_r($e->getMessage());
}
                                    
语音识别示例代码
  • 1. 语音识别获取链接标识接口示例代码
  • 2. 连接webscoket进行语音识别翻译示例代码
  • 3. 获取译文音频链接接口示例代码
语音识别获取链接标识接口示例代码
<?php
/**
 * 语音识别获取链接标识接口
 * getConnectionId.php
 * Create on 2023/3/24 17:51
 * Create by lihailiang@fanyigou.com
 */
include_once __DIR__.'/../vendor/autoload.php';

use Fanyigou\ApiSdkPhp\Dispatch;
use Fanyigou\ApiSdkPhp\DispatchException;

$appKey = '您的应用ID';
$secKey = '您的密钥';

$dispatch = new Dispatch(['app_key' => $appKey, 'sec_key' => $secKey]);

$params   = [
    'from' => '源语言(目前支持中文或者英文)',
    'to'   => '目标语言(目前支持英文或者中文)',
];

try {
    $result = $dispatch->getConnectionId($params);
    print_r($result);
} catch (DispatchException $e) {
    print_r($e->getMessage());
}
                                    
连接webscoket进行语音识别翻译示例代码
<?php
/**
 * 连接webscoket进行语音识别翻译
1.语音识别获取链接标识接口与当前的websocket传入的appid必须一致
2.connectionId的只有二十分钟有效期
3.connenctionId连接成功并发送音频数据后不能再使用当前connectionId进行二次连接
 * getTransAudioLink.php
 * Create on 2023/3/24 17:51
 * Create by lihailiang@fanyigou.com
 */
include_once __DIR__.'/../vendor/autoload.php';

use Fanyigou\ApiSdkPhp\WebSocket;

$appKey = '您的应用ID';
$secKey = '您的密钥';

$connectionId = ''; // {connectionId}: 获取connectionId进行websocket连接,通过语音识别获取链接标识接口获取
$filePath = '音频路径';

// 初始化websocket连接
$socket = new WebSocket($appKey, $secKey);
$client = $socket->connection($connectionId);

// 模拟发送流式数据
send_data($client, $filePath, 6400);

function send_data($client, $path, $step)
{
    if (!file_exists($path)) {
        echo "file not exist";
        return;
    }
    $file = fopen($path, "r");
    // 发送消息的时间
    $pre_timestamp = return_mills_timestamp();
    while (!feof($file)) {
        $cur_timestamp = return_mills_timestamp();
        // 流式数据传输间隔推荐每6400bytes间隔200ms
        if ($cur_timestamp - $pre_timestamp < 200) {
            continue;
        }
        $pre_timestamp = $cur_timestamp;
        $buffer = fread($file, $step);
        send_binary_message($client, $buffer);
    }
    send_binary_message($client, "{\"end\": \"true\"}");
}

// 获取毫秒级时间戳
function return_mills_timestamp(): float
{
    $micrometer = microtime(true);
    return round($micrometer * 1000);
}


function send_binary_message($client, $message)
{
    $binary = pack("H*", bin2hex($message));
    $client->binary($binary);
    echo 'send binary message length: ' . strlen($binary) . "\n";
}
                                    
获取译文音频链接接口示例代码
<?php
/**
 * 获取译文音频链接接口
 * getTransAudioLink.php
 * Create on 2023/3/24 17:51
 * Create by lihailiang@fanyigou.com
 */
include_once __DIR__.'/../vendor/autoload.php';

use Fanyigou\ApiSdkPhp\Dispatch;
use Fanyigou\ApiSdkPhp\DispatchException;

$appKey = '您的应用ID';
$secKey = '您的密钥';

$dispatch = new Dispatch(['app_key' => $appKey, 'sec_key' => $secKey]);

$params   = [
    'recordId' => '音频文件翻译id',
];

try {
    $result = $dispatch->getTransAudioLink($params);
    print_r($result);
} catch (DispatchException $e) {
    print_r($e->getMessage());
}


                                    
音频识别示例代码
  • 1. 音频文件上传接口示例代码
  • 2. 音频翻译任务查询接口示例代码
  • 3. 音频下载译文链接接口示例代码
音频文件上传接口示例代码
<?php
/**
 * 音频文件上传接口
请求方式:post(file参数请以 multipart/form-data 方式的表单 POST 提交)
语音识别翻译支持音频格式:
1.pcm(pcm_s16le)、wav音频格式文件;
2.文件大小仅支持10min、10M以内文件;
3.采样率为16000,比特率为16bit;
4.单声道;
 * voiceAudioUpload.php
 * Create on 2023/3/24 17:51
 * Create by lihailiang@fanyigou.com
 */
include_once __DIR__.'/../vendor/autoload.php';

use Fanyigou\ApiSdkPhp\Dispatch;
use Fanyigou\ApiSdkPhp\DispatchException;

$appKey = '您的应用ID';
$secKey = '您的密钥';

$dispatch = new Dispatch(['app_key' => $appKey, 'sec_key' => $secKey]);

$voicePath = __DIR__.'/file/test.wav'; //文档路径

$params = [
    'from' => '源语言(目前支持中文或者英文)',
    'to' => '目标语言(目前支持英文或者中文)',
];

try {
    $result = $dispatch->voiceAudioUpload($params, $voicePath);
    print_r($result);
} catch (DispatchException $e) {
    print_r($e->getMessage());
}
                                    
音频翻译任务查询接口示例代码
<?php
/**
 * 音频翻译任务查询接口
 * voiceAudioQueryProgress.php
 * Create on 2023/3/24 17:51
 * Create by lihailiang@fanyigou.com
 */
include_once __DIR__.'/../vendor/autoload.php';

use Fanyigou\ApiSdkPhp\Dispatch;
use Fanyigou\ApiSdkPhp\DispatchException;

$appKey = '您的应用ID';
$secKey = '您的密钥';

$dispatch = new Dispatch(['app_key' => $appKey, 'sec_key' => $secKey]);

$params   = [
    'recordId' => '音频文件翻译id',
];

try {
    $result = $dispatch->voiceAudioQueryProgress($params);
    print_r($result);
} catch (DispatchException $e) {
    print_r($e->getMessage());
}
                                    
音频下载译文链接接口示例代码
<?php
/**
 * 音频下载译文链接接口
 * voiceAudioDownload.php
 * Create on 2023/3/24 17:51
 * Create by lihailiang@fanyigou.com
 */
include_once __DIR__.'/../vendor/autoload.php';

use Fanyigou\ApiSdkPhp\Dispatch;
use Fanyigou\ApiSdkPhp\DispatchException;

$appKey = '您的应用ID';
$secKey = '您的密钥';

$dispatch = new Dispatch(['app_key' => $appKey, 'sec_key' => $secKey]);

$params   = [
    'recordId' => '音频文件翻译id',
];

try {
    $result = $dispatch->voiceAudioDownload($params);
    print_r($result);
} catch (DispatchException $e) {
    print_r($e->getMessage());
}
                                    
词典示例代码
<?php
/**
 * 词典
 * dictSearch.php
 * Create on 2023/3/24 17:51
 * Create by lihailiang@fanyigou.com
 */
include_once __DIR__.'/../vendor/autoload.php';

use Fanyigou\ApiSdkPhp\Dispatch;
use Fanyigou\ApiSdkPhp\DispatchException;

$appKey = '您的应用ID';
$secKey = '您的密钥';

$dispatch = new Dispatch(['app_key' => $appKey, 'sec_key' => $secKey]);

$params   = [
    'word' => '搜索词', // 词语,小于等于15个字符
];

try {
    $result = $dispatch->dictSearch($params);
    print_r($result);
} catch (DispatchException $e) {
    print_r($e->getMessage());
}
                                    
获取账户信息示例代码
<?php
/**
* 获取账户信息
* getAccount.php
* Create on 2023/3/24 17:51
* Create by lihailiang@fanyigou.com
*/
include_once __DIR__.'/../vendor/autoload.php';

use Fanyigou\ApiSdkPhp\Dispatch;
use Fanyigou\ApiSdkPhp\DispatchException;

$appKey = '您的应用ID';
$secKey = '您的密钥';

$dispatch = new Dispatch(['app_key' => $appKey, 'sec_key' => $secKey]);

$params   = [
    'type' => 1, //资源包类型 1.文档翻译 2.文字翻译 3.图片翻译 4.格式转换
];

try {
    $result = $dispatch->getAccount($params);
    print_r($result);
} catch (DispatchException $e) {
    print_r($e->getMessage());
}                                        
                                    

PYTHON-SDK调用说明

环境说明

1.运行环境 python3.x

2.调用前需安装第三方环境

pip install requests    
pip install websockets (语音识别翻译接口需要此环境,不用可不安装)
                                    
接口说明

1.account.py (获取账户信息)

2.audio_trans.py (音频识别翻译)

3.dict_search.py (词典)

4.doc_convert.py (文档转换)

5.doc_convert.py (文档翻译)

6.image_trans.py (图片翻译)

7.ocr.py (ocr识别)

8.text_trans.py (文字翻译)

9.voice_trans.py (语音识别翻译)

操作步骤
1.安装
pip install qingxun-openapi-python-sdk
2.引用
import TranslateApi

只引用文字翻译:

from TranslateApi.text_trans import trans
                                    
3.调用方式(参考下方示例代码)
示例代码
#引用api库
import TranslateApi

ip = "服务ip 如 www.fanyigou.com"
appid = "应用ID"
privatekey = "密钥"
fromLang = "源语言"
toLang = "目标语言"
filepath = "本机上需要上传翻译的文件地址"
filename = "给上传的文件取一个名字吧"

#调用需要的方法(当前按方法是上传并翻译接口)
uploadTranslateres = TranslateApi.document_translation.uploadTranslate(ip, appid, privatekey, fromLang, toLang, filepath, filename)

#文档上传有四个追加参数
# industryId   行业代码   int    见行业列表  否
# transImg 文档内图片翻译    int    0:不翻译文档内图片(默认),1:翻译文档内图片。目前支持中、英、日、韩的文档内图片翻译。(如有需要请联系销售开通) 否
# excelMode    指定excel翻译模式    int    0:只翻译当前打开sheet(默认),1:翻译全部sheet(页数按全部sheet字符数来计算)   否
# bilingualControl 指定翻译模式 int    0:译文单独为一个文档(默认),1:双语对照(原文和译文在一个文档) 否
# 可以在参数后边用(industryId = 0 ,transImg=0 , excelMode = 0,bilingualControl=0)进行追加

# 追加示例(详情参数请查看开放平台)
res = TranslateApi.document_translation.uploadTranslate(fromLang,toLang,filepath,filename,industryId = 0 ,transImg=0 , excelMode = 0,bilingualControl=0)

#打印结果
print(res)

# 返回示例
# {'msg': '请求成功', 'code': 100, 'data': {'tid': tid}}
# 查询进度接口
# res = qxkjapi.queryTransProgress("tid")
# 文档下载接口
# res = qxkjapi.downloadFile("tid","3")

# 参数详情请查看开放平台文档
"http://open.qingxun.com/filecore.html"

                                    
文档翻译示例代码
  • 1. 文档翻译示例代码
  • 2. 文件上传示例代码
  • 3. 获取进度示例代码
  • 4. 下载示例代码
  • 5. 上传文件检测页数示例代码
  • 6. 检测页数文件提交翻译示例代码
文档翻译示例代码
ip = "服务ip 如 www.fanyigou.com"
appid = "应用ID"
privatekey = "密钥"
fromLang = "源语言"
toLang = "目标语言"
filepath = "本机上需要上传翻译的文件地址"
filename = "给上传的文件取一个名字吧"
                                    
文件上传示例代码
from TranslateApi.document_translation import uploadTranslate

uploadTranslateres = uploadTranslate(ip,appid,privatekey, fromLang, toLang, filepath, filename)
                                    
获取进度示例代码
from TranslateApi.document_translation import queryTransProgress

tid = "调用uploadTranslate获取的tid"
queryTransProgressres = queryTransProgress(ip,appid,privatekey, tid)
                                    
下载示例代码
from TranslateApi.document_translation import downloadFile

dtype = "下载的文件类型(new)"
Filecontent = downloadFile(ip,appid,privatekey,tid, dtype)
with open("保存文件地址","wb") as w:
    w.write(Filecontent)
                                    
上传文件检测页数示例代码
from TranslateApi.document_translation import detectDocPage

detectDocPageres = detectDocPage(ip,appid,privatekey,filepath,filename)
                                
检测页数文件提交翻译示例代码
from TranslateApi.document_translation import submitForDetectDoc

submitForDetectDocres = submitForDetectDoc(ip,appid,privatekey,tid,fromLang,toLang)
                                
文字翻译示例代码
from TranslateApi.text_trans import trans

ip = "服务ip 如 www.fanyigou.com"
appid = "应用ID"
privatekey = "密钥"

fromLang = "源语言"
toLang = "目标语言"
text = "要翻译的文字"
print(trans(ip,appid,privatekey,fromLang,toLang,text))
                                    
格式转换示例代码
  • 1. 文档转换示例代码
  • 2. 获取进度示例代码
  • 3. 下载示例代码
文档转换示例代码
from TranslateApi.doc_convert import convert

ip = "服务ip 如 www.fanyigou.com"
appid = "应用ID"
privatekey = "密钥"
filepath = "本机上需要上传翻译的文件地址"
filename = "给上传的文件取一个名字吧"
conversionFormat = "转换的目标格式(int类型)"

convertres = convert(ip,appid,privatekey,filepath,filename,conversionFormat)
print(convertres.json())
                                    
获取进度示例代码
from TranslateApi.document_translation import queryTransProgress

ip = "服务ip 如 www.fanyigou.com"
appid = "应用ID"
privatekey = "密钥"
tid = "调用convert获取的tid"

queryTransProgressres = queryTransProgress(ip,appid,privatekey, tid)
                                    
下载示例代码
from TranslateApi.document_translation import downloadFile
    
ip = "服务ip 如 www.fanyigou.com"
appid = "应用ID"
privatekey = "密钥"
#6:转换完成文档
dtype = 6 
Filecontent = downloadFile(ip,appid,privatekey,tid, dtype)
with open("保存文件地址","wb") as w:
w.write(Filecontent)
                                    
图片翻译上传示例代码
  • 1. 图片翻译上传示例代码
  • 2. 查询图片翻译进度示例代码
  • 3. 图片翻译下载示例代码
图片翻译上传示例代码
from TranslateApi.image_trans import uploadTranslateImage

ip = "服务ip 如 www.fanyigou.com"
appid = "应用ID"
privatekey = "密钥"

fromLang = "源语言"
toLang = "目标语言"
filepath = "本机上需要上传翻译的文件地址"
filename = "给上传的文件取一个名字吧"

uploadTranslateImageres = uploadTranslateImage(ip,appid,privatekey,fromLang,toLang,filepath,filename)
print(uploadTranslateImageres)
                                    
查询图片翻译进度示例代码
from TranslateApi.image_trans import queryImageTransProgress

ip = "服务ip 如 www.fanyigou.com"
appid = "应用ID"
privatekey = "密钥"
tid =  "调用uploadTranslateImage获取的tid"

queryImageTransProgressres = queryImageTransProgress(ip,appid,privatekey,tid)
print(queryImageTransProgressres)
                                    
图片翻译下载示例代码
from TranslateApi.image_trans import downloadImage
ip = "服务ip 如 www.fanyigou.com"
appid = "应用ID"
privatekey = "密钥"
tid = "调用uploadTranslateImage获取的tid"
Imagecontent = downloadImage(ip,appid,privatekey,tid)

with open("保存文件地址","wb") as w:
w.write(Imagecontent)
                                    
OCR(图像识别)示例代码
from TranslateApi.ocr import ocrUploadImage

ip = "服务ip 如 www.fanyigou.com"
appid = "应用ID"
privatekey = "密钥"
fromLang = "源语言"
filepath = "本机上需要上传翻译的文件地址"
filename = "给上传的文件取一个名字吧"

ocrUploadImageres = ocrUploadImage(ip, appid,privatekey, fromLang, filepath, filename)
print(ocrUploadImageres)
                                    
语音识别翻译示例代码
  • 1. "获取ConnectionId"示例代码
  • 2. "连接webscoket进行语音识别翻译"示例代码
  • 3. 获取译文音频链接接口示例代码
"获取ConnectionId"示例代码
from TranslateApi.voice_trans import getConnectionId

ip = "服务ip 如 www.fanyigou.com"
appid = "应用ID"
privatekey = "密钥"
fromLang = "源语言"
toLang = "目标语言"

getConnectionIdres = getConnectionId(ip,appid,privatekey,fromLang,toLang)
print(getConnectionIdres)
                                    
"连接webscoket进行语音识别翻译"示例代码
from TranslateApi.voice_trans import up_webscoket

ip = "服务ip 如 www.fanyigou.com"
appid = "应用ID"
privatekey = "密钥"
filepath = "本机上需要上传翻译的文件地址"
connectionId = "调用getConnectionId接口获取id"

up_webscoketres = up_webscoket(ip,appid,privatekey,filepath,connectionId)
print(up_webscoketres)
                                    
获取译文音频链接接口示例代码
from TranslateApi.voice_trans import up_webscoket

ip = "服务ip 如 www.fanyigou.com"
appid = "应用ID"
privatekey = "密钥"
filepath = "本机上需要上传翻译的文件地址"
connectionId = "调用getConnectionId接口获取id"

up_webscoketres = up_webscoket(ip,appid,privatekey,filepath,connectionId)
print(up_webscoketres)
                                    
音频识别翻译示例代码
  • 1. 音频文件上传接口示例代码
  • 2. 音频进度接口示例代码
  • 3. 音频下载译文链接接口示例代码
音频文件上传接口示例代码
from TranslateApi.audio_trans import audio_upload

ip = "服务ip 如 www.fanyigou.com"
appid = "应用ID"
privatekey = "密钥"
fromLang = "源语言"
toLang = "目标语言"
filepath = "本机上需要上传翻译的文件地址"

audio_uploadres = audio_upload(ip,appid,privatekey,fromLang,toLang,filepath)
print(audio_uploadres.json())
                                    
音频进度接口示例代码
from TranslateApi.audio_trans import audio_queryProgress
ip = "服务ip 如 www.fanyigou.com"
appid = "应用ID"
privatekey = "密钥"
recordId = "调用音频文件上传接口audio_upload获取"

audio_queryProgressres = audio_queryProgress(ip,appid,privatekey,recordId)
print(audio_queryProgressres.json())
                                    
音频下载译文链接接口示例代码
from TranslateApi.audio_trans import audio_download
ip = "服务ip 如 www.fanyigou.com"
appid = "应用ID"
privatekey = "密钥"
recordId = "调用音频文件上传接口audio_upload获取"
audio_downloadres = audio_download(ip,appid,privatekey,recordId)
print(audio_downloadres.json())
                                    
词典示例代码
from TranslateApi.dict_search import findDict

ip = "服务ip 如 www.fanyigou.com"
appid = "应用ID"
privatekey = "密钥"
word = "搜索词"

findDictres = findDict(ip,appid,privatekey,word)
print(findDictres.json())
                                    
获取账户信息示例代码
from TranslateApi.account import getAccount

ip = "www.fanyigou.com"
appid = "应用ID"
privatekey = "密钥"
Accountres = getAccount(ip,appid,privatekey)
print(Accountres.json())
                                    
购买的企业版有效期到期,到期后如何延长文件储存时长?
到期后数据我们会自动免费为您保存10日(到期时间顺延10日),若您有复购需求,10日内完成复购即可延长文件在线存储时长;若您无复购需求,建议您尽早下载文件保存到本地,避免文件丢失。
企业版有页数,为何翻译需要收费?
请登录翻译狗企业版(网址:https://enterprise.fanyigou.com/),再次尝试。
文件翻译后出现乱码?
翻译文件乱码问题出现原因主要为原文件加密,上传翻译时未对文件解密,请解密文件后重试。
翻译狗企业版与个人版有何区别?
翻译狗企业版提供项目管理功能,可创建多个子账号共同使用,同时提供机器辅助翻译CAT功能,用户可在线校对译文,提高翻译准确性。
翻译狗企业套餐有效期如何计算?套餐内页数有效期如何计算?
购买的企业版套餐有效期,以不同套餐开通的具体日期为开始时间,在套餐有效期内,套餐内页数均可使用,直至套餐到期;若套餐到期后您有未使用完的页数,将会自动清零,请根据需要尽早使用套餐内页数。
我是海外用户,我想使用企业版,应该如何登录?
海外用户可以使用邮箱进行账号注册登录。
如何更换企业账号管理员?
提交工单,工作日时间24小时内立即受理。
企业版子账号收不到短信验证码相关,无法登录该如何处理?
您的账号可能注册了翻译狗个人版账号,现提供给您2种登录方式:①使用您翻译狗个人版账号密码登录翻译狗企业版,系统会自动为您跳转页面;②登录时选择输入手机号/邮箱登录方式,点击忘记密码,完成验证登录。
使用企业版翻译完成后,文件为空白页面怎么办?
请拨打4001-868-556 或 提交工单 联系客服,客服将为您优先处理。
企业套餐页数怎么分配使用?
您购买的企业套餐页数,可以登录企业主账号,根据需要手动分配给子账号用户使用。
文字翻译空格是否算字符?
文字翻译空格也会被计算为字符。
接口调用支持哪些方式?是否提供demo案例?
接口调用支持标准HTTP请求调用,也可以基于SDK调用,目前提供的SDK有JAVA、PHP和PYTHON。请参考文档中心-SDK调用示例
翻译文档出错怎么办?
请拨打4001-868-556 或 提交工单 联系客服,客服将为您优先处理。
翻译狗本地部署服务是否支持离线部署?
翻译狗本地部署服务支持离线部署,目前翻译狗在线的语言共120+种,全部支持离线部署。
翻译狗本地部署服务采用离线部署方式,如何进行收费?
请拨打电话15381069892联系翻译狗商务获取报价信息。
系统需要维护升级及时间相关。
请拨打电话15381069892联系翻译狗团队。
翻译狗开放平台技术交流群 项目

扫一扫群二维码,立刻加入该群

群号:21120026830

翻译狗翻译使用协议

尊敬的用户,欢迎您使用翻译狗翻译产品。在使用前请您仔细阅读以下条款及 《翻译狗用户协议》《翻译狗隐私政策》《翻译狗翻译使用协议》等翻译狗平台规则内容,如果您对本协议中的任何条款表示异议,您可以选择不使用翻译狗翻译;但如果您使用翻译狗翻译,将视为您已充分理解且同意本协议的所有条款,且具有浏览翻译狗翻译平台信息、使用健康咨询服务等翻译狗翻译平台服务的相应权利能力和行为能力,并可以对自己的行为承担法律责任。

第一章 总则

第一条 翻译狗翻译是杭州轻寻科技有限公司向用户提供语言翻译服务的产品。
第二条 翻译狗翻译的所有权、经营权、管理权均属杭州轻寻科技有限公司。

第二章 免责声明

第三条 除产品或者服务另有说明外,翻译狗翻译基本原理是机器自动从大量语料中学习并自动生成翻译结果,翻译结果没有经过任何人工整理与编辑。
第四条 翻译狗翻译以非人工方式提供翻译结果,杭州轻寻科技有限公司对翻译结果的正确性和合法性不做任何形式的保证,亦不承担任何法律责任。文档翻译企业用户可在机器翻译结果上进行编辑,能够上传术语和语料对机器翻译结果进行干预,翻译狗对用户自行修改和上传的内容造成的侵权、纠纷、损失概不负责,亦不承担任何法律责任。
第五条 翻译狗翻译根据用户键入的内容机器自动生成翻译结果,不代表翻译狗赞成键入内容及翻译结果的内容、立场、观点。
第六条 翻译狗翻译仅根据用户键入内容提供机器翻译结果,对键入内容和翻译结果造成的侵权、纠纷、损失概不负责,亦不承担任何法律责任。
第七条 用户自行决定是否使用系统提供的编辑译文的功能,进行人工修正翻译结果;自行决定是否导入语料,使用系统提供的语料管理和干预的功能,对机器翻译结果进行干预。
第八条 翻译狗翻译-AI翻译功能,由第三方提供。因“AI翻译”的翻译内容和质量等原因产生的任何问题与翻译狗翻译无关。AI翻译内容仅供参考,如您自行决定使用,由此产生的一切问题翻译狗不承担任何责任。
第九条 您充分知晓并保证您在翻译狗翻译使用相关功能时上传、发布的内容享有合法权益,若发布的内容发生权利纠纷或侵犯了任何第三方的合法权益,由您承担全部法律责任,翻译狗不承担任何法律责任。
第十条 翻译狗尊重并保护所有使用翻译狗用户的个人隐私权,对收集的用户数据中涉及用户个人隐私的数据、用户账户信息、用户用于翻译的原文以及生成的翻译结果进行保护,不会将用户的上述数据对外公开或提供给任何第三方,但以下情况除外:
1.您在使用翻译狗翻译时输入的内容将不被认为是您的个人隐私资料;
2.您同意让第三方共享;
3.您同意公开个人数据,享受为您提供的产品和服务;
4.根据法律法规的规定,或行政机关的要求,向行政机关、司法机关或其他法律规定的第三方披露;
5.您因个人原因向行政机关、司法机关或其他法律规定的第三方提出诉求,第三方向翻译狗了解相关内容,轻寻将向第三方披露其个人数据。
6.您同意并授权翻译狗客服进行人工编辑优化翻译版面,包括授权使用第三方软件进行处理。
第十一条 由于系统发生故障导致影响翻译狗翻译的正常运行,翻译狗承诺及时处理并进行修复,但用户因此而产生的纠纷和损失,杭州轻寻科技有限公司概不负责,亦不承担任何法律责任。此外,杭州轻寻科技有限公司保留不经事先通知而为维修、升级或其他目的暂停本服务全部或任何部分的权利。
第十二条 翻译狗翻译-使用加密版翻译的用户,您已知晓并同意如您开通翻译狗AI翻译功能,则加密版将自动转为普通版本,保密等级、合同赔偿及其他方面将与普通版本同步。赔偿上限为当次已支付总金额。

第三章 服务费用

第十四条 翻译狗翻译部分服务以免费方式提供,具体计费方式、收费标准和支付方式以平台提供和相关页面详情内容为准。您在充值和翻译文档前,应仔细阅读关于翻译狗具体计费方式、收费标准和支付方式的相关内容。
第十五条 翻译狗可能根据实际需要对收费服务的收费标准、方式进行修改和变更。前述修改、变更或开始收费前,翻译狗将在相应服务页面进行通知或公告。如果您不同意上述修改、变更或付费内容,则应直接停止、取消使用该服务,否则视为您同意上述修改、变更或付费内容。如您已使用该服务,翻译狗有权不予退还您已使用该服务的相关费用。

第四章 权利声明

第十六条 当用户发现翻译狗翻译侵犯其合法权益时,权利人应事先向杭州轻寻科技有限公司发出“权利通知”,翻译狗将根据中国法律法规和政府规范性文件采取措施移除或修改相关机器翻译结果,并将结果反馈权利人。权利个人或单位务必以书面的通讯方式向杭州轻寻科技有限公司提交权利通知。为使杭州轻寻科技有限公司有效处理权利人的权利通知,权利通知的书写请使用以下书面形式:
1. 权利人对涉嫌侵权内容拥有商标权、著作权和/或其他依法可以行使权利的权属证明;
2. 请充分、明确地描述被涉嫌侵犯了权利人合法权益的内容并请提供侵权的翻译键入内容和翻译结果;
3. 请指明涉嫌侵权的翻译结果侵犯了第2项中列明的权利人的合法权益;
4. 请提供权利人具体的联络信息,包括真实的姓名、身份证或护照复印件(针对自然人)、单位登记证明复印件(针对单位)、通信地址、电话号码、传真和电子邮件;
5. 请在权利通知中加入如下关于通知内容真实性的声明:
(1)我本人为所投诉内容的合法权利人;
(2)我举报的翻译狗翻译相关内容侵犯了本人相应的合法权益;
(3)本人确认:如果本权利通知内容不完全属实,本人将承担由此产生的一切法律责任。
6. 请在权利通知中加入如下陈述:
“我保证,本权利通知中所诉信息是充分、真实、准确的,我是所投诉内容的合法权利人”或“我保证,本权利通知中所诉信息是充分、真实、准确的,我已获授权,有权行使第2项中列明内容的权益。”
7. 请您签署该文件,如果您是依法成立的机构或组织,请您加盖公章。
请您将包含以上7项的完整权利通知、相关资料和真实准确的联络方式以书面的形式发往以下地址:
浙江省杭州市余杭区五常街道文一西路998号4幢510室
邮政编码:310000
第十七条 如果权利通知的陈述失实,权利通知提交者将承担由此造成的全部法律责任(包括但不限于赔偿各种费用及律师费)。如果上述个人或单位不确定翻译狗翻译是否侵犯了其合法权益,杭州轻寻科技有限公司建议该个人或单位首先咨询专业人士。

第五章 服务使用规范

第十八条 在使用翻译狗翻译服务过程中,您承诺:
a) 您在翻译狗翻译实施的所有行为(包括但不限于交易行为、信息发布行为)均遵守国家各项法律、法规的规定和要求,遵守诚实信用原则,不损害社会公共利益或违反公共道德,不损害他人的合法权益,不违反本协议的规则和精神。您如果违反前述承诺并造成任何损害后果的,您应以自己的名义独立承担所有的法律责任,翻译狗翻译对此概不负责。若您违反本款规定的行为给翻译狗翻译造成不利后果的,则您应负责消除影响,且应赔偿翻译狗翻译的全部损失。
b) 不得妨碍翻译狗翻译的正常运营秩序,包括但不限于不以虚构或歪曲事实的方式对其他用户或第三方服务商进行不当或诋毁性评价,不采取不正当方式虚构、抬高或拉低其他用户或第三方服务商的信用度。
c) 不对翻译狗翻译的任何数据资料进行任何超出翻译狗翻译合理使用范围的利用,包括但不限于在未经翻译狗翻译事先书面同意的情况下,以翻译狗翻译外复制、传播或其他任何方式使用翻译狗翻译上展示的资料。
d) 不通过任何途径限制、干扰或破坏翻译狗翻译的正常运作或翻译狗翻译上进行的各项服务活动。
e) 不进行任何其他可能对翻译狗翻译正常服务或其他用户正常使用造成不利影响的行为。
第十九条 在使用服务服务过程中,您了解并同意:
a) 翻译狗翻译有权对您是否违反上述承诺做出单方认定,并根据单方认定结果的适用有关规则予以处理或终止向您提供服务,且无须提前通知您或征得您的同意。
b) 基于维护交易秩序及交易安全的需要,翻译狗翻译有权根据自身情况执行暂停有关交易活动、关闭有关交易订单等操作。
c) 经国家司法机关或行政机关生效的法律文书确认您存在违法或侵权行为的,或者翻译狗翻译根据自身的判断,认为您的行为涉嫌违反本协议、平台规则或有关法律法规的规定的,则翻译狗翻译有权对您涉嫌违法或违约的行为予以公示。
d) 对于您在翻译狗翻译上实施的行为,以及您未在翻译狗翻译上实施但已经对翻译狗翻译及其用户产生影响的行为,翻译狗翻译有权单方面认定您行为的性质及是否构成对本协议或有关规则的违反,并据此采取相应的措施。如您对翻译狗翻译的处理行为有疑问和异议的,您应自行对与您行为有关的证据进行保存,并承担无法提供充分证据的不利后果。
e) 对于您涉嫌违反法律法规或本协议的行为给任何第三方造成损害的,您应以自己的名义独立承担所有的法律责任,并应确保翻译狗翻译免于因此产生任何损失。
f) 对于您涉嫌违反法律法规或本协议的行为给翻译狗翻译造成损害的,或使翻译狗翻译遭受来自任何第三方的索赔,或受到任何司法部门、行政部门或其他监管机构处罚的,您应当赔偿翻译狗翻译因此受到的全部损失及发生的合理费用。
第二十条 在使用翻译狗翻译所提供的服务过程中,您了解并同意,翻译狗翻译不对因包括但不限于下述情况而使您产生的任何损失承担责任:
a) 使用或未能使用服务;
b) 第三方未经批准的使用您的账号或更改您的数据;
c) 您通过服务购买或获取的任何商品、样品、数据、信息致使您产生的费用或带来的损失;
d) 您对服务的误解;
e) 任何非因翻译狗翻译的原因而引起的与服务有关的其它损失。

第六章 信息保护与管理

第二十一条 翻译狗翻译非常重视保护用户信息。在您使用翻译狗翻译服务的过程中,我们会基于您需求的服务,收集和使用您的个人信息。《翻译狗隐私政策》适用于翻译狗集团所有产品和服务,如协议中有未尽事宜,以《翻译狗隐私政策》为准,若本协议和《翻译狗隐私政策》存在不一致,则优先适用本协议约定。
1.您在使用翻译狗翻译的文档翻译功能及相关功能时,需先注册成为翻译狗用户。您应该保证注册的个人资料是真实且准确的, 您在账号名称、头像等注册信息中不得出现违法和不良信息。您因缺少身份认证或认证信息不真实而导致账号、账号内财产等丢失、减少而无法找回的,翻译狗不承担任何法律责任。您应妥善保管自己的账号和密码,加强密码安全性,谨防账号泄露或被盗。您因账号被泄露或被盗而造成的任何损失,翻译狗不承担补偿责任。
2.翻译狗翻译将根据翻译狗账号和密码确认您的身份,如果您还未注册翻译狗账号,则需要先注册成为翻译狗用户,以便使用部分翻译狗翻译的产品和服务。您不得以任何形式转让或授权他人使用您的账号。您应妥善保护您的账号、密码,并对该账号发生的一切活动(包括但不限于发布信息、网上点击同意或提交任何有关规则的协议、网上续签协议或购买商品等)承担全部责任。
3.您确认,在您完成注册程序或者以其他翻译狗翻译允许的方式实际使用服务时,您应当是具备完全民事权利能力和与所从事的民事行为相适应的行为能力的自然人、法人或其他组织。若您不具备前述主体资格,则您及您的监护人应承担因使用此服务而导致的一切后果,且本平台有权注销或永久冻结您的账号,并向您及您的监护人索偿相应损失。
第二十二条 您知悉并确认,对于您在使用翻译狗翻译服务过程中提供、形成的除个人信息外的文字、图片、视频、音频、数据等非个人信息(包括但不限于经过匿名化处理的咨询记录、购买记录、快递记录等),均属于翻译狗的专有财产。在法律规定的保护期限内,翻译狗有权独占性的存储、使用、复制、修订、编辑、发布、展示、翻译、分发、转授权该等信息或制作其派生作品,并以已知或日后开发的形式、媒体或技术将上述信息纳入其它作品内。
第二十三条 一般情况下,您可以浏览、修改自己提交的信息,但出于安全性和身份识别的考虑,您可能无法修改注册时提供的身份信息及其他相关信息。
第二十四条 在使用翻译狗翻译提供的服务时,您应对您的用户资料、联系方式等信息及时予以更新,以使之具有真实性、完整性和准确性。如有合理理由认为您提供的资料不实、不完整或有错误的,翻译狗翻译有权向您进行询问或发出要求改正的通知,并有权直接做出删除相应资料的处理,直至暂停、中断或终止对您提供部分或全部服务。翻译狗翻译对此不承担任何责任,您将承担因此产生的任何直接或间接损失及不利后果。
第二十五条 您了解并同意,对您在翻译狗翻译提供的用户信息和形成的交易记录等信息内容,翻译狗翻译有权根据司法部门、行政部门及其他监管机构的要求向其提供。如您的使用行为涉嫌侵犯他人合法权益,则翻译狗翻译亦有权在对涉嫌侵权行为进行初步判断并认定其存在的基础上,向权利人提供您必要的身份信息。
第二十六条 您在使用翻译狗翻译时应承诺遵守法律法规、国家利益、公共秩序、社会道德风尚和信息真实性。您声明并保证,您使用翻译狗翻译服务过程中提供、形成的信息不包含以下内容,否则翻译狗可对您在使用翻译狗翻译过程中提供、形成的信息依法或依本协议进行删除或屏蔽,终止您使用翻译狗翻译服务并赔偿翻译狗因此遭受的一切损失:
a) 违反宪法或法律法规规定的;
b) 宣扬或实施危害国家主权、国家安全、国家秘密、国家统一、国家荣誉、国家利益、民族关系、民族团结、社会秩序、社会稳定、公序良俗的行为;
c) 宣扬或实施煽动民族仇恨或民族歧视的、破坏民族团结的、破坏国家宗教政策的、宣扬邪教和封建迷信的、散布谣言的、扰乱社会秩序的、破坏社会稳定的、侮辱的、诽谤的、淫秽的、色情的、暴力的、恐怖的、教唆犯罪的行为;
d) 宣扬或实施含有虚假、有害、胁迫、侵害他人隐私、骚扰、侵害、中伤、粗俗、猥亵或其它道德上令人反感的内容的行为;
e) 宣扬或提供关于非法行为的说明信息;
f) 宣扬或实施侵害他人的个人信息权、隐私权、人身财产、名誉权、肖像权、知识产权、商业秘密权等合法权益的行为;
g) 收集或存储有关其他用户的个人信息,用于法律法规或本协议禁止的行为或活动;
h) 存在可能破坏、篡改、删除、影响翻译狗翻译任何系统正常运行或未经授权获取翻译狗翻译及其他用户的数据、个人信息的病毒、木马、爬虫等恶意软件、程序代码的;
i) 其他含有法律、行政法规禁止的内容。

第七章 服务变更或终止

第二十七条 翻译狗翻译有权自行全权决定以任何理由不经事先通知而暂停、中断或终止向用户提供本协议项下的全部或部分服务,暂时冻结或永久冻结(注销)您的账号在翻译狗翻译的权限,且无须为此对用户或任何第三方承担任何责任。终止本协议、冻结账号权限的情形包括但不限于:
a) 您提供的用户信息中的主要内容不具有真实性、完整性或有效性;
b) 翻译狗翻译认为您已经违反法律法规或本协议的规则或精神的;
c) 翻译狗翻译终止向您提供服务后,您涉嫌再次直接或间接或以他人名义注册使用本服务的;
d) 本协议(含有关规则)变更时,您明示并通知翻译狗翻译不愿接受经修改的协议或有关规则的;
第二十八条 翻译狗翻译在永久冻结或注销账号权限后,有权自行对账号相关内容及信息进行删除或以其他方式进行处理,且无需为此向用户承担任何责任。
第二十九条 您同意,您与翻译狗翻译经营者的合同关系终止后,翻译狗翻译仍有权继续保存您的用户信息及您使用服务期间的所有交易信息。对于您在使用服务期间存在违法行为或违反本协议和/或有关规则的行为的,翻译狗翻译仍可依据本协议向您主张权利。
第三十条 翻译狗翻译暂停、中断或终止向您提供服务后,对于您在服务暂停、中断或终止之前的交易行为依下列原则处理:
a) 您在服务暂停、中断或终止之前已经与其他用户、第三方服务商达成合同,但合同尚未实际履行的,翻译狗翻译有权删除该合同及其交易物品的有关信息;
b) 您在服务暂停、中断或终止之前已经与其他用户、第三方服务商达成合同且已部分履行的,翻译狗翻译有权单方面决定是否删除该项交易的有关信息,并有权在暂停、中断或终止服务的同时将相关情形通知您的交易对方。
c) 您同意,您独立承担进行上述处理所产生的任何争议、损失或增加的任何费用,并应确保翻译狗翻译免于因此产生任何损失或承担任何费用。

第八章 知识产权和无许可

第三十一条 翻译狗翻译上的所有内容,包括但不限于任何文字、数据、图像、文章、照片、插图、声效及其他素材及资料(单称或合称“内容”)可能全部或部分地受中华人民共和国及其他国家著作权法、商标法、其他适用法律和/或国际公约保护。您承认并同意,翻译狗翻译所有内容的所有相应的知识产权均为翻译狗和/或其许可或授权的第三方或翻译狗翻译入驻的第三方服务提供商(单称或合称“权利人”)的专有财产。除本协议明示授予的许可和权利之外,本协议不通过暗示或其他方式向您授予权利人拥有或控制的任何知识产权项下的任何许可或权利。
第三十二条 您承诺,未经我们书面许可:
a) 不对翻译狗翻译的任何内容进行全部或部分修改、发布、转载、出售、复制,反向工程、反向编译或反汇编,通过任何机器人、爬虫等程序或设备监视,以之为基础创造衍生作品、分销、执行、呈现或以任何方式利用;
b) 不得以任何方式在任何国家或区域展示、使用、申请或注册、或以任何其他方式进行处理翻译狗商标,包括但不限于在翻译狗翻译(含小程序或官方网站等)上展示的“翻译狗”、“翻译狗翻译”、“fanyigou”等文字、设计、图形及其组成部分,以及翻译狗翻译(包括但不限于小程序或官方网站)上展示的其他标识、徵记、产品和服务名称,也不得在任何国家或区域向他人表明您有权展示、使用、申请或注册、或以任何其他方式进行处理翻译狗商标。
否则由此引起的一切法律后果由您负责,翻译狗将依法追究法律责任。

第九章 附则

第三十三条 翻译狗有权不时对本协议进行修订,修订后协议条款将在相关服务页面上公布。我们建议您不时查看最新的协议条款。您理解并同意,如果您在本协议条款修订版本公布后继续使用翻译狗翻译产品或服务的,即视为您同意接受修订后协议条款并受其约束。
第三十四条 如果本协议中的任何条款无论因何种原因完全或部分无效或不具有执行力,或违反任何适用的法律,则双方应当以最接近于该条款意图的新条款替代被认定为无效、非法和不能执行的条款。本协议的其余条款仍应有效并且具有约束力。
第三十五条 未经翻译狗的事先书面同意,您不得向任何第三方转让本协议及其项下的任何权利和义务。翻译狗有权随时在未取得您同意的情况下向以下各方全部或部分地转让本协议项下全部或部分权利:
(1)翻译狗的子公司或者关联方;
(2)翻译狗的股权、业务或资产的收购方;
(3)并购交易中翻译狗的继承人。
任何违反本协议的转让行为均是无效的。
第三十六条 本协议各条款前所列标题仅为帮助您理解该条款表达的主旨之用,不影响或限制本协议条款的含义或解释。为维护您自身权益,建议您仔细阅读各条款具体表述。
第三十七条 您同意,如果本平台未执行或未行使法律规定或本协议约定中的任何权利或赔偿,不可视为本平台对该权利或赔偿的放弃,这些权利或救济仍对本平台有效。
第三十八条 您理解并同意,翻译狗就翻译狗翻译产品或服务相关的任何通知可通过如下任一途径向您发送:
(1)在本技能平台或翻译狗官方网站发出一般通知;
(2)向您提供的手机号码发送短信通知或电话联系您;
(3)向您提供的通讯地址(如有)寄送书面通知。
前述通知自发布或发送之日即视为已经对您送达,您理解并同意您有义务查收任何上述通知。
第三十九条 在法律允许的范围内本协议最终解释权归【杭州轻寻科技有限公司】及其关联公司所有。
第四十条 本协议中“关联方”是指:对任何一家实体而言,指受该实体控制、控制该实体或与该实体受第三方共同控制的实体。所谓“控制”是指持有一家实体超过50%投票权的股权/权益或者有权委派该实体超过半数的董事或者其他类似管理机构的成员,或通过协议或其他方式对该实体的运营具有实际决定权或控制权。


再次感谢您对翻译狗翻译的信任和使用!

咨询
4001-868-556 咨询热线
在线客服咨询 点击联系在线客服
扫码加入开放平台技术交流群 群号:21120026830
帮助
工单