AI口語(yǔ)老師簡(jiǎn)介
概念解釋
AI口語(yǔ)老師服務(wù),可以根據(jù)用戶(hù)的需求和偏好生成更加自然、流程和準(zhǔn)確的對(duì)話(huà)內(nèi)容,并根據(jù)用戶(hù)對(duì)話(huà)給出高質(zhì)量的自然語(yǔ)言評(píng)價(jià),為用戶(hù)提供更加個(gè)性化、貼心的對(duì)話(huà)體驗(yàn)。
說(shuō)明
Hi,您好,歡迎使用有道智云AI口語(yǔ)老師接口服務(wù)。
本文檔主要針對(duì)需要集成HTTP API的技術(shù)開(kāi)發(fā)工程師,詳細(xì)描述AI口語(yǔ)老師能力相關(guān)的技術(shù)內(nèi)容。
如果您有與我們商務(wù)合作的需求,可以通過(guò)以下方式聯(lián)系我們:
商務(wù)郵箱: AIcloud_Business@corp.youdao.com
如果您對(duì)文檔內(nèi)容有任何疑問(wèn),可以通過(guò)以下幾種方式聯(lián)系我們:
客服QQ:1906538062
AIGC產(chǎn)品技術(shù)交流群 :837394306
聯(lián)系郵箱: zhiyun@corp.youdao.com
溫馨提示:
- 本文檔主要針對(duì)開(kāi)發(fā)人員,接入測(cè)試前需要獲取應(yīng)用ID和應(yīng)用密鑰,并創(chuàng)建應(yīng)用;如果您還沒(méi)有,請(qǐng)按照 新手指南 獲取。
- 平臺(tái)向每個(gè)賬戶(hù)贈(zèng)送50元的體驗(yàn)金,供用戶(hù)集成前測(cè)試所用。
協(xié)議須知
調(diào)用方在集成AI口語(yǔ)老師API時(shí),請(qǐng)遵循以下規(guī)則。
規(guī)則 | 描述 |
---|
傳輸方式 | HTTPS |
請(qǐng)求方式 | POST |
字符編碼 | 統(tǒng)一使用UTF-8 編碼 |
請(qǐng)求格式 | JSON |
響應(yīng)格式 | JSON |
接口調(diào)用參數(shù)
AI口語(yǔ)老師線上調(diào)用地址:
https://openapi.youdao.com/ai_dialog
服務(wù)配置說(shuō)明
1、服務(wù)支持10輪對(duì)話(huà),系統(tǒng)根據(jù)對(duì)話(huà)輪次,任務(wù)完成度,主動(dòng)回復(fù)客戶(hù)bye bye,并將end標(biāo)志設(shè)置為結(jié)束。
2、如果對(duì)話(huà)已經(jīng)結(jié)束,再請(qǐng)求生成對(duì)話(huà)或者推薦表達(dá)接口,系統(tǒng)可能只會(huì)返回 bye bye。
3、對(duì)話(huà)歷史系統(tǒng)和用戶(hù)content字段的總字符數(shù)限制:12000.
4、口語(yǔ)對(duì)話(huà)服務(wù)各接口統(tǒng)一設(shè)置 :Content-Type : application/json
5、生成簽名時(shí),q字段的取值在對(duì)應(yīng)的接口里有說(shuō)明。
注意:
簽名生成方法如下:
signType=v3;
sign=sha256(應(yīng)用ID+input+salt+curtime+應(yīng)用密鑰);
其中,input的計(jì)算方式為:input=q前10個(gè)字符 + q長(zhǎng)度 + q后10個(gè)字符(當(dāng)q長(zhǎng)度大于20)或 input=q字符串(當(dāng)q長(zhǎng)度小于等于20);
AI口語(yǔ)老師接口定義
獲取默認(rèn)場(chǎng)景列表接口
接口參數(shù):
{
"appKey":"",
"salt":"", // 隨機(jī)值
"curtime":"", // 時(shí)間戳
"signType":"v3", // 僅支持v3
"sign":"", // 生成方式見(jiàn)demo, q取q字段
"q":"topics" // 固定值
}
{????
"code": "0",?//錯(cuò)誤碼???
"msg": "SUCCESS",?//信息說(shuō)明????
"data": {
"topicList": [
{
"tag": "初級(jí)",
"topics": [
{
"emoji": "??",
"name": "互相介紹",
"enName": "Introduce yourself to a friend at school"
}
]
}
]
}
}
場(chǎng)景生成接口
- 接口uri:/generate_topic
- 接口說(shuō)明:
用戶(hù)提供簡(jiǎn)要話(huà)題,系統(tǒng)返回具體的場(chǎng)景信息。 - 接口參數(shù):
{
"appKey":"",
"salt":"", // 隨機(jī)值
"curtime":"", // 時(shí)間戳
"signType":"v3", // 僅支持v3
"sign":"", // 生成方式見(jiàn)demo,q取topic字段
"topic": "Introduce yourself to a friend at school" // 用戶(hù)指定的話(huà)題關(guān)鍵詞,語(yǔ)種限制英文,長(zhǎng)度限制 < 500,單詞數(shù)限制 < 100
}
{
"code": "0",
"msg": "SUCCESS",
"data": {
"taskId": "f52c2df42bc311ee9d19bebd871cbd01", // 任務(wù)id
"scene": {
"mainTask": "Introduce yourself and get to know your new friend", // 主任務(wù):對(duì)話(huà)目標(biāo)
"emoji": "??",
"subTasks": [ // 子任務(wù)列表
"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", // 系統(tǒng)性別, 取值范圍: Male 男性; Female 女性;
"botRole": "Friend", // 系統(tǒng)角色
"userRole": "New student", // 用戶(hù)角色
"content": "First day of school" // 場(chǎng)景內(nèi)容
}
}
}
生成對(duì)話(huà)接口
- 接口uri:/generate_dialog
- 接口說(shuō)明:
用戶(hù)和系統(tǒng)之間的對(duì)話(huà)接口。特別注意: 第一次需要把場(chǎng)景信息告訴系統(tǒng),讓系統(tǒng)生成第一句話(huà); - 接口參數(shù):
{
"appKey":"",
"salt":"", // 隨機(jī)值
"curtime":"", // 時(shí)間戳
"signType":"v3", // 僅支持v3
"sign":"", // 生成方式見(jiàn)demo, q取taskId
"taskId": "f52c2df42bc311ee9d19bebd871cbd01", // 場(chǎng)景生成接口返回的任務(wù)id
"scene": { // 生成場(chǎng)景接口返回的 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", // 用戶(hù)等級(jí):0表示1-3年級(jí)小學(xué)生;1表示4-6年級(jí)小學(xué)生;2表示初中學(xué)生;3表示高中學(xué)生;
"history": [ // 對(duì)話(huà)歷史,講話(huà)人字段:系統(tǒng)與用戶(hù)必須交替出現(xiàn),第一句話(huà)的講話(huà)人必須是系統(tǒng),獲取系統(tǒng)說(shuō)的第一句話(huà)時(shí),history傳空數(shù)組
]
}
{
"code": "0",
"msg": "SUCCESS",
"data": {
"endCode": 0, //結(jié)束碼:0-未結(jié)束; 1-結(jié)束;
"taskId": "f52c2df42bc311ee9d19bebd871cbd01", // 任務(wù)id
"resultArr": [
{
"result": [ // 系統(tǒng)回話(huà)
"Hi there! My name is Sarah, and I'm from New York. What's your name and where are you from?"
],
"score": 0, // 對(duì)話(huà)接口不關(guān)注此字段
"achievement": [], // 對(duì)話(huà)接口不關(guān)注此字段
"index": -1 // 對(duì)話(huà)接口不關(guān)注此字段
}
]
}
}
生成推薦表達(dá)接口
- 接口uri:/generate_recommendation
- 接口說(shuō)明:
用戶(hù)提供場(chǎng)景信息和對(duì)話(huà)歷史,并指定要系統(tǒng)推薦表達(dá)的句子,系統(tǒng)會(huì)根據(jù)場(chǎng)景信息和對(duì)話(huà)上下文返回推薦的 1 - 3 句表達(dá)例句。 - 接口參數(shù):
{
"appKey":"",
"salt":"", // 隨機(jī)值
"curtime":"", // 時(shí)間戳
"signType":"v3", // 僅支持v3
"sign":"", // 生成方式見(jiàn)demo, q取taskId
"taskId": "f52c2df42bc311ee9d19bebd871cbd01", // 場(chǎng)景生成接口返回的任務(wù)id
"scene": { // 生成場(chǎng)景接口返回的 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", // 用戶(hù)等級(jí):0表示1-3年級(jí)小學(xué)生;1表示4-6年級(jí)小學(xué)生;2表示初中學(xué)生;3表示高中學(xué)生;
"history": [ // 對(duì)話(huà)歷史,講話(huà)人字段:系統(tǒng)與用戶(hù)必須交替出現(xiàn)
{
"speaker":"System", // 講話(huà)人:系統(tǒng),第一句話(huà)的講話(huà)人必須是系統(tǒng)
"content":"Hi there! My name is Sarah, and I'm from New York. What's your name and where are you from?" // 講話(huà)內(nèi)容, 語(yǔ)種限制英文
},
{
"speaker":"User", // 講話(huà)人:用戶(hù)
"content":"Hello, I'm Echo, I come from China. Nice to meet you. Do you have any hobbies?" // 講話(huà)內(nèi)容, 語(yǔ)種限制英文,單詞數(shù)限制80
}
],
"indexArr": [ // 請(qǐng)求系統(tǒng)生成推薦表達(dá)例句的索引(對(duì)應(yīng)history數(shù)組),取值為 0 - history.length, 如果取值 = history.length,則會(huì)生成對(duì)話(huà)歷史的下一句話(huà), 目前該數(shù)組中僅支持一個(gè)值
"1"
],
"count": "1" // 系統(tǒng)生成推薦表達(dá)例句的數(shù)量,取值 1 - 3,存在指定為3但結(jié)果不足3句的情況
}
{
"code": "0",
"msg": "SUCCESS",
"data": {
"endCode": 0, //結(jié)束碼:0-未結(jié)束; 1-結(jié)束;
"taskId": "f52c2df42bc311ee9d19bebd871cbd01", // 任務(wù)id
"resultArr": [
{
"result": [ // 系統(tǒng)生成的推薦表達(dá)例句
"Hi Sarah, my name is Echo, and I'm from China."
],
"score": 0, // 生成推薦接口不關(guān)注此字段
"achievement": [], // 生成推薦接口不關(guān)注此字段
"index": 0 // 用戶(hù)指定的會(huì)話(huà)歷史中的索引
}
]
}
}
生成報(bào)告接口
- 接口uri:/generate_report
- 接口說(shuō)明:
用戶(hù)提供場(chǎng)景信息和對(duì)話(huà)歷史,系統(tǒng)生成報(bào)告,報(bào)告包含語(yǔ)法評(píng)價(jià)、句子潤(rùn)色、語(yǔ)音評(píng)價(jià)、任務(wù)完成度評(píng)價(jià)。 - 接口參數(shù):
{
"appKey":"",
"salt":"", // 隨機(jī)值
"curtime":"", // 時(shí)間戳
"signType":"v3", // 僅支持v3
"sign":"", // 生成方式見(jiàn)demo, q取taskId
"taskId": "f52c2df42bc311ee9d19bebd871cbd01", // 場(chǎng)景生成接口返回的任務(wù)id
"scene": { // 生成場(chǎng)景接口返回的 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", // 用戶(hù)等級(jí):0表示1-3年級(jí)小學(xué)生;1表示4-6年級(jí)小學(xué)生;2表示初中學(xué)生;3表示高中學(xué)生;
"history": [ // 對(duì)話(huà)歷史,講話(huà)人字段:系統(tǒng)與用戶(hù)必須交替出現(xiàn)
{
"speaker":"System", // 講話(huà)人:系統(tǒng),第一句話(huà)的講話(huà)人必須是系統(tǒng)
"content":"Hi there! My name is Sarah, and I'm from New York. What's your name and where are you from?" // 講話(huà)內(nèi)容, 語(yǔ)種限制英文
},
{
"speaker":"User", // 講話(huà)人:用戶(hù)
"content":"Hello, I'm Echo, I come from China. Nice to meet you. Do you have any hobbies?" // 講話(huà)內(nèi)容, 語(yǔ)種限制英文,單詞數(shù)限制80
"voice":"" // 選填字段:音頻的base64編碼, 如果不填,會(huì)影響最終的語(yǔ)音評(píng)分。音頻格式要求:采樣率16K,單聲道,wav,如格式不符,會(huì)影響評(píng)分結(jié)果。
},
{
"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": [ // 會(huì)話(huà)歷史, 僅評(píng)價(jià)用戶(hù)的講話(huà)內(nèi)容
{
"index": "1",
"speaker": "User",
"content": "Hello, I'm Echo, I come from China. Nice to meet you. Do you have any hobbies?",
"needImprove": "false", // 是否需要改進(jìn):true 表示需要; false 表示不需要
"paraphrase": null, // 潤(rùn)色結(jié)果,如果content的長(zhǎng)度 <30 或者單詞數(shù) <3,會(huì)導(dǎo)致無(wú)法生成潤(rùn)色結(jié)果。
"suggest": { // 系統(tǒng)建議
"grammar": null, // 語(yǔ)法評(píng)價(jià)
"voice": { // 語(yǔ)音評(píng)價(jià)
"overall": "0.000040", // 發(fā)音得分
"words": [
{
"word": "Hello",
"text": "Hello 發(fā)音不清晰, 其中 h、e 發(fā)音不準(zhǔn)確"
},
{
"word": "I'm",
"text": "I'm 發(fā)音不清晰, 其中 a?、m 發(fā)音不準(zhǔn)確"
}
]
}
}
},
{
"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": "語(yǔ)法結(jié)構(gòu)豐富,語(yǔ)言運(yùn)用自然流暢,沒(méi)有語(yǔ)法錯(cuò)誤",
"score": "79.7"
},
"voice": null
}
}
],
"scene": { // 場(chǎng)景信息
"emoji": "??",
"name": "First day of school"
},
"summary": { // 報(bào)告概要
"grammarScore": "64", // 語(yǔ)法得分
"voiceScore": "0", // 音頻得分
"wordNum": "125", // 單詞數(shù)
"star": "3" // 任務(wù)完成評(píng)分,1表示完成主要任務(wù),2表示完成主要任務(wù)和部分子任務(wù),3表示完成主要任務(wù)和全部子任務(wù)
}
}
}
錯(cuò)誤代碼列表
狀態(tài)碼 | 狀態(tài)碼含義 |
---|
101 | 缺少必填的參數(shù),首先確保必填參數(shù)齊全,然后,確認(rèn)參數(shù)書(shū)寫(xiě)是否正確。 |
102 | 不支持的語(yǔ)言類(lèi)型 |
103 | 翻譯文本過(guò)長(zhǎng) |
104 | 不支持的API類(lèi)型 |
105 | 不支持的簽名類(lèi)型 |
106 | 不支持的響應(yīng)類(lèi)型 |
107 | 不支持的傳輸加密類(lèi)型 |
108 | 應(yīng)用ID無(wú)效,注冊(cè)賬號(hào),登錄后臺(tái)創(chuàng)建應(yīng)用并完成綁定,可獲得應(yīng)用ID和應(yīng)用密鑰等信息 |
109 | batchLog格式不正確 |
110 | 無(wú)相關(guān)服務(wù)的有效應(yīng)用,應(yīng)用沒(méi)有綁定服務(wù)。注:某些服務(wù)的結(jié)果發(fā)音需要tts服務(wù),需要在控制臺(tái)創(chuàng)建語(yǔ)音合成實(shí)例綁定應(yīng)用后方能使用。 |
111 | 開(kāi)發(fā)者賬號(hào)無(wú)效 |
112 | 請(qǐng)求服務(wù)無(wú)效 |
113 | q不能為空 |
114 | 不支持的圖片傳輸方式 |
201 | 解密失敗,可能為DES,BASE64,URLDecode的錯(cuò)誤 |
202 | 簽名檢驗(yàn)失敗,如果確認(rèn)應(yīng)用ID和應(yīng)用密鑰的正確性,仍返回202,一般是編碼問(wèn)題。請(qǐng)確保翻譯文本 q 為UTF-8編碼. |
203 | 訪問(wèn)IP地址不在可訪問(wèn)IP列表 |
205 | 請(qǐng)求的接口與應(yīng)用的平臺(tái)類(lèi)型不一致,確保接入方式(Android SDK、IOS SDK、API)與創(chuàng)建的應(yīng)用平臺(tái)類(lèi)型一致。如有疑問(wèn)請(qǐng)參考入門(mén)指南 |
206 | 因?yàn)闀r(shí)間戳無(wú)效導(dǎo)致簽名校驗(yàn)失敗 |
207 | 重放請(qǐng)求 |
303 | 服務(wù)異常 |
405 | 鑒權(quán)失敗 |
AIDIALOG001 | topic字段長(zhǎng)度或單詞數(shù)超出限制 |
AIDIALOG002 | q字段長(zhǎng)度超出限制 |
AIDIALOG003 | 不支持的userLevel字段 |
AIDIALOG004 | 不支持的count字段 |
AIDIALOG005 | indexArr字段取值無(wú)效 |
AIDIALOG006 | 不支持的speaker字段 |
AIDIALOG007 | 講話(huà)人順序異常 |
AIDIALOG008 | 不支持的語(yǔ)種 |
AIDIALOG009 | content字段長(zhǎng)度或單詞數(shù)超出限制 |
AIDIALOG010 | 生成場(chǎng)景接口請(qǐng)求失敗 |
AIDIALOG011 | 生成推薦表達(dá)接口請(qǐng)求失敗 |
AIDIALOG012 | 生成對(duì)話(huà)接口請(qǐng)求失敗 |
AIDIALOG013 | history字段異常: 結(jié)構(gòu)異常、超出對(duì)話(huà)輪次限制,生成報(bào)告接口該字段為空等。 |
AIDIALOG018 | 基礎(chǔ)服務(wù)異常 |
AIDIALOG019 | 請(qǐng)求中包含敏感詞 |
AIDIALOG020 | 系統(tǒng)回話(huà)中包含敏感詞 |
AIDIALOG021 | 總字符數(shù)超出限制 |
AIDIALOG022 | 系統(tǒng)無(wú)結(jié)果 |
AIDIALOG023 | scene字段異常 |
AIDIALOG024 | 不支持的bot取值(scene中的字段) |
常用語(yǔ)言 Demo
Java 示例
口語(yǔ)老師 Java demo
python3 示例
口語(yǔ)老師 python demo
go 示例
口語(yǔ)老師 go demo