扫读笔_在线OCR识别及查词协议
文档状态
| 文件标识: | TuringOS-OpenSocket-V1.4.3 |
|---|---|
| 系统版本: | OpenSocket |
| 作 者: | 段亚骏 |
| 完成日期: | 2022年11月16日 |
文档修订记录
为便于后续文档维护,文档版本号将由三部分组成,第一个数字为主版本号,第二个数字为功能版本号,第三个数字为修订版本号:
| 文档版本号 | 修订日期 | 修订原因 | 修订人 |
|---|---|---|---|
| V1.2.1 | 2022.02.16 | 创建文档 | 段亚骏 |
| V1.3.1 | 2022.04.20 | 增加点查功能 | 刘杏 |
| V1.4.0 | 2022.06.07 | 增加拼音识别及词典查询 | 刘杏 |
| V1.4.1 | 2022.10.28 | 在第3.3.9小节中,增加英文自然拼读返回示例及参数说明 | 刘杏 |
| V1.4.2 | 2022.11.16 | 增加扫描返回拼接图片的功能,控制字段expStitchImage | 刘杏 |
| V1.4.3 | 2024.4.24 | 上传图片时增加不上传图片头的协议字段 | 刘秀丽 |
一、接口要求
1. 加密说明
为保证接口的安全性和稳定性,需要对接口数据进行加密;
- 加密必须包含的信息:APIkey,Secret(需通过图灵Biz平台 - 机器人信息页获取);
- 需针对请求参数中的Data字段,进行AES加密处理,具体加密方式如下:
| 参数 | 说明 | 备注 |
|---|---|---|
| 加密模式 | CBC | - |
| 填充 | PKCS5Padding | - |
| 数据块 | 128位(密钥为16位) | - |
| 密码 | secretKey | Apikey+Secret+时间戳(毫秒,与入参保持一致) 进行Md5加密,取16位小写值 |
| 偏移量 | secretKey | Apikey+Secret+时间戳(毫秒,与入参保持一致) 进行Md5加密,取16位小写值 |
| 输出 | base64编码 | - |
| 字符集 | utf-8 | - |
2. 接口说明
2.1 请求方法
正式环境:ws://ws-api.turingapi.com/api/v2
端口号:80
字符编码:UTF-8
2.2 通用请求示例
当biz平台开启加密时,使用该初始化示例请求socket服务:
{
"key": "ed474dae62*********67050faea1788",
"timestamp": "150******7793",
"service_identify": "scanPen",
"data": "加密后的内容"
}
当使用service_identify字段,为扫读笔场景时:
- 参数值只有是scanPen才会生效,输入其他值均为普通场景;
- 普通场景无法使用OCR能力,会提示OCR权限异常。
请求参数说明
| 参数 | 类型 | 是否必须 | 描述 |
|---|---|---|---|
| key | String | Y | 图灵biz平台申请的Apikey |
| timestamp | String | Y | 当前时间戳 |
| data | String | Y | 请求内容,需填写加密后的结果 |
| service_identify | String | Y | 场景模式 scanPen为扫读笔场景 |
2.3 通用返回示例
{
"code": xxx,
"done": false,
"globalId": "142648208233479001",
"message": "OCR文本分词结果"
}
返回参数说明
| 参数 | 类型 | 是否必返 | 说明 |
|---|---|---|---|
| code | int | Y | 状态code;参考状态code列表 |
| globalId | String | Y | 请求唯一标识,用于排查日志 |
| done | boolean | Y | 单轮请求是否结束 false为单轮请求未结束(云端还会返回结果) true为已结束(可进行下次请求或关闭连接) |
| message | String | Y | code对应的说明 |
| result | Json | N | 识别结果 |
请注意:
WebSocket不允许并发请求,即当done为false时(上一轮请求结果未完成),不允许发送下一个请求。
二、接入流程
title: 扫读笔请求流程:
participant client as l1
participant OpenSocket as l2
participant OCR Server as l3
participant TTS Server as l4
l1->l2: 初始化参数
l2->l3: 请求OCR服务
l3->l2: 初始化结果通知
l2->l1: 确认初始化完成
l1->l2: 上传图片片段...
l2->l3:图片片段1..图片片段2...
l1-->l2:上报结束标识
l3->l2: 返回OCR识别结果
l2-->l2: OCR识别结果请求分词服务
l2->l1: 返回OCR识别+分词结果
l2->l4: OCR文本请求TTS服务(需开启TTS权限)
l4->l2: 返回OCR文本的TTS结果
l2->l1: 返回OCR文本的TTS结果
l2-->l2: OCR识别结果请求词典技能
l2->l1: 返回查词结果
1.请求示例
1.1 初始化参数
{
"deviceId": "ai***3",
"requestType": ["NLP"],
"streamTts": "true",
"nlpRequest": {
"content": [{
"data": "23bf6bf2f5284449924999fceebc194a",
"type": 6
}],
"clientInfo": {
"appState": {
"code": 1000633,
"operateState": 1100
},
"robotSkill": {
"1000633": {
"dicts": ["cn_char", "cn_idiom", "cn_word", "en_word", "en_phrase"]
}
}
}
},
"ocr2TextRequest": {
"hardwareId": 10004,
"imageAngle": 60,
"rTextState": 10,
"model": 1
},
"binarysState": {
"openBinarysId": "23bf6bf2f5284449924999fceebc194a"
}
}
注意:
- 以上请求,需与图灵项目人员确认已开启OCR文本识别、词典、TTS技能;
- 在初始化请求时,如需上传图片文件,需在nlpRequest-content-data中用UUID作为上传文件的唯一标识;
- 在上传结束标识时,不需要nlpRequest、requestType、deviceId、asrRequest上传这些字段!否则云端会认为新建请求。
1.2 上传图片数据
初始化参数成功后,需上传图片二进制参数,数据格式由数据头 + 文本字节流 + 图片字节流组成,具体说明如下:
1.2.1 图片数据格式说明
- 上传图片需使用JPG格式(不支持其他格式)
- 图片大小建议在2kb以内
- 数据头采用大端优先模式
- type为1时 传图片不用传图片的头文件,初始化时需传头部文件base64字符串
1.2.2 文本字节流说明
文本字节流示例(最终转为二进制或十六进制):
{
"photoExposureMoment": 1212121,
"imgIndex": 1
}
参数说明
| 字段名称 | 类型 | 是否必填 | 介绍 |
|---|---|---|---|
| photoExposureMoment | long | Y | 拍照曝光时刻(当前时间戳,必须为毫秒级) |
| imgIndex | int | Y | 图片序号,编号从1开始 |
注意:时间戳不能使用“秒级时间戳 * 1000”的方式,需直接获取毫秒级时间戳,否则会导致云端拼接图片出现问题;
1.3 上报图片结束标识
data加密前数据格式:
{
"binarysState": {
"completeBinarysId": "23bf6bf2f5284449924999fceebc194a"
}
}
请注意:该结束标识加密后,需放入data字段中,与apikey、timestamp一起请求,参考加密请求示例;
2. 请求参数说明
data字段说明
| 参数 | 类型 | 是否必须 | 说明 |
|---|---|---|---|
| deviceId | String | Y | 用户设备Id: 由字母或数字组成,其他字符可能导致部分功能错误,长度等于16位 |
| requestType | Array | Y | 该次请求需要请求的内容:1:NLP,2:TTS |
| ocr2TextRequest | Json | Y | 请求OCR时需要的参数 |
| nlpRequest | Json | Y | nlp内容请求信息 |
| binarysState | Json | N | 二进制参数上传状态 |
| streamTts | boolean | N | tts是否以二进制流式输出(默认是false) 为true时,以二进制流式输出; 为false时,不以二进制流式输出 |
ocr2TextRequest
| 参数 | 类型 | 是否必须 | 说明 |
|---|---|---|---|
| hardwareId | long | Y | 摄像头标定后硬件ID 需要标定后填写; |
| imageAngle | Int | N | 扫描笔与桌面的角度(0-90度是右手,-90到0是左手), 目前右手是+60和左手是-60,默认角度为+60 |
| debug | Int | N | debug模式 0:关闭(默认),1:开启 |
| rTextState | Integer | N | 使用推荐查词结果 (默认为关闭推荐) 10:开启推荐 |
| model | int | N | 0:普通模式(扫读和点查);1:口算批改模式;3:拼音模式;4:古诗词模式;默认0 |
| expStitchImage | int | N | 是否输出拼接图 0:不输出(默认);1:输出图片+文本; 2:只输出拼接图片 |
| type | int | N | 0 正常模式 ;1 省流模式(此场景下imgHeadStr不能为空) 默认0 |
| imgHeadStr | string | N | 头部文件base64字符串 (type为1是必填) |
nlpRequest - content字段说明
| 参数 | 类型 | 是否必须 | 说明 |
|---|---|---|---|
| type | int | N | 输入类型: type=0为文本请求(默认) type=2为AI对话音频 type=5为口语评测音频 type=6为OCR识别 |
| data | String | Y | 当type=0,可直接输入文本内容 当type=其他值,需输入图片或音频的二进制参数:32位字符串(UUID) |
32位字符串(UUID):自己生成一个32位的唯一值进行上传就可以,主要作为上传文件的唯一标识;
nlpRequest - userInfo字段说明
| 参数 | 类型 | 是否必须 | 说明 |
|---|---|---|---|
| useCodes | Array | N | 此次交互只进入指定的技能(可指定多个技能) [1000018]为指定请求全文翻译 [1000633]为指定请求在线查词 |
补充说明:
- 只列出本协议相关的code,其他技能code可参照官网文档 http://docs.turingos.cn/api/apiV2/#turingos
nlpRequest - ClientInfo 字段说明
| 参数 | 类型 | 是否必须 | 说明 |
|---|---|---|---|
| appState | Json | N | 应用状态 |
| robotSkill | Json | N | 技能配置 |
ClientInfo - appState字段说明
| 参数 | 类型 | 是否必须 | 说明 |
|---|---|---|---|
| code | int | N | 技能code [1000633]为查词技能; |
| operateState | int | N | 应用状态 [1100]为扫读笔词典; |
ClientInfo - robotSkill字段说明
| 参数 | 类型 | 是否必须 | 说明 |
|---|---|---|---|
| 1000633 | Json | N | 需配置的技能code |
robotSkill - 1000633字段说明
| 参数 | 类型 | 是否必须 | 说明 |
|---|---|---|---|
| dictType | String | N | 词典类别优先级(默认为图灵词典) tuling为图灵词典 niujin为牛津词典 |
| dicts | array | N | 指定词典类型,则优先按词典类型查词,若字段为空,则按优先级顺序输出,默认顺序如下: 汉字(cn_char) 成语(cn_idiom) 汉词(cn_word) 英文单词(en_word) 英文短语(en_phrase) 无查词内容(others) 拼音(cn_pinyin) |
| > dictType和dicts可同时使用,当dictType为niujin时,查词内容优先进入牛津词典,若牛津词典未查到结果,则进入图灵词典,并按dicts字段指定的词典顺序进行查词; |
binarysState字段说明
| 参数 | 类型 | 是否必须 | 说明 |
|---|---|---|---|
| openBinarysId | String | N | 将要上传的文件参数:32位字符串 (该值与nlpRequest-content-data字段中的UUID一致) |
| completeBinarysId | String | Y | 已完成上传的文件参数:32位字符串 (该值与nlpRequest-content-data字段中的UUID一致) |
补充说明:
openBinarysId:在初始化时使用该字段,主要为了告知云端,将要上传一个二进制文件,需要云端准备接收;
completeBinarysId:在上报结束标识时使用该字段,主要为了告知云端,已上传完二进制文件,云端不需要再等待接收文件;
3. 返回示例及参数说明
3.1 OCR识别+分词结果(文本)
{
"code": 293,
"done": false,
"globalId": "142648208233479001",
"message": "OCR文本分词结果",
"result": {
"debugImgUrl": "http://universe-file.turingapi.com/scan-pen/debugImageOcrUrl_143343837246338001_2021-05-20-20-27-58.jpg",
"fps": "10",
"ocr2Text": "直到手术中才将",
"pwords": [{
"type": 2,
"w": "直到"
}, {
"type": 2,
"w": "手术"
}, {
"type": 0,
"w": "中"
}, {
"type": 0,
"w": "才"
}, {
"type": 0,
"w": "将"
}],
"uploadZipUrl": "http://universe-file.turingapi.com/scan_pen/69534782-20210520202753062.zip"
}
}
result字段说明
| 参数 | 类型 | 是否必返 | 说明 |
|---|---|---|---|
| ocr2Text | String | Y | OCR识别文本 |
| pword | array | Y | 分词结果 |
| uploadZipUrl | String | Y | 上传图片的压缩包(开启debug模式返回) |
| debugImgUrl | String | N | 云端拼接后的图片(开启debug模式返回) |
| fps | String | N | 1秒传输的图片数(开启debug模式返回) |
result - pword字段说明
| 参数 | 类型 | 是否必返 | 说明 |
|---|---|---|---|
| type | int | Y | 0:单词/汉字/连续数字 1:标点 2:短句/成语 |
| w | String | Y | 分词内容文本 |
| pos | String | N | 词性 |
| nc | array[pword] | N | 下层分词结果; |
目前分词结果为多层嵌套结构:
1.当获取到分词结果时,可直接从第一层json中获取分词文本,如”我“,”想“,”听“,”三国演义“;
2.获取分词文本时,可在同层级json中判断是否有nc字段,若有nc字段,则代表首次分词结果可继续分词,如“三国”,“演义”;如没有nc字段,则代表不能继续分词。其他层级依次类推。
3.2 OCR识别结果(TTS)
3.2.1 非流式TTS输出示例(当streamTts为默认值或false时)
{
"code": 291,
"done": false,
"globalId": "142648208233479001",
"message": "OCR文本TTS结果",
"result": {
"ocr2TextTts": ["http://turing-iot.oss-cn-beijing.aliyuncs.com/tts/tts-b79a94caa96e4e8692be89263cdbe82e-f26c102b440d4f36bd73875e2ee3a055.mp3"]
}
}
3.2.2 流式TTS输出示例 (当streamTts为true时)
- 当state=210,TTS流式传输开始
{
"code": 260,
"done": false,
"globalId": "156366860964973001",
"message": "TTS流式传输状态",
"ttsResponse": {
"binarysId": "c4609faf7ad44686bb271145c7af7e5b",
"state": 210,
"value": "Together for a long time, two people's personalities will gradually complement each other"
}
}
- 当state=200,TTS传输结束
{
"code": 260,
"done": false,
"globalId": "156366860964973001",
"message": "TTS流式传输状态",
"ttsResponse": {
"binarysId": "c4609faf7ad44686bb271145c7af7e5b",
"state": 200,
"value": "Together for a long time, two people's personalities will gradually complement each other"
}
}
TTS流式输出说明
- 输入参数中streamTts=true;
- 流式TTS目前输出的音频仅支持MP3格式;
- 设备端收到TTS传输开始标识后,云端开始分段下发二进制音频数据,当所有音频传输完成,云端会再次下发TTS传输结束标识,告知设备端传输结束;
ttsResponse参数说明
| 参数 | 类型 | 是否必须 | 说明 |
|---|---|---|---|
| binarysId | String | Y | TTS二进制参数Id,与ttsStreamId参数一致 |
| value | String | Y | TTS文本内容 |
| state | int | Y | state=210时,TTS传输开始 state=200时,TTS传输正确结束 state=400时,TTS异常结束 |
3.3 查词结果
3.3.1 汉字
{
"code": 200,
"done": true,
"globalId": "157336052169908001",
"message": "success",
"nlpResponse": {
"intent": {
"code": 1000633,
"operateState": 1010,
"parameters": {
"result": {
"dict": "cn_char",
"dictType": "tuling",
"info": {
"radicalsAudio": "http://book-iot-cdn.turingos.cn/202110291941/1cf8d3a47ee9a7f3070118298054d0da/dictV2/6511f3c85bea1dae46b4aba0a3895103.mp3",
"strokesNumAudio": "http://universe-file-limit.turingapi.com/202110291911/92122374c56aacb2f63d4b0eb0325bd3/dict/ca2159e08562402096c0e76d56e8b7b3.mp3",
"isCollect": false,
"copy": ["http://book-iot-cdn.turingos.cn/202110291941/0f0e4474bcc0c664580b277a8dcfbf6a/svg/svg-gif/allgif100/21644.gif"],
"polyphone": [{
"pinyin": "hé",
"explanations": ["相安,谐调", "平静", "平息争端", "数学上指加法运算中的得数", "连带", "连词,跟,同", "介词,向,对", "指日本国", "体育比赛不分胜负的结果", "姓"],
"audio": "http://universe-file-limit.turingapi.com/202110291911/cb4386ca3f5dcf1a3911e9348beee43d/dict/cn_char/99da7cfadfe14016b0694e65334759a3.mp3",
"combineWords": [{
"type": "start",
"word": "和睦"
}, {
"type": "start",
"word": "和衷共济"
}, {
"type": "start",
"word": "和气"
}, {
"type": "start",
"word": "和合"
}, {
"type": "start",
"word": "和美"
}, {
"type": "end",
"word": "祥和"
}, {
"type": "start",
"word": "和平"
}, {
"type": "start",
"word": "和谐"
}, {
"type": "start",
"word": "和声"
}, {
"type": "end",
"word": "温和"
}]
}, {
"pinyin": "hè",
"explanations": ["和谐地跟着唱", "依照别人的诗词的题材或体裁作诗词"],
"audio": "http://universe-file-limit.turingapi.com/202110291911/641733c5f9fbc54dbffb4408cfe21512/dict/cn_char/54af0fab7cd141ebb7ac336512e1927a.mp3",
"combineWords": [{
"type": "middle",
"word": "曲高和寡"
}, {
"type": "start",
"word": "和诗"
}, {
"type": "end",
"word": "一唱一和"
}]
}, {
"pinyin": "huò",
"explanations": ["粉状或粒状物搀和在一起,或加水搅拌", "量词,指洗衣服换水的次数或一剂药煎的次数"],
"audio": "http://universe-file-limit.turingapi.com/202110291911/af69d5455e4e3952019314d6a8962bc6/dict/cn_char/b74ab187ec104aaf81e4e474321fd12c.mp3",
"combineWords": [{
"type": "start",
"word": "和药"
}, {
"type": "start",
"word": "和弄"
}, {
"type": "start",
"word": "和稀泥"
}]
}, {
"pinyin": "huó",
"explanations": ["在粉状物中搅拌或揉弄使粘在一起"],
"audio": "http://universe-file-limit.turingapi.com/202110291911/c257dcfe5363ad80b62e576ceafc741e/dict/cn_char/978f2aa2a92546058911365c46b606fa.mp3",
"combineWords": [{
"type": "start",
"word": "和面"
}, {
"type": "start",
"word": "和泥"
}]
}, {
"pinyin": "hú",
"explanations": ["打麻将或斗纸牌时某一家的牌合乎规定的要求,取得胜利"],
"audio": "http://universe-file-limit.turingapi.com/202110291911/5c5b822edd9efb02618e5b949b6e3a2c/dict/cn_char/37302e8707fe479f89e25dafda12ea26.mp3"
}],
"radicalsText": "口字旁",
"strokesNumText": "共八画",
"wordAudio": "http://universe-file-limit.turingapi.com/202110291911/cb4386ca3f5dcf1a3911e9348beee43d/dict/cn_char/99da7cfadfe14016b0694e65334759a3.mp3",
"word": "和",
"strokesNum": "8",
"structure": "左右结构"
}
},
"content": "和"
}
}
}
}
nlpResponse - Intent字段说明
| 参数 | 类型 | 是否必返 | 说明 |
|---|---|---|---|
| code | int | Y | 输出应用code |
| operateState | int | Y | 应用状态(每个应用单独定义) |
| parameters | Json | Y | 识别结果参数 |
输出应用code可参照官网文档 http://docs.turingos.cn/api/apiV2/#turingos
Intent - parameters字段说明
| 参数 | 类型 | 是否必返 | 说明 |
|---|---|---|---|
| result | Json | Y | 查词结果 |
| content | String | Y | 查词内容 |
parameters - result字段说明
| 参数 | 类型 | 是否必返 | 说明 |
|---|---|---|---|
| dictType | String | Y | 词典类别 tuling为图灵词典 niujin为牛津词典 |
| dict | String | Y | 图灵词典类型 汉字(cn_char) 成语(cn_idiom) 古诗词(cn_poem) 历史人名(cn_word_person) 汉词(cn_word) 英文单词(en_word) 英文短语(en_phrase) 无查词内容(others) |
| info | Json | Y | 查词信息,参考以下各词典类型字段; |
results 字段说明
| 参数 | 类型 | 是否必返 | 说明 |
|---|---|---|---|
| group | Int | N | 组类型(文本接入可忽略该参数): 0为独立输出; 大于0时可能包含同组相关内容 |
info 字段说明
| 参数 | 类型 | 是否必返数据 | 描述 |
|---|---|---|---|
| word | String | Y | 汉字 |
| polyphone | List |
N | 多音字 |
| wordAudio | String | N | 汉字音频 |
| strokesNum | String | N | 笔画数 |
| structure | String | N | 结构 |
| radicals | String | N | 偏旁 |
| radicalsText | String | N | 偏旁用于tts的文本 |
| radicalsAudio | String | N | 偏旁tts |
| strokesNumText | String | N | 笔画数用于tts的文本 |
| strokesNumAudio | String | N | 笔画数tts |
| copy | List |
N | 描红 |
| isCollect | boolean | Y | 收藏标识 |
polyphone字段说明
| 参数 | 类型 | 是否必返数据 | 描述 |
|---|---|---|---|
| pinyin | String | Y | 多音字读音 |
| audio | String | Y | 多音字音频 |
| combineWords | Array | N | 组词 |
| explanations | Array | Y | 多音字释义 |
combineWords字段说明
| 参数 | 类型 | 是否必返数据 | 描述 |
|---|---|---|---|
| type | String | Y | 组词类型 |
| word | Array | Y | 组词 |
3.3.2 成语
{
"code": 200,
"done": true,
"globalId": "157336013624908001",
"message": "success",
"nlpResponse": {
"intent": {
"code": 1000633,
"operateState": 1010,
"parameters": {
"result": {
"dict": "cn_idiom",
"dictType": "tuling",
"info": {
"pinyin": "héng săo qiān jūn",
"examples": [{
"cn": "李自成的队伍不断壮大,真是兵强马壮,横扫千军,声威大震。"
}, {
"cn": "蒙古铁骑以横扫千军之势,几乎荡平了欧洲。"
}, {
"cn": "七百里驱十五日,赣水苍茫闽山碧,横扫千军如席卷。"
}],
"synonyms": ["风卷残云"],
"antonyms": ["溃不成军", "丢盔卸甲"],
"isCollect": false,
"explanations": ["横扫:扫荡、扫除。把大量敌军象扫地似地一阵子扫除掉"],
"copy": ["http://book-iot-cdn.turingos.cn/202110291940/bbfdad28224f58a04a7e3bdaed35599c/svg/svg-gif/allgif100/27178.gif", "http://book-iot-cdn.turingos.cn/202110291940/9a7f4dd382bf3d4288734efef7133164/svg/svg-gif/allgif100/25195.gif", "http://book-iot-cdn.turingos.cn/202110291940/13dfb2d61e6af794fdcf18d094faa5bc/svg/svg-gif/allgif100/21315.gif", "http://book-iot-cdn.turingos.cn/202110291940/20140f8070dd35e80f83e41aacdccb67/svg/svg-gif/allgif100/20891.gif"],
"wordAudio": "http://universe-file-limit.turingapi.com/202110291910/10731cfc516bd2353415c089c770b888/dict/40226f68638749c0949d476b5cf28e40.mp3",
"word": "横扫千军"
}
},
"content": "横扫千军"
}
}
}
}
info 字段说明
| 参数 | 类型 | 是否必返数据 | 描述 |
|---|---|---|---|
| word | String | Y | 成语 |
| pinyin | String | N | 拼音 |
| examples | List |
N | 中英例句 |
| explanations | List |
N | 释义 |
| wordAudio | String | N | 成语音频 |
| synonyms | List |
N | 近义词 |
| antonyms | List |
N | 反义词 |
| copy | List |
N | 描红 |
| isCollect | boolean | Y | 收藏标识 |
example字段说明
| 参数 | 类型 | 是否必返数据 | 描述 |
|---|---|---|---|
| cn | String | Y | 中文 |
3.3.3 汉词
{
"code": 200,
"done": true,
"globalId": "157336776838908001",
"message": "success",
"nlpResponse": {
"intent": {
"code": 1000633,
"operateState": 1010,
"parameters": {
"result": {
"dict": "cn_word",
"dictType": "tuling",
"info": {
"isCollect": false,
"copy": ["http://book-iot-cdn.turingos.cn/202110291953/ebfbc1a351714c9b56ed4c9dfee35861/svg/svg-gif/allgif100/32654.gif", "http://book-iot-cdn.turingos.cn/202110291953/d2c91dd479b762433f5e0edc4ff572a3/svg/svg-gif/allgif100/20029.gif"],
"polyphone": [{
"pinyin": "měi lì",
"examples": [{
"cn": "民间流传着很多美丽的神话传说。"
}, {
"cn": "张老师绘声绘色地讲着美丽的桂林山水的景色,听的同学们引人入胜。"
}, {
"cn": "冬爷爷呼啸着给万物披上雪白的绒袄,在窗上印下一朵朵美丽的冰花。"
}],
"synonyms": ["俊俏", "秀美", "美观", "美貌", "俏丽", "优美", "美艳", "俊美"],
"antonyms": ["难看", "丑陋", "丑恶"],
"explanations": ["使人看了产生快感的;好看"],
"audio": "http://universe-file-limit.turingapi.com/202110291923/60febeb9beb8616bbd69657788739b8d/dict/cn_word/a7447ff2a56d44529e384e3d43b24b1a.mp3"
}],
"wordAudio": "http://universe-file-limit.turingapi.com/202110291923/60febeb9beb8616bbd69657788739b8d/dict/cn_word/a7447ff2a56d44529e384e3d43b24b1a.mp3",
"word": "美丽"
}
},
"content": "美丽"
}
}
}
}
info 字段说明
| 参数 | 类型 | 是否必返数据 | 描述 |
|---|---|---|---|
| word | String | Y | 词语 |
| polyphone | List |
N | 多音字 |
| wordAudio | String | N | 词语音频 |
| copy | List |
N | 描红 |
| isCollect | boolean | Y | 收藏标识 |
Polyphone字段说
| 参数 | 类型 | 是否必返数据 | 描述 |
|---|---|---|---|
| pinyin | String | Y | 拼音 |
| synonyms | List |
Y | 近义词 |
| antonyms | List |
N | 反义词 |
| examples | List |
Y | 中英例句 |
| explanations | List |
Y | 释义 |
| audio | String | Y | 多音字音频 |
example字段说明
| 参数 | 类型 | 是否必返数据 | 描述 |
|---|---|---|---|
| cn | String | Y | 中文 |
3.3.4 英文单词
{
"code": 200,
"done": true,
"globalId": "157336911720908001",
"message": "success",
"nlpResponse": {
"intent": {
"code": 1000633,
"operateState": 1010,
"parameters": {
"result": {
"dict": "en_word",
"dictType": "tuling",
"info": {
"phoneticEn": "wiːk",
"presentParticiple": "",
"phoneticUsAudio": "http://universe-file-limit.turingapi.com/202110291925/becf5168dc07c1e11a929029f90cc42a/dict/en_word_us/3e772d6a0f1447ad8395dd1f591dbc8f.mp3",
"isCollect": false,
"verb": "",
"wordAudio": "http://book-iot-cdn.turingos.cn/202110291955/378130a716850987c058f9069a843283/dictV2/172a8327fcd3685ab3c0f740d031da09.mp3",
"superlativeDegree": "",
"thirdSingular": "",
"adjective": "",
"examples": [{
"en": "A week passed quickly.",
"cn": "一个星期很快地过去了。"
}, {
"en": "He begged a week off.",
"cn": "他请了一星期的假。"
}, {
"en": "May Day is only a week off.",
"cn": "离“五一”节只一星期了。"
}],
"phoneticUs": "wiːk",
"pastParticiple": "",
"explanations": [{
"pos": "n",
"meaning": "星期;周"
}],
"preterit": "",
"nounPlurals": "weeks ",
"word": "week",
"comparativeDegree": "",
"phoneticEnAudio": "http://universe-file-limit.turingapi.com/202110291925/32c3bbf1657c94d9dc2937ad1d208a3c/dict/en_word_en/e63f10de20b64c94ba6b183283a9c324.mp3"
}
},
"content": "week"
}
}
}
}
英文单词支持口语评测功能,当设备端输出在线查词结果时,可在设备端显示录音按键,触发口语评测功能,具体协议可见【口语评测说明文档】
info 字段说明
| 参数 | 类型 | 是否必返数据 | 描述 |
|---|---|---|---|
| word | String | Y | 单词 |
| phoneticEn | String | N | 英音标 |
| thirdSingular | String | N | 第三人称单数 |
| adjective | String | N | 形容词 |
| verb | String | N | 动词 |
| superlativeDegree | String | N | 最高级 |
| presentParticiple | String | N | 现在分词 |
| phoneticUs | String | N | 美音标 |
| pastParticiple | String | N | 过去分词 |
| nounPlurals | String | N | 名词复数 |
| wordAudio | String | N | 单词音频 |
| comparativeDegree | String | N | 比较级 |
| phoneticEnAudio | String | N | 英音标音频 |
| phoneticUsAudio | String | N | 美音标音频 |
| preterit | String | N | 过去式 |
| explanations | List |
N | 释义 |
| examples | List |
N | 中英例句 |
| isCollect | boolean | Y | 收藏标识 |
example字段说明
| 参数 | 类型 | 是否必须 | 描述 |
|---|---|---|---|
| en | String | Y | 英文 |
| cn | String | Y | 中文 |
explanations字段说明
| 参数 | 类型 | 是否必返数据 | 描述 |
|---|---|---|---|
| pos | String | Y | 词性 |
| meaning | String | Y | 汉语释义 |
3.3.5 英文短语
{
"code": 200,
"done": true,
"globalId": "157338134027908001",
"message": "success",
"nlpResponse": {
"intent": {
"code": 1000633,
"operateState": 1010,
"parameters": {
"result": {
"dict": "en_phrase",
"dictType": "tuling",
"info": {
"examples": [{
"en": "How are you fixed for cash?",
"cn": "你有多少现金?"
}, {
"en": "How are you Lennox? Good to see you up and about.",
"cn": "伦诺克斯你好吗? 真高兴看到你恢复正常活动了。"
}, {
"en": "Howdy, how are you all doing?",
"cn": "你好,你们都好吗?"
}],
"phrase": "how are you",
"isCollect": false,
"explanations": ["你好"],
"wordAudio": ""
}
},
"content": "how are you"
}
}
}
}
英文短语支持口语评测功能,当设备端输出在线查词结果时,可在设备端显示录音按键,触发口语评测功能,具体协议可见【口语评测说明文档】
info 字段说明
| 参数 | 类型 | 是否必返数据 | 描述 |
|---|---|---|---|
| phrase | String | Y | 短语内容 |
| examples | List |
N | 双语例句 |
| explanations | List |
N | 释义 |
| isCollect | boolean | Y | 收藏标识 |
| wordAudio | String | N | 短语音频 |
example字段说明
| 参数 | 类型 | 是否必返数据 | 描述 |
|---|---|---|---|
| en | String | Y | 英文 |
| cn | String | Y | 中文 |
3.3.6 牛津词典
{
"code": 200,
"done": true,
"globalId": "154480613972195001",
"message": "success",
"nlpResponse": {
"intent": {
"code": 1000633,
"operateState": 1010,
"parameters": {
"result": {
"operation": "",
"oxfordVersion": 4,
"dictType": "niujin",
"info": [{
"entry": [{
"sn-gs": [{
"sn-g": []
}]
}],
"anagram": [
"be 的过去式 "
],
"or-wd": [
"be"
],
"h": [
"was"
],
"pron-gs": [{
"geo": "英",
"audioUrl": "http://book-iot-cdn.turingos.cn/202202172010/9715c4d8a99f0122c474ab79e429dbf8/dict/niujin/niujin_data/Headwordaudio/W/was%23_gb_1.mp3",
"phon": "wəz",
"audio": "was#_gb_1"
},
{
"geo": "美",
"audioUrl": "http://book-iot-cdn.turingos.cn/202202172010/0882089d5bbac395cb6f719b22f7fd10/dict/niujin/niujin_data/Headwordaudio/W/was%23_us_3_rr.mp3",
"phon": "wəz",
"audio": "was#_us_3_rr"
}
],
"vp-gs": [{
"pastpart": "过去分词 been"
},
{
"past": "过去式 was"
},
{
"thirdps": "第三人称单数 is"
},
{
"prespart": "现在进行时 being"
}
],
"infl-g": [
"was"
]
}]
},
"content": "was"
}
}
}
info 字段说明
| 参数 | 类型 | 是否必返 | 说明 |
|---|---|---|---|
| h | string | Y | 单词文本 |
| infl-g | array | Y | 单词所有变形 |
| pos-g | array | Y | 单词所有词性 |
| label-g | array | Y | 单词标识,包括语体、地理、学科标识 |
| gram-g | string | Y | 单词的语法说明 |
| vp-gs | array | Y | 单词变形的具体说明 |
| v-gs | array | Y | 单词的变体 |
| Ox-aw | array | Y | 用于说明单词是否属于牛津3000词或学术用词 |
| anagram | array | Y | 原词的其他变形词 |
| or-wd | array | Y | 原词文本 |
| pron-gs | array | N | 单词音标及发音 |
| ...geo | string | N | 用于说明是英式还是美式发音 |
| ...phon | string | N | 单词音标 |
| ...audio | string | N | 单词发音 |
| entry | array | N | 单词详细信息 |
| ...pos-g | string | N | 单词的某个词性 |
| ...sn-gs | array | N | 该词性下的单词释义及例句 |
| ......shcut | array | N | 用于说明该单词的释义的类别或范围 |
| .........en | string | N | 英文说明 |
| .........cn | string | N | 中文说明 |
| ......sn-g | array | N | 单词的一条释义 |
| .........gram-g | string | N | 单词某个释义的语法 |
| .........cf | array | N | 单词在某个或某个释义的用法 |
| .........dis-g | array | N | 对在该释义在的用法进一步说明 |
| .........v-gs | array | N | 单词在某个释义下的变体 |
| .........xr-gs | array | N | 释义的参见项 |
| .........label-g | array | N | 释义的语体、地理、学科标识 |
| .........def | array | N | 释义 |
| ............en | string | N | 英文释义 |
| ............cn | string | N | 中文释义 |
| .........x-gs | array | N | 这几种用法的例句 |
| ............cf | array | N | 单词在某个例句中的用法 |
| ............en | string | N | 英文例句 |
| ............cn | string | N | 例句中文翻译 |
| ............pron-gs | array | N | 例句发音 |
| ...............geo | string | N | 用于说明是英式还是美式发音 |
| ...............audio | string | N | 例句音频 |
| ...pv-gs | array | N | 该词性下的短语动词组 |
| ......pv | array | N | 短语动词 |
| ......v-gs | array | N | 短语的变体 |
| ......sn-gs | array | N | 该短语动词的解释及例句 |
| .........v-gs | array | N | 在某个释义下的变体 |
| .........xr-gs | array | N | 短语在某个释义下的参见项 |
| .........label-g | array | N | 短语标识,用于说明其语体、地理、学科 |
| .........def | array | N | 该短语动词的解释 |
| ............en | string | N | 英文解释 |
| ............cn | string | N | 中文解释 |
| .........x-gs | array | N | 该短语动词的例句 |
| ............label-g | array | N | 该句子的地理、语体、学科标识 |
| ............en | string | N | 英文例句 |
| ............cn | string | N | 例句的中文翻译 |
| ............pron-gs | array | N | 例句的发音 |
| ...............geo | string | N | 用于说明是英式还是美式发音 |
| ...............audio | string | N | 例句音频 |
| ...idm-gs | array | N | 该词性下的习语组 |
| ......xr-gs | array | N | 习语的参见项 |
| .........idm-g | array | N | 习语的信息 |
| ............idm | array | N | 习语 |
| ............v-gs | array | N | 习语的变体 |
| ............sn-gs | array | N | 习语的解释和例句 |
| ...............def | array | N | 习语的解释 |
| ..................en | string | N | 英文解释 |
| ..................cn | string | N | 中文解释 |
| ...............x-gs | array | N | 习语的例句 |
| ..................en | string | N | 英文例句 |
| ..................cn | string | N | 例句的中文翻译 |
| ..................pron-gs | array | N | 例句的发音 |
| .....................geo | string | N | 用于说明是英式还是美式发音 |
| .....................audio | string | N | 例句音频 |
| ...dr-gs | array | N | 派生词信息 |
| ......dr | array | N | 派生词 |
| ......v-gs | array | N | 派生词变体 |
| ......pos-g | array | N | 派生词词性 |
| ......infl-g | array | N | 派生词的变形 |
| ......pron-gs | array | N | 派生词音标及发音 |
| .........geo | string | N | 用于说明是英式还是美式发音 |
| .........phon | string | N | 派生词的音标 |
| .........audio | string | N | 派生词的发音 |
| ......sn-gs | array | N | 派生词的其他信息 |
| .........gram-g | string | N | 派生词的语法说明 |
| .........xr-gs | array | N | 习语的参见项 |
| .........x-gs | array | N | 派生词的例句 |
| ............cf | array | N | 派生词在某个例句中的用法 |
| ............label-g | array | N | 派生词的语体、地理、学科标识 |
| ............en | string | N | 英文例句 |
| ............cn | string | N | 例句的中文翻译 |
| ............pron-gs | array | N | 例句的发音 |
| ...............geo | string | N | 用于说明是英式还是美式发音 |
| ...............audio | string | N | 例句音频 |
3.3.7 附加词典
汉英词典
{
"code": 200,
"done": true,
"globalId": "160787403240804001",
"message": "success",
"nlpResponse": {
"intent": {
"code": 1000633,
"operateState": 1010,
"parameters": {
"result": {
"dict": "cn_char",
"otherDicts": {
"dict": "cn_transl_en",
"info": {
"items": [{
"star": 3,
"pos": "名词",
"reversedTranslation": "日, 天, 日子, 白天, 昼, 旦",
"translation": "day"
}, {
"star": 2,
"pos": "名词",
"reversedTranslation": "天空, 天, 空, 霄, 过分地",
"translation": "sky"
}, {
"star": 1,
"pos": "名词",
"reversedTranslation": "上帝, 天, 老天爷, 菩萨",
"translation": "God"
}, {
"star": 1,
"pos": "名词",
"reversedTranslation": "天, 过分地",
"translation": "heavens"
}, {
"star": 1,
"pos": "名词",
"reversedTranslation": "性质, 自然, 性, 本质, 大自然, 天",
"translation": "nature"
}, {
"star": 1,
"pos": "副词",
"reversedTranslation": "天, 在楼上, 在上边",
"translation": "overhead"
}, {
"star": 1,
"pos": "名词",
"reversedTranslation": "季节, 季, 时节, 时令, 令, 天",
"translation": "season"
}, {
"star": 1,
"pos": "名词",
"reversedTranslation": "天气, 天, 气",
"translation": "weather"
}],
"word": "天"
}
},
"dictType": "tuling",
"info": {
"radicalsAudio": "http://book-iot-cdn.turingos.cn/202112081823/54b9eac9e09f1a07724a074a156d7327/dictV2/93dd7d6e9effdea7478c910664ff1edf.mp3",
"radicals": "大",
"strokesNumAudio": "http://universe-file-limit.turingapi.com/202112081753/62c09a9b212efa965c46e9f10fe3d1cf/dict/ac27e8f189d5425f91e44ea3d9cff369.mp3",
"isCollect": false,
"copy": ["http://book-iot-cdn.turingos.cn/202112081823/927afc40a7695d873a945e22a10454c8/svg/svg-gif/allgif100/22825.gif"],
"polyphone": [{
"pinyin": "tiān",
"explanations": ["在地面以上的高空", "在上面", "气候", "季节,时节", "日,一昼夜,或专指昼间", "指神仙或他们所住的地方", "自然界", "[天干]古代用来记日或年的字,有“天干”和“地支”两类,天干共十字", "自然的、生成的"],
"audio": "http://universe-file-limit.turingapi.com/202112081753/8c81c7a021209432a2bdab09fb8e8ca3/dict/cn_char/e7abf46685a048ce9dc448081db706b5.mp3",
"combineWords": [{
"type": "start",
"word": "天头"
}, {
"type": "start",
"word": "天气"
}, {
"type": "start",
"word": "天罡"
}, {
"type": "start",
"word": "天冷"
}, {
"type": "end",
"word": "今天"
}, {
"type": "start",
"word": "天际"
}, {
"type": "end",
"word": "冬天"
}, {
"type": "start",
"word": "天空"
}, {
"type": "start",
"word": "天马行空"
}]
}],
"radicalsText": "大字头",
"strokesNumText": "共四画",
"wordAudio": "http://universe-file-limit.turingapi.com/202112081753/8c81c7a021209432a2bdab09fb8e8ca3/dict/cn_char/e7abf46685a048ce9dc448081db706b5.mp3",
"word": "天",
"strokesNum": "4",
"structure": "上下结构"
}
},
"content": "天"
}
}
}
}
parameters - result字段说明
| 参数 | 类型 | 是否必返 | 说明 |
|---|---|---|---|
| dictType | String | Y | 词典类别 |
| dict | String | Y | 图灵词典类型 |
| info | Json | Y | 查词信息,参考以下各词典类型字段; |
| otherDicts | Json | N | 附加词典 cn_transl_en 为汉英词典 |
附加词典说明:
1.目前附加词典由云端控制权限,无需设备端通过字段请求;
2.开启附加词典权限后,若请求内容进入图灵字/词典且同时命中附加词典,则返回2个词典结果(图灵字/词典+附加词典);
3.若请求内容进入词典后,并未命中附加词典,则只返回查词结果或无查词结果(others),不返回附加词典。
otherDicts 字段说明
| 参数 | 类型 | 是否必须 | 描述 |
|---|---|---|---|
| dict | String | N | 词典名称 |
| info | Json | N | 词典数据集 |
info 字段说明
| 参数 | 类型 | 是否必须 | 描述 |
|---|---|---|---|
| items | List |
N | 词典数据列表 |
| word | String | N | 查询的内容 |
items字段说明
| 参数 | 类型 | 是否必须 | 描述 |
|---|---|---|---|
| pos | String | N | 英文词性 |
| reversedTranslation | String | N | 中文释义 |
| translation | String | N | 汉译英 |
3.3.8 无查词结果
- 文本无查词结果
{
"code": 200,
"done": true,
"globalId": "156458198449143001",
"message": "success",
"nlpResponse": {
"intent": {
"code": 1000633,
"operateState": 1010,
"parameters": {
"result": {
"dict": "others",
"dictType": "tuling",
"info": {
"translation": "It was not until the operation that",
"word": "直到手术中才将"
}
},
"content": "直到手术中才将"
}
},
"results": [{
"groupType": 0,
"resultType": "text",
"values": {
"ttsUrl": ["http://turing-iot.oss-cn-beijing.aliyuncs.com/tts/tts-c683408b68654d4dac779a0f262a5d45-fc00d68d94734dfbba8681af82b009a7.mp3"],
"text": "It was not until the operation that"
}
}]
}
}
- 拼音无查词结果
{
"code": 200,
"done": true,
"globalId": "156458242866143001",
"message": "success",
"nlpResponse": {
"intent": {
"code": 1000633,
"operateState": 1010,
"parameters": {
"result": {
"dict": "others",
"dictType": "tuling",
"info": {
"word": "dà jiā hǎo"
}
},
"content": "dà jiā hǎo"
}
},
"results": [{
"groupType": 0,
"resultType": "text",
"values": {}
}]
}
}
当扫描内容为拼音时,TTS会返回拼音音频,但查词结果和翻译会返回为空,设备端可不展示拼音查词内容;
- 英文长句无查词结果
{
"code": 200,
"done": true,
"globalId": "158428712483981001",
"message": "success",
"nlpResponse": {
"intent": {
"code": 1000633,
"operateState": 1010,
"parameters": {
"result": {
"oralTestState": 1101,
"dict": "others",
"dictType": "tuling",
"info": {
"translation": "你好你在做什么",
"word": "hello what are you doing"
}
},
"content": "hello what are you doing"
}
},
"results": [{
"groupType": 0,
"resultType": "text",
"values": {
"text": "你好你在做什么"
}
}]
}
}
当云端在无词典结果中,下发英文长句标识位oralTestState字段时,可在设备端显示录音按键,触发口语评测功能。评测请求类别为英文句子(1101),具体协议可见【口语评测说明文档】
parameters - result字段说明
| 参数 | 类型 | 是否必返数据 | 说明 |
|---|---|---|---|
| dict | String | Y | 词典类型 |
| info | Array | Y | 查词结果信息 |
| dictType | String | Y | 词典类别 tuling为图灵词典 niujin为牛津词典 |
| oralTestState | Int | N | 英文长句标识位 1100:英文单词 1101:英文句子 |
info 字段说明
| 参数 | 类型 | 是否必返数据 | 描述 |
|---|---|---|---|
| word | String | Y | 待查词内容 |
| translation | String | Y | 翻译内容 |
3.3.9 英文自然拼读
请求图灵词典
{
"code": 200,
"done": true,
"globalId": "188758106726622001",
"message": "success",
"nlpResponse": {
"intent": {
"code": 1000633,
"operateState": 1010,
"parameters": {
"result": {
"naturalSpell": {
"phoneticSymbol": "æpl",
"audio": "http://universe-file-limit.turingapi.com/202210281127/e67578db6c0a7503a8093f57d949976a/dict/73adf709315148cb89f1eb34816c5e61.mp3",
"phoneticLetters": [{
"phoneticSymbol": "'æ",
"letter": "a",
"phoneticSymbolAudio": "http://universe-file-limit.turingapi.com/202210281127/81406b6e01cd8e024e0b2ff06e8ba859/dict/29958271416d42d2aaf9dcc40dc8eedf.mp3"
}, {
"phoneticSymbol": "p",
"letter": "pp",
"phoneticSymbolAudio": "http://universe-file-limit.turingapi.com/202210281127/4ef8d667282c4f81bddf716b1d75490c/dict/ce2ed741b6ca4d7893743c5584019abe.mp3"
}, {
"phoneticSymbol": "l",
"letter": "le",
"phoneticSymbolAudio": "http://universe-file-limit.turingapi.com/202210281127/a701d3b3bc7934a5b1af28d82c5ed149/dict/9b640ace8e854bb7af4266d6592509fb.mp3"
}
],
"word": "apple"
},
"oralTestState": 1100,
"dict": "en_word",
"dictType": "tuling",
"info": {
"phoneticEn": "ˈæpl",
"presentParticiple": "",
"phoneticUsAudio": "http://universe-file-limit.turingapi.com/202210281132/9e4a3a5a2ac92fadf809f0950163c010/dict/en_word_us/7a5e3ef8c8854ee69d3484e5832a1a7e.mp3",
"isCollect": false,
"verb": "",
"wordAudio": "http://book-iot-cdn.turingos.cn/202210281202/464bc3a0dacb2bfc003cafa41ba0cad4/dictV2/1f3870be274f6c49b3e31a0c6728957f.mp3",
"superlativeDegree": "",
"thirdSingular": "",
"adjective": "",
"examples": [{
"en": "Cut the apple in half.",
"cn": "把苹果切成两半。"
}, {
"en": "Have an apple of our own growth.",
"cn": "尝一尝我们自己种的苹果吧。"
}
],
"phoneticUs": "ˈæpl",
"pastParticiple": "",
"explanations": [{
"pos": "n",
"meaning": "苹果"
}, {
"pos": "n",
"meaning": "形似苹果的果实"
}, {
"pos": "n",
"meaning": "炸弹;手榴弹;(棒球的)球"
}, {
"pos": "n",
"meaning": "人,家伙"
}
],
"preterit": "",
"nounPlurals": "apples",
"word": "apple",
"comparativeDegree": "",
"phoneticEnAudio": "http://universe-file-limit.turingapi.com/202210281132/2f5c90de455884da706fa92957d4a7fa/dict/en_word_en/e3ef52091f9b4cedb4c33a21e8010075.mp3"
}
},
"content": "apple"
}
}
}
}
请求牛津词典
{
"code": 200,
"done": true,
"globalId": "188758659407622001",
"message": "success",
"nlpResponse": {
"intent": {
"code": 1000633,
"operateState": 1011,
"parameters": {
"result": {
"naturalSpell": {
"phoneticSymbol": "æpl",
"audio": "http://universe-file-limit.turingapi.com/202210281127/e67578db6c0a7503a8093f57d949976a/dict/73adf709315148cb89f1eb34816c5e61.mp3",
"phoneticLetters": [{
"phoneticSymbol": "'æ",
"letter": "a",
"phoneticSymbolAudio": "http://universe-file-limit.turingapi.com/202210281127/81406b6e01cd8e024e0b2ff06e8ba859/dict/29958271416d42d2aaf9dcc40dc8eedf.mp3"
}, {
"phoneticSymbol": "p",
"letter": "pp",
"phoneticSymbolAudio": "http://universe-file-limit.turingapi.com/202210281127/4ef8d667282c4f81bddf716b1d75490c/dict/ce2ed741b6ca4d7893743c5584019abe.mp3"
}, {
"phoneticSymbol": "l",
"letter": "le",
"phoneticSymbolAudio": "http://universe-file-limit.turingapi.com/202210281127/a701d3b3bc7934a5b1af28d82c5ed149/dict/9b640ace8e854bb7af4266d6592509fb.mp3"
}
],
"word": "apple"
},
"operation": "",
"oxfordVersion": 4,
"dictType": "niujin",
"info": [{
"pos-g": ["noun"],
"entry": [{
"pos-g": "noun",
"idm-gs": [{
"idm-g": {
"idm": ["the apple doesn’t fall/never falls far from the ˈtree"],
"sn-gs": [{
"sn-g": [{
"def": [{
"en": "a child usually behaves in a similar way to his or her parent(s)",
"cn": "有什么样的父母就有什么样的儿女;上行下效"
}
],
"label-g": ["saying, especially NAmE"]
}
]
}
]
}
}, {
"idm-g": {
"idm": ["the ˌapple of sb’s ˈeye"],
"sn-gs": [{
"sn-g": [{
"def": [{
"en": "a person or thing that is loved more than any other",
"cn": "心肝宝贝;掌上明珠"
}
],
"x-gs": [{
"en": "She is the apple of her father’s eye.",
"pron-gs": [{
"geo": "br",
"audioUrl": "http://book-iot-cdn.turingos.cn/202210281211/89944f707b5d484413e4f4bc68b00f75/dict/niujin/niujin_data/Sentenceaudio/A/_apple%23_gbs_1.mp3",
"audio": "_apple#_gbs_1"
}, {
"geo": "n_am",
"audioUrl": "http://book-iot-cdn.turingos.cn/202210281211/1f65594254a6d0d995fa249d289d1c01/dict/niujin/niujin_data/Sentenceaudio/A/_apple%23_uss_1.mp3",
"audio": "_apple#_uss_1"
}
]
}
]
}
]
}
]
}
}, {
"idm-g": {
"idm": ["ˌapples and ˈoranges"],
"sn-gs": [{
"sn-g": [{
"def": [{
"en": "used to describe a situation in which two people or things are completely different from each other",
"cn": "苹果橘子两码事;截然不同"
}
],
"label-g": ["especially NAmE"],
"x-gs": [{
"en": "They really are apples and oranges.",
"pron-gs": [{
"geo": "br",
"audioUrl": "http://book-iot-cdn.turingos.cn/202210281211/6b10641c7b9ed755472068b0b7bbeb90/dict/niujin/niujin_data/Sentenceaudio/A/_apple%23_brs_2.mp3",
"audio": "_apple#_brs_2"
}, {
"geo": "n_am",
"audioUrl": "http://book-iot-cdn.turingos.cn/202210281211/764121341c85105abf06658752e1ec02/dict/niujin/niujin_data/Sentenceaudio/A/_apple%23_uss_2.mp3",
"audio": "_apple#_uss_2"
}
],
"cn": "他们确实是迥然不同。"
}, {
"en": "They are both great but you can’t compare apples and oranges.",
"pron-gs": [{
"geo": "br",
"audioUrl": "http://book-iot-cdn.turingos.cn/202210281211/5fa96d9cd7060c7950b7712d7c527a69/dict/niujin/niujin_data/Sentenceaudio/A/_apple%23_gbs_2.mp3",
"audio": "_apple#_gbs_2"
}, {
"geo": "n_am",
"audioUrl": "http://book-iot-cdn.turingos.cn/202210281211/fa97f40dbe747d6c9e99c90598cd474e/dict/niujin/niujin_data/Sentenceaudio/A/_apple%23_ams_2.mp3",
"audio": "_apple#_ams_2"
}
],
"cn": "他们俩都很棒,但是截然不同,无法比较。"
}, {
"en": "It’s a totally different situation, it’s apples and oranges."
}
]
}
]
}
]
}
}, {
"xr-gs": ["-> more at American, rotten"]
}
],
"sn-gs": [{
"sn-g": [{
"xr-gs": ["SEE ALSO Adam’s apple, Big Apple, cooking apple, crab apple, eating apple, toffee apple"],
"def": [{
"en": "a round fruit with shiny red or green skin and firm white flesh",
"cn": "苹果"
}
],
"x-gs": [{
"en": "Peel and core the apples.",
"cn": "将这些苹果削皮、去核儿。"
}, {
"en": "an apple pie",
"cn": "苹果馅饼"
}, {
"en": "apple sauce",
"cn": "苹果沙司"
}, {
"en": "a garden with three apple trees",
"cn": "有三棵苹果树的花园"
}
]
}
]
}
]
}
],
"h": ["apple"],
"pron-gs": [{
"geo": "英",
"audioUrl": "http://book-iot-cdn.turingos.cn/202210281211/38fc9cb31e8cf5afa6ba4a7cd4ff392c/dict/niujin/niujin_data/Headwordaudio/A/apple%23_gb_1.mp3",
"phon": "ˈæpl",
"audio": "apple#_gb_1"
}, {
"geo": "美",
"audioUrl": "http://book-iot-cdn.turingos.cn/202210281211/537a00b09a4367c45602a2751b85e92a/dict/niujin/niujin_data/Headwordaudio/A/apple%23_us_1.mp3",
"phon": "ˈæpl",
"audio": "apple#_us_1"
}
],
"Ox-aw": ["ox3000"],
"infl-g": ["apple", "apples"]
}
]
},
"content": "apple"
}
}
}
}
naturalSpell 字段说明
| 参数 | 类型 | 是否必返 | 描述 |
|---|---|---|---|
| phoneticSymbol | String | N | 单词音标 |
| audio | String | N | 单词音频 |
| phoneticLetters | array | N | 单词拆分详情 |
| word | String | N | 单词 |
phoneticLetters 字段说明
| 参数 | 类型 | 是否必返 | 描述 |
|---|---|---|---|
| phoneticSymbol | String | N | 字母音标 |
| audio | String | N | 音标音频 |
| phoneticLetters | String | N | 单词拆分后的字母 |
查词补充说明:
初始化请求查词技能时,当intent-code字段返回1000633,为查词结果;若intent-code为其他值,则未进入查词技能。建议设备端只展示查词结果;
设备端可通过云端返回的result-dicit字段判断词典类型,当dict字段返回为others时,为无查词结果,云端会将查词内容进行整句翻译,并将翻译结果返回给设备端;
三、方案配置
1. 多行扫描
title: OCR多行扫读请求流程:
participant client as l1
participant OpenSocket as l2
participant OCR Server as l3
participant TTS Server as l4
l1->l2: 初始化参数(与OCR单行请求参数一致)
l2->l3: 请求OCR服务
l3->l2: 初始化结果通知
l2->l1: 确认初始化完成
l1->l2: 上传图片片段...
l2->l3:图片片段1..图片片段2...
l1-->l2:上传第一行图片结束标识+第二行图片开始标识
l2-->l2:等待设备上传第二行图片
l2->l3:告知第一行图片上传结束
l3->l2: 返回第一行OCR识别结果
l2->l1: 返回第一行OCR识别结果
l1->l2:上传第二行图片片段...
l2->l3:图片片段1..图片片段2...
l1-->l2:上传第二行图片结束标识+第三行图片开始标识
l2-->l3:上传第二行图片结束标识
l2-->l2:等待设备上传第三行图片
l1-->l2:上传图片结束标识(超出设备多行等待时间)
l2-->l3:上传图片结束标识
l3-->l2:OCR识别结果返回(第一行+第二行+...+最后一行)
l2-->l2:OCR识别结果请求分词服务
l2->l1: 返回OCR识别+分词结果
l2->l4: OCR文本请求TTS服务(需开启TTS权限)
l4->l2: 返回OCR文本的TTS结果
l2->l1: 返回OCR文本的TTS结果
OCR多行扫读流程说明:
- 多行初始化请求与单行初始化请求参数一致,不需要改动请求参数;
- 当设备端开启OCR多行扫读功能时,每次触发提笔事件,需设备端在上传图片结束标识时,同时上传下一行图片开始标识;
- 当设备在等待时间内(由设备端规定)再次触发扫描事件,则继续上传图片数据,云端在多行扫读过程中,仅返回OCR识别结果(第一行+....+上一行);
- 当设备超过等待时间,未触发扫描事件时,设备仅向云端上传图片结束标识,此时代表多行扫读结束,云端返回所有OCR识别结果+分词结果、TTS结果;
请求示例(以扫描两行为例)
1.1 第一行初始化请求
该示例为加密模式,data加密前数据格式:
{
"deviceId": "ai***3",
"requestType": ["TTS"],
"nlpRequest": {
"content": [{
"data": "23bf6bf2f5284449924999fceebc194a",
"type": 6
}]
},
"ocr2TextRequest": {
"hardwareId": 10004,
"imageAngle": 60
},
"binarysState": {
"openBinarysId": "23bf6bf2f5284449924999fceebc194a"
}
}
多行初始化时,content - data字段在首次与openBinarysId字段保持一致即可,后续通过上传binarysState参数控制是否多行;
1.2 上传第一行结束标识+下一行开始标识示例
每次上传完图片数据后,需同时上传completeBinarysId和openBinarysId字段,openBinarysId字段在每次初始化时,都需要重新生成,并和同一轮的completeBinarysId完全一致,否则会出现OCR报错问题;
data加密前数据格式:
{
"binarysState": {
"completeBinarysId": "23bf6bf2f5284449924999fceebc194a",
"openBinarysId": "9bc0355870a14893ad09dc6841d7224c"
}
}
completeBinarysId字段,为上一行图片结束标识,需与初始化openBinarysId对应;
openBinarysId字段,为下一行开始标识,需重新生成32位字符串作为图片二进制参数;
1.3 上传多行结束标识示例
data加密前数据格式:
{
"binarysState": {
"completeBinarysId": "9bc0355870a14893ad09dc6841d7224c"
}
}
在上传完最后一行图片数据,且设备端判断客户不会再进行下一行扫描时,只上传completeBinarysId字段,即为结束多行扫描。
2. 左右手切换
左右手切换支持用户使用设备通过不同角度扫描文本,可通过imageAngle字段进行配置;
请求参数
"ocr2TextRequest": {
"imageAngle": 60
}
imageAngle字段说明
| 参数 | 类型 | 是否必须 | 说明 |
|---|---|---|---|
| imageAngle | Integer | N | 左右手配置,默认值为60(右手) 当值为0 - 90时,为右手; 当值为-90 - 0时,为左手; |
3. 词典优先级
词典优先级支持词典类别:
- 图灵词典:包含汉语字典、汉语词典、汉语成语词典、英文单词词典、英文短语词典、古诗词词典、古诗词人名词典;
- 图灵附加词典:当前仅包含汉英词典;
- 牛津高阶英语词典(第9版)
请求参数
"robotSkill": {
"1000633": {
"dictType": "niujin",
"dicts": ["cn_char", "cn_idiom", "cn_word", "en_word", "en_phrase"]
}
ocr2TextRequest字段说明
| 参数 | 类型 | 是否必须 | 说明 |
|---|---|---|---|
| dicts | Integer | N |
4. 推荐查词机制
推荐查词可对用户扫描结果进行智能判断,若扫描的英文单词或短语前后有1个字符时,云端会自动优化掉多余字符,使用处理后的单词进行查词。
-
“开启推荐”:在OCR分词结果中,返回“扫描文本”和“推荐文本”,并在查词结果中,返回“推荐文本”的查词结果;
-
“关闭推荐”:显示用户扫描的内容,不会对前后字符进行处理,需手动点击分词单词查看单词的查词内容;
-
”查看扫描文本“:开启推荐后,若需要点击”完整“查看扫描文本及翻译,可在OCR分词结果中,保存“ocr2Text”字段文本,并用该文本单独查询词典。

请求参数
"ocr2TextRequest": {
"rTextState": 10
}
ocr2TextRequest字段说明
| 参数 | 类型 | 是否必须 | 说明 |
|---|---|---|---|
| rTextState | Integer | N | 使用推荐查词结果 (默认为关闭推荐) 10:开启推荐 |
返回示例
当rTextState为10时,返回2个分词结果:
{
"code": 293,
"done": false,
"globalId": "166838338024812001",
"message": "OCR文本分词结果",
"result": {
"binarysId": "e7ff9f391f4d46ecb9cb4d106fda6f73",
"ocr2Text": "- a welcome a -",
"pwords": [{
"pos": "x",
"type": 1,
"w": "-"
}, {
"pos": "w",
"type": 1,
"w": " "
}, {
"pos": "x",
"type": 0,
"w": "a"
}, {
"pos": "w",
"type": 1,
"w": " "
}, {
"pos": "x",
"type": 0,
"w": "welcome"
}, {
"pos": "w",
"type": 1,
"w": " "
}, {
"pos": "x",
"type": 0,
"w": "a"
}, {
"pos": "w",
"type": 1,
"w": " "
}, {
"pos": "w",
"type": 1,
"w": "-"
}],
"rText": "welcome",
"rWords": [{
"pos": "x",
"type": 0,
"w": "welcome"
}]
}
}
result字段说明
| 参数 | 类型 | 是否必返 | 说明 |
|---|---|---|---|
| ocr2Text | String | Y | OCR识别文本 |
| pword | array | Y | 分词结果 |
| binarysId | String | Y | OCR识别ID,用于定位OCR识别文本 |
| rText | String | N | 推荐文本(开启推荐设置后返回) |
| rWords | array | N | 推荐文本分词结果(开启推荐设置后返回) |
5. 点查模式
点查模式将查词体验从扫描的交互方式直接简化到用笔“点击一下”即可完成查词,查词更快更高效。使用该功能需联系图灵的项目/商务同事开通。
硬件要求
- 扫读笔的视野窗口至少开到1.6cm,垂直点触时,至少可以拍到英文教材4号字体6个以上的字符。对K6教材资源匹配率更高。
点查类型
- 英语:用户点触一下扫读笔,系统会根据匹配结果推荐三个用户可能想要查询的三个单词;
- 语文:用户点触一下扫读笔,系统会将匹配的结果分词查词,若查词未查到会进行翻译处理。
返回示例
{
"code": 293,
"done": false,
"globalId": "172268934936360001",
"message": "OCR文本分词结果",
"result": {
"binarysId": "501db77eb5794f71a622ac0298606e6a",
"ocr2Text": "appear",
"pointDatas": ["appear", "appeared", "apple"],
"pwords": [{
"pos": "x",
"type": 0,
"w": "appear"
}
]
}
}
result字段说明
| 参数 | 类型 | 是否必返 | 说明 |
|---|---|---|---|
| binarysId | String | Y | OCR识别ID,用于定位OCR识别文本 |
| ocr2Text | String | Y | OCR识别文本 |
| pword | array | Y | 分词结果 |
| pointDatas | array | N | 点查推荐内容(开启点查功能后返回) |
四、其他请求示例
1. OCR识别+查词(不加密示例)
当biz平台未开启加密时,使用该初始化示例请求socket服务:
{
"key": "dc37***********127b",
"timestamp": "162****992",
"service_identify": "scanPen",
"streamTts": "true",
"data": {
"deviceId": "ai****03",
"requestType": ["NLP"],
"nlpRequest": {
"content": [{
"data": "23bf6bf2f5284449924999fceebc194a",
"type": 6
}],
"clientInfo": {
"appState": {
"code": 1000633,
"operateState": 1100
},
"robotSkill": {
"1000633": {
"dicts": ["cn_char", "cn_idiom", "cn_word", "en_word", "en_phrase"]
}
}
}
},
"ocr2TextRequest": {
"hardwareId": 10004,
"imageAngle": 60
},
"binarysState": {
"openBinarysId": "23bf6bf2f5284449924999fceebc194a"
}
}
}
2. OCR识别+全文翻译示例
该示例为加密模式,data加密前数据格式:
{
"deviceId": "ai***3",
"requestType": ["NLP","TTS"],
"streamTts": "true",
"nlpRequest": {
"content": [{
"data": "23bf6bf2f5284449924999fceebc194a",
"type": 6
}],
"userInfo": {
"useCodes": [1000018]
}
},
"ocr2TextRequest": {
"hardwareId": 10004,
"imageAngle": 60
},
"binarysState": {
"openBinarysId": "23bf6bf2f5284449924999fceebc194a"
}
}
3. OCR识别+非流式TTS输出示例
该示例为加密模式,data加密前数据格式:
{
"deviceId": "ai***3",
"requestType": ["TTS"],
"nlpRequest": {
"content": [{
"data": "23bf6bf2f5284449924999fceebc194a",
"type": 6
}]
},
"ocr2TextRequest": {
"hardwareId": 10004,
"imageAngle": 60
},
"binarysState": {
"openBinarysId": "23bf6bf2f5284449924999fceebc194a"
}
}
请求TTS补充说明:
- 若需要用文本直接请求TTS,可将示例中content - type改为0,content - data改为文本内容,再将ocr2TextRequest和binarysState字段删除即可;
4. 文本请求TTS示例
该示例为加密模式,data加密前数据格式:
{
"deviceId": "ai***3",
"streamTts": "true",
"requestType": ["TTS"],
"nlpRequest": {
"content": [{
"data": "美丽"
}]
}
}
5. 文本查词示例
该示例为加密模式,data加密前数据格式:
{
"deviceId": "ai***3",
"requestType": ["NLP"],
"nlpRequest": {
"content": [{
"data": "美丽"
}],
"clientInfo": {
"appState": {
"code": 1000633,
"operateState": 1100
},
"robotSkill": {
"1000633": {
"dicts": ["cn_char", "cn_idiom", "cn_word", "en_word", "en_phrase"]
}
}
}
}
}
文本查词时,可在content-data字段中直接输入文本,无需在data和binarysState字段中上报UUID;
6. 指定技能请求示例
该示例为加密模式,data加密前数据格式:
{
"deviceId": "ai***3",
"requestType": ["NLP","TTS"],
"streamTts": "true",
"nlpRequest": {
"content": [{
"data": "23bf6bf2f5284449924999fceebc194a",
"type": 6
}],
"clientInfo": {
"appState": {
"code": 1000633,
"operateState": 1100
},
"robotSkill": {
"1000633": {
"dicts": ["cn_char", "cn_idiom", "cn_word", "en_word", "en_phrase"]
}
}
}
},
"ocr2TextRequest": {
"hardwareId": 10004,
"imageAngle": 60
},
"binarysState": {
"openBinarysId": "23bf6bf2f5284449924999fceebc194a"
},
"userInfo": {
"useCodes": [1000633]
}
}
使用useCodes字段后,只会进入指定技能,可有效避免扫描文本解析为其他技能,导致输出结果不准确。具体说明可参见userInfo字段说明;
7. 牛津词典查词示例
该示例为加密模式,data加密前数据格式:
{
"deviceId": "ai***3",
"requestType": ["NLP"],
"nlpRequest": {
"content": [{
"data": "hello"
}],
"clientInfo": {
"appState": {
"code": 1000633,
"operateState": 1100
},
"robotSkill": {
"1000633": {
"dictType": "niujin",
"oxfordVersion": "4",
"dicts": ["cn_char", "cn_idiom", "cn_word", "en_word", "en_phrase"]
}
}
}
}
}
补充说明:
- 当扫描查词功能中不包含古诗词、历史人名查询时,可直接使用该示例请求;
- 当dictType为niujin时,查词内容优先进入牛津词典,若牛津词典未查到结果,则进入图灵词典,并按dicts字段指定的词典顺序进行查词;
五、拼音识别及词典查询
拼音查词主要分为获取拼音文本及拼音查词两部分。
可通过扫描识别方式或拉取字母表方式,首先获取到拼音文本,然后请求查询拼音词典。
1. 获取拼音文本
1.1 扫描识别拼音
支持扫描OCR识别拼音,和分词接口拆分拼音文本。可参考文档 3.1 OCR识别+分词结果。
1.2 拉取字母表
接口地址
http://stat.turingos.cn/pinyin/getPinyinCatalog
请求方法
Method: POST
Content-Type: application/json
加密请求示例
{
"key":"e6b5bf********97a64b7eb4ce96",
"timestamp":"1654588952349",
"data":"********"
}
data 加密前内容
{
"deviceId":"****",
"type": 0
}
data 字段说明
| 参数 | 类型 | 是否必须 | 说明 |
|---|---|---|---|
| deviceId | String | Y | 设备号 |
| type | int | Y | 0:获取全部音节;1:声母;2:全部韵母;3:单韵母; 4:复韵母;5:特殊韵母;6:鼻韵母;7:整体认读 |
返回示例
{
"code": 200,
"message": "success",
"data": {
"nasalVowel": [
"an",
"en",
"in",
"un",
"ün",
"ang",
"eng",
"ing",
"ong"
],
"overallReading": [
"zhi",
"chi",
"shi",
"ri",
"zi",
"ci",
"si",
"yi",
"wu",
"yu",
"ye",
"yue",
"yuan",
"yin",
"yun",
"ying"
],
"specialVowel": [
"er"
],
"initialConsonant": [
"b",
"p",
"m",
"f",
"d",
"t",
"n",
"l",
"g",
"k",
"h",
"j",
"q",
"x",
"zh",
"ch",
"sh",
"r",
"z",
"c",
"s",
"y",
"w"
],
"simpleFinal": [
"a",
"o",
"e",
"i",
"u",
"ü"
],
"compoundFinal": [
"ai",
"ei",
"ui",
"ao",
"ou",
"iu",
"ie",
"üe"
]
}
}
返回参数说明
| 参数 | 类型 | 是否必须 | 说明 |
|---|---|---|---|
| initialConsonant | Array | Y | 声母 |
| simpleFinal | Array | Y | 单韵母 |
| compoundFinal | Array | Y | 复韵母 |
| specialVowel | Array | Y | 特殊韵母 |
| nasalVowel | Array | Y | 鼻韵母 |
| overallReading | Array | Y | 整体认读 |
2. 拼音词典查询
2.1 拼音查词示例
{
"deviceId": "ai***3",
"requestType": ["NLP"],
"nlpRequest": {
"content": [{
"data": "b"
}],
"clientInfo": {
"appState": {
"code": 1000633,
"operateState": 1100
},
"robotSkill": {
"1000633": {
"dicts": ["cn_pinyin"]
}
}
}
}
}
2.2 查词结果
2.2.1 声母
{
"code": 200,
"done": true,
"globalId": "176422665894225001",
"message": "success",
"nlpResponse": {
"intent": {
"code": 1000633,
"operateState": 1010,
"parameters": {
"result": {
"oralTestState": 1100,
"dict": "cn_pinyin",
"dictType": "tuling",
"info": {
"spell": ["b-i=bi"],
"typeExt": 1,
"letter": "b",
"pronMethod": "发音时,双唇紧闭,阻碍气流,然后双唇突然放开,让气流冲出,读音轻短。",
"letterAudio": "",
"copy": [],
"pronAudio": "",
"type": "shengmu"
}
},
"content": "b"
}
}
}
}
info 字段说明
| 参数 | 类型 | 是否必须 | 描述 |
|---|---|---|---|
| type | String | 是 | 拼音词典查询类别-声母 shengmu |
| typeExt | String | 是 | 拼音词典查询类别扩展字段 1.声母;2:韵母;3:拼读;4:整体认读 |
| letter | String | 是 | 声母 |
| letterAudio | String | 是 | 声母读音 |
| pronMethod | String | 是 | 发音方法 |
| pronAudio | String | 是 | 发音方法音频 |
| spell | String | 是 | 拼读内容 |
| copy | Array | 否 | 字段的svg图像链接 |
2.2.2 韵母
{
"code": 200,
"done": true,
"globalId": "176423073897435001",
"message": "success",
"nlpResponse": {
"intent": {
"code": 1000633,
"operateState": 1010,
"parameters": {
"result": {
"oralTestState": 1100,
"dict": "cn_pinyin",
"dictType": "tuling",
"info": {
"spell": ["t-a->ta"],
"typeExt": 2,
"syllable": "a a a a",
"syllableAudio": "http://4.mp3",
"letter": "a",
"pronMethod": "a就读作a",
"letterAudio": "http://2.mp3",
"subType": 1,
"copy": [],
"pronAudio": "http://3.mp3",
"type": "yunmu"
}
},
"content": "a"
}
}
}
}
info 字段说明
| 参数 | 类型 | 是否必须 | 描述 |
|---|---|---|---|
| type | String | 是 | 拼音词典查询类别-韵母 yunmu |
| typeExt | String | 是 | 拼音词典查询类别扩展字段 1.声母;2:韵母;3:拼读;4:整体认读 |
| letter | String | 是 | 韵母 |
| letterAudio | String | 是 | 韵母读音 |
| pronMethod | String | 是 | 发音方法 |
| pronAudio | String | 是 | 发音方法音频 |
| spell | String | 是 | 拼读内容 |
| syllable | String | 是 | 音节 |
| syllableAudio | String | 是 | 音节音频 |
| subType | String | 是 | 韵母类别:1(单韵母),2(复韵母),3(特殊元音韵母),4(鼻韵母) |
| copy | Array | 否 | 字段的svg图像链接 |
2.2.3 拼读
{
"code": 200,
"done": true,
"globalId": "176423301183435001",
"message": "success",
"nlpResponse": {
"intent": {
"code": 1000633,
"operateState": 1010,
"parameters": {
"result": {
"dict": "cn_pinyin",
"dictType": "tuling",
"info": {
"typeExt": 3,
"letter": "xià",
"letterAudio": "xià.mp3",
"words": [{
"phrase": ["大家"],
"phraseAudio": "大.mp3",
"word": "大"
}
],
"copy": [],
"type": "pindu"
}
},
"content": "xià"
}
}
}
}
info 字段说明
| 参数 | 类型 | 是否必须 | 描述 |
|---|---|---|---|
| type | String | 是 | 拼音词典查询类别-拼读:pindu |
| typeExt | String | 是 | 拼音词典查询类别扩展字段 1.声母;2:韵母;3:拼读;4:整体认读 |
| letter | String | 是 | 拼读拼音 |
| letterAudio | String | 是 | 拼读拼音音频 |
| words | Array | 是 | 拼音查字 |
| copy | Array | 否 | 字段的svg图像链接 |
words 字段说明
| 参数 | 类型 | 是否必须 | 描述 |
|---|---|---|---|
| word | String | 否 | 字 |
| phrase | String | 否 | 字组词 |
| phraseAudio | String | 否 | 字组词音频 |
2.2.4 整体拼读
{
"code": 200,
"done": true,
"globalId": "176423464715435001",
"message": "success",
"nlpResponse": {
"intent": {
"code": 1000633,
"operateState": 1010,
"parameters": {
"result": {
"oralTestState": 1100,
"dict": "cn_pinyin",
"dictType": "tuling",
"info": {
"typeExt": 4,
"syllable": "zhi zhi zhi zhi",
"syllableAudio": "http://zhi音节.mp3",
"letter": "zhi",
"pronMethod": "zhi就读作zhi",
"letterAudio": "http://zhi.mp3",
"copy": [],
"pronAudio": "zhi读法.mp3",
"type": "zhengtirendu"
}
},
"content": "zhi"
}
}
}
}
info 字段说明
| 参数 | 类型 | 是否必须 | 描述 |
|---|---|---|---|
| type | String | 是 | 拼音词典查询类别-整体认读:zhengtirendu |
| typeExt | String | 是 | 拼音词典查询类别扩展字段 1.声母;2:韵母;3:拼读;4:整体认读 |
| letter | String | 是 | 整体认读拼音 |
| letterAudio | String | 是 | 拼音音频 |
| pronMethod | String | 是 | 发音方法 |
| pronAudio | String | 是 | 发音方法音频 |
| spell | String | 是 | 拼读内容 |
| syllable | String | 是 | 音节 |
| syllableAudio | String | 是 | 音节音频 |
| copy | Array | 否 | 字段的svg图像链接 |
六、异常code码说明
| code | 说明 |
|---|---|
| 200 | 正确结果返回 |
| 210 | 参数初始化成功,请收到该标识后上传二进制数据(如果需要) |
| 220 | 参数上传完成,正在请求nlp/tts |
| 230 | OCR/NLP正确处理,但tts功能处理失败(单独请求TTS功能,异常时也返回该code) |
| 240 | 输入参数为空,nlp/tts不处理 |
| 250 | robot TTS调用次数耗尽 |
| 260 | TTS 流式处理状态 |
| 290 | OCR文本识别结果 |
| 291 | OCR文本TTS结果 |
| 292 | OCR,TTS处理失败,请稍后再试。 |
| 293 | OCR文本分词结果 |
| 294 | OCR分词处理失败 |
| 300 | 无效数据:二进制参数已完成传输,不要发送该数据 |
| 4004 | 机器人类型非法 |
| 4005 | apikey信息错误 |
| 4006 | deviceId信息错误 |
| 4007 | 解密失败,您的加密逻辑存在异常 |
| 4008 | 数据内容格式错误 |
| 4009 | 机器人被禁用 |
| 4010 | 试用期已过 |
| 4011 | 系统不支持二进制参数 |
| 4012 | 今天我们已经聊了很多啦,明天再来找我聊天吧。 |
| 4013 | 这一小时的对话次数已经超过我的极限啦,让我休息一下,待会再聊 |
| 4014 | 这一分钟里我们已经聊了很多啦,休息,休息一下吧 |
| 4015 | 二进制参数错误,请确定binarysId是否对应 |
| 4016 | 单次交互时间过长,请查看文档! |
| 4017 | 二进制参数错误,有重复binarysId! |
| 4018 | 二进制参数输入状态异常 |
| 4019 | 二进制参数处理时间超时/第三方引擎参数错误 |
| 4021 | TTS权限异常 |
| 4022 | 二进制传输内容过大! |
| 4023 | 单次交互同类型的二进制参数只允许输入一个 |
| 4025 | 上传数据失败,请稍后~ |
| 4026 | nlp/tts请求内容过长 |
| 4027 | 请求类型不能为空 |
| 4028 | 丢弃任务:同一用户不允许同时处理一个以上的ASR请求 |
| 4030 | robot NLP调用次数耗尽 |
| 4031 | uri不支持 |
| 4032 | 请求时间戳偏与服务器时间偏差太大,message为服务器时间戳 |
| 4033 | OCR权限异常 |
| 4100 | 服务正在升级 请稍后再试 |
| 4101 | 请求没有正确初始化! |
| 4102 | 长时间未请求业务,关闭连接 |
| 4200 | robot信息异常 |
| 4201 | nlp/tts处理异常 |
| 4202 | tts数据为空 |
| 5001 | 音频信息参数错误 |
| 5002 | 未上传任何二进制数据 |
| 5104 | userid并发请求测评功能 |
| 5200 | OCR引擎链接异常 |
| 5201 | OCR客户端非法并发请求 |
| 5202 | OCR处理异常 |
| 6000 | 丢弃任务:同一用户不允许同时处理一个以上的ASR请求 |
注意
- 4XXX~5XXX异常,服务端将主动关闭与客户端的connection,其余code不会关闭;
七、常见问题
如何更改加密状态?
答:在biz平台中登录账号,选择机器人名称 - 基础信息,通过“加密状态”按钮控制是否加密;
为什么云端会主动断开websocket?
答:当设备端非法请求云端时,云端为保护,会主动断开websocket连接,目前有以下几种情况:
- 长时间未请求:每次上传图片间隔不超过90秒,单轮OCR请求时长不超过45秒,否则云端会下发code=4102且自动关闭socket,需重新建立连接或发送心跳包维持;
- 请求出现报错:当出现请求参数错误、初始化失败等错误时,云端会下发对应错误Code且自动关闭socket通道,需查看报错原因,避免非法请求;
- 请求数据包超限:请求websocket服务时,单个数据包超出256KB时,云端会自动关闭socket,需将数据分包传输;
为什么开启debug功能,但云端不下发debug图片了?
答:当apikey状态由“测试状态”变为正式状态时,debug功能默认失效。如需查看某个设备Debug图片,需联系图灵项目人员;
为什么请求词典技能,有时会返回闲聊或诗词背诵技能?
答:由于词典技能超时导致。可使用useCodes字段指定请求词典技能,避免文本进入其他技能(具体字段说明可参见请求参数 - userInfo字段说明)