AI口语老师服务,可以根据用户的需求和偏好生成更加自然、流程和准确的对话内容,并根据用户对话给出高质量的自然语言评价,为用户提供更加个性化、贴心的对话体验。
Hi,您好,欢迎使用有道智云AI口语老师接口服务。
本文档主要针对需要集成HTTP API的技术开发工程师,详细描述AI口语老师能力相关的技术内容。
如果您有与我们商务合作的需求,可以通过以下方式联系我们:
商务邮箱: AIcloud_Business@corp.youdao.com
如果您对文档内容有任何疑问,可以通过以下几种方式联系我们:
客服QQ:1906538062
AIGC产品技术交流群 :837394306
联系邮箱: zhiyun@corp.youdao.com
温馨提示:
调用方在集成AI口语老师API时,请遵循以下规则。
规则 | 描述 |
---|---|
传输方式 | HTTPS |
请求方式 | POST |
字符编码 | 统一使用UTF-8 编码 |
请求格式 | JSON |
响应格式 | JSON |
AI口语老师线上调用地址:
https://openapi.youdao.com/ai_dialog
1、服务支持10轮对话,系统根据对话轮次,任务完成度,主动回复客户bye bye,并将end标志设置为结束。
2、如果对话已经结束,再请求生成对话或者推荐表达接口,系统可能只会返回 bye bye。
3、对话历史系统和用户content字段的总字符数限制:12000.
4、口语对话服务各接口统一设置 :Content-Type : application/json
5、生成签名时,q字段的取值在对应的接口里有说明。
注意:
签名生成方法如下:
signType=v3;
sign=sha256(应用ID+input+salt+curtime+应用密钥);
其中,input的计算方式为:input=q前10个字符 + q长度 + q后10个字符(当q长度大于20)或 input=q字符串(当q长度小于等于20);
接口参数:
{
"appKey":"",
"salt":"", // 随机值
"curtime":"", // 时间戳
"signType":"v3", // 仅支持v3
"sign":"", // 生成方式见demo, q取q字段
"q":"topics" // 固定值
}
{
"code": "0", //错误码
"msg": "SUCCESS", //信息说明
"data": {
"topicList": [
{
"tag": "初级",
"topics": [
{
"emoji": "😄",
"name": "互相介绍",
"enName": "Introduce yourself to a friend at school"
}
]
}
]
}
}
{
"appKey":"",
"salt":"", // 随机值
"curtime":"", // 时间戳
"signType":"v3", // 仅支持v3
"sign":"", // 生成方式见demo,q取topic字段
"topic": "Introduce yourself to a friend at school" // 用户指定的话题关键词,语种限制英文,长度限制 < 500,单词数限制 < 100
}
{
"code": "0",
"msg": "SUCCESS",
"data": {
"taskId": "f52c2df42bc311ee9d19bebd871cbd01", // 任务id
"scene": {
"mainTask": "Introduce yourself and get to know your new friend", // 主任务:对话目标
"emoji": "👋",
"subTasks": [ // 子任务列表
"1. Tell your friend your name and where you are from",
"2. Ask your friend about her hobbies and interests",
"3. Talk about your favorite subject in school",
"4. Ask your friend if she has any advice for navigating the school"
],
"botGender": "Female", // 系统性别, 取值范围: Male 男性; Female 女性;
"botRole": "Friend", // 系统角色
"userRole": "New student", // 用户角色
"content": "First day of school" // 场景内容
}
}
}
{
"appKey":"",
"salt":"", // 随机值
"curtime":"", // 时间戳
"signType":"v3", // 仅支持v3
"sign":"", // 生成方式见demo, q取taskId
"taskId": "f52c2df42bc311ee9d19bebd871cbd01", // 场景生成接口返回的任务id
"scene": { // 生成场景接口返回的 scene 字段
"mainTask": "Introduce yourself and get to know your new friend",
"emoji": "👋",
"subTasks": [
"1. Tell your friend your name and where you are from",
"2. Ask your friend about her hobbies and interests",
"3. Talk about your favorite subject in school",
"4. Ask your friend if she has any advice for navigating the school"
],
"botGender": "Female",
"botRole": "Friend",
"userRole": "New student",
"content": "First day of school"
},
"userLevel": "0", // 用户等级:0表示1-3年级小学生;1表示4-6年级小学生;2表示初中学生;3表示高中学生;
"history": [ // 对话历史,讲话人字段:系统与用户必须交替出现,第一句话的讲话人必须是系统,获取系统说的第一句话时,history传空数组
]
}
{
"code": "0",
"msg": "SUCCESS",
"data": {
"endCode": 0, //结束码:0-未结束; 1-结束;
"taskId": "f52c2df42bc311ee9d19bebd871cbd01", // 任务id
"resultArr": [
{
"result": [ // 系统回话
"Hi there! My name is Sarah, and I'm from New York. What's your name and where are you from?"
],
"score": 0, // 对话接口不关注此字段
"achievement": [], // 对话接口不关注此字段
"index": -1 // 对话接口不关注此字段
}
]
}
}
{
"appKey":"",
"salt":"", // 随机值
"curtime":"", // 时间戳
"signType":"v3", // 仅支持v3
"sign":"", // 生成方式见demo, q取taskId
"taskId": "f52c2df42bc311ee9d19bebd871cbd01", // 场景生成接口返回的任务id
"scene": { // 生成场景接口返回的 scene 字段
"mainTask": "Introduce yourself and get to know your new friend",
"emoji": "👋",
"subTasks": [
"1. Tell your friend your name and where you are from",
"2. Ask your friend about her hobbies and interests",
"3. Talk about your favorite subject in school",
"4. Ask your friend if she has any advice for navigating the school"
],
"botGender": "Female",
"botRole": "Friend",
"userRole": "New student",
"content": "First day of school"
},
"userLevel": "0", // 用户等级:0表示1-3年级小学生;1表示4-6年级小学生;2表示初中学生;3表示高中学生;
"history": [ // 对话历史,讲话人字段:系统与用户必须交替出现
{
"speaker":"System", // 讲话人:系统,第一句话的讲话人必须是系统
"content":"Hi there! My name is Sarah, and I'm from New York. What's your name and where are you from?" // 讲话内容, 语种限制英文
},
{
"speaker":"User", // 讲话人:用户
"content":"Hello, I'm Echo, I come from China. Nice to meet you. Do you have any hobbies?" // 讲话内容, 语种限制英文,单词数限制80
}
],
"indexArr": [ // 请求系统生成推荐表达例句的索引(对应history数组),取值为 0 - history.length, 如果取值 = history.length,则会生成对话历史的下一句话, 目前该数组中仅支持一个值
"1"
],
"count": "1" // 系统生成推荐表达例句的数量,取值 1 - 3,存在指定为3但结果不足3句的情况
}
{
"code": "0",
"msg": "SUCCESS",
"data": {
"endCode": 0, //结束码:0-未结束; 1-结束;
"taskId": "f52c2df42bc311ee9d19bebd871cbd01", // 任务id
"resultArr": [
{
"result": [ // 系统生成的推荐表达例句
"Hi Sarah, my name is Echo, and I'm from China."
],
"score": 0, // 生成推荐接口不关注此字段
"achievement": [], // 生成推荐接口不关注此字段
"index": 0 // 用户指定的会话历史中的索引
}
]
}
}
{
"appKey":"",
"salt":"", // 随机值
"curtime":"", // 时间戳
"signType":"v3", // 仅支持v3
"sign":"", // 生成方式见demo, q取taskId
"taskId": "f52c2df42bc311ee9d19bebd871cbd01", // 场景生成接口返回的任务id
"scene": { // 生成场景接口返回的 scene 字段
"mainTask": "Introduce yourself and get to know your new friend",
"emoji": "👋",
"subTasks": [
"1. Tell your friend your name and where you are from",
"2. Ask your friend about her hobbies and interests",
"3. Talk about your favorite subject in school",
"4. Ask your friend if she has any advice for navigating the school"
],
"botGender": "Female",
"botRole": "Friend",
"userRole": "New student",
"content": "First day of school"
},
"userLevel": "0", // 用户等级:0表示1-3年级小学生;1表示4-6年级小学生;2表示初中学生;3表示高中学生;
"history": [ // 对话历史,讲话人字段:系统与用户必须交替出现
{
"speaker":"System", // 讲话人:系统,第一句话的讲话人必须是系统
"content":"Hi there! My name is Sarah, and I'm from New York. What's your name and where are you from?" // 讲话内容, 语种限制英文
},
{
"speaker":"User", // 讲话人:用户
"content":"Hello, I'm Echo, I come from China. Nice to meet you. Do you have any hobbies?" // 讲话内容, 语种限制英文,单词数限制80
"voice":"" // 选填字段:音频的base64编码, 如果不填,会影响最终的语音评分。音频格式要求:采样率16K,单声道,wav,如格式不符,会影响评分结果。
},
{
"speaker":"System",
"content":"Yes, I love hiking and playing tennis. What about you?"
},
{
"speaker":"User",
"content":"I like singing and running, especially listening to music while running. It's one of my favorite ways to relax. I also like listening to music while reading, so I like Chinese class, how about you?"
}
]
}
{
"code": "0",
"msg": "SUCCESS",
"data": {
"history": [ // 会话历史, 仅评价用户的讲话内容
{
"index": "1",
"speaker": "User",
"content": "Hello, I'm Echo, I come from China. Nice to meet you. Do you have any hobbies?",
"needImprove": "false", // 是否需要改进:true 表示需要; false 表示不需要
"paraphrase": null, // 润色结果,如果content的长度 <30 或者单词数 <3,会导致无法生成润色结果。
"suggest": { // 系统建议
"grammar": null, // 语法评价
"voice": { // 语音评价
"overall": "0.000040", // 发音得分
"words": [
{
"word": "Hello",
"text": "Hello 发音不清晰, 其中 h、e 发音不准确"
},
{
"word": "I'm",
"text": "I'm 发音不清晰, 其中 aɪ、m 发音不准确"
}
]
}
}
},
{
"index": "3",
"speaker": "User",
"content": "I like singing and running, especially listening to music while running. It's one of my favorite ways to relax. I also like listening to music while reading, so I like Chinese class, how about you?",
"needImprove": "true",
"paraphrase": [
{
"rawSent": "I like singing and running, especially listening to music while running.", // 原句
"diffs": [ // 操作
{
"text": "I",
"operation": "EQUAL" // 不变
},
{
"text": "like",
"operation": "DELETE" // 删除
},
{
"text": "love",
"operation": "INSERT" // 插入
},
{
"text": "singing and running, especially listening to music while running.",
"operation": "EQUAL" // 不变
}
]
},
{
"rawSent": "It's one of my favorite ways to relax.",
"diffs": null
},
{
"rawSent": "I also like listening to music while reading, so I like Chinese class, how about you?",
"diffs": [
{
"text": "I also like",
"operation": "EQUAL"
},
{
"text": "listening",
"operation": "DELETE"
},
{
"text": "to listen",
"operation": "INSERT"
},
{
"text": "to music while reading, so I like Chinese",
"operation": "EQUAL"
},
{
"text": "class,",
"operation": "DELETE"
},
{
"text": "lessons,",
"operation": "INSERT"
},
{
"text": "how about you?",
"operation": "EQUAL"
}
]
}
],
"suggest": {
"grammar": {
"advice": "语法结构丰富,语言运用自然流畅,没有语法错误",
"score": "79.7"
},
"voice": null
}
}
],
"scene": { // 场景信息
"emoji": "👋",
"name": "First day of school"
},
"summary": { // 报告概要
"grammarScore": "64", // 语法得分
"voiceScore": "0", // 音频得分
"wordNum": "125", // 单词数
"star": "3" // 任务完成评分,1表示完成主要任务,2表示完成主要任务和部分子任务,3表示完成主要任务和全部子任务
}
}
}
状态码 | 状态码含义 |
---|---|
101 | 缺少必填的参数,首先确保必填参数齐全,然后,确认参数书写是否正确。 |
102 | 不支持的语言类型 |
103 | 翻译文本过长 |
104 | 不支持的API类型 |
105 | 不支持的签名类型 |
106 | 不支持的响应类型 |
107 | 不支持的传输加密类型 |
108 | 应用ID无效,注册账号,登录后台创建应用并完成绑定,可获得应用ID和应用密钥等信息 |
109 | batchLog格式不正确 |
110 | 无相关服务的有效应用,应用没有绑定服务。注:某些服务的结果发音需要tts服务,需要在控制台创建语音合成实例绑定应用后方能使用。 |
111 | 开发者账号无效 |
112 | 请求服务无效 |
113 | q不能为空 |
114 | 不支持的图片传输方式 |
201 | 解密失败,可能为DES,BASE64,URLDecode的错误 |
202 | 签名检验失败,如果确认应用ID和应用密钥的正确性,仍返回202,一般是编码问题。请确保翻译文本 q 为UTF-8编码. |
203 | 访问IP地址不在可访问IP列表 |
205 | 请求的接口与应用的平台类型不一致,确保接入方式(Android SDK、IOS SDK、API)与创建的应用平台类型一致。如有疑问请参考入门指南 |
206 | 因为时间戳无效导致签名校验失败 |
207 | 重放请求 |
303 | 服务异常 |
405 | 鉴权失败 |
AIDIALOG001 | topic字段长度或单词数超出限制 |
AIDIALOG002 | q字段长度超出限制 |
AIDIALOG003 | 不支持的userLevel字段 |
AIDIALOG004 | 不支持的count字段 |
AIDIALOG005 | indexArr字段取值无效 |
AIDIALOG006 | 不支持的speaker字段 |
AIDIALOG007 | 讲话人顺序异常 |
AIDIALOG008 | 不支持的语种 |
AIDIALOG009 | content字段长度或单词数超出限制 |
AIDIALOG010 | 生成场景接口请求失败 |
AIDIALOG011 | 生成推荐表达接口请求失败 |
AIDIALOG012 | 生成对话接口请求失败 |
AIDIALOG013 | history字段异常: 结构异常、超出对话轮次限制,生成报告接口该字段为空等。 |
AIDIALOG018 | 基础服务异常 |
AIDIALOG019 | 请求中包含敏感词 |
AIDIALOG020 | 系统回话中包含敏感词 |
AIDIALOG021 | 总字符数超出限制 |
AIDIALOG022 | 系统无结果 |
AIDIALOG023 | scene字段异常 |
AIDIALOG024 | 不支持的bot取值(scene中的字段) |