AI销管
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 
 

225 行
5.2 KiB

  1. module.exports = {
  2. data() {
  3. return {
  4. config: {
  5. "asrConfig": {
  6. "class": "TencentASR",
  7. "secretKey": "",
  8. "secretId": "AKIDyvwuvrfikhYK1dDj9Vlv154zmVAjFdt0",
  9. "appId": 1310500600,
  10. "partnerId": "0002",
  11. "signatureUrl": "https://commercial-integration-asr-int-api.xiaoice.com/api/v3/asr/tencentSignature",
  12. "hotWordId": "2ab7be50d11f11ecbfd6525400aec391",
  13. "silenceTime": 240,
  14. "engineModelType": "16k_zh",
  15. "needVad": 1,
  16. "filterDirty": 1,
  17. "filterModal": 0,
  18. "filterPunc": 1,
  19. "vadSilenceTime": 240,
  20. "convertNumMode": 1,
  21. "wordInfo": 2
  22. },
  23. "character": "furao-casual-v4",
  24. "autoStart": true,
  25. "characterConfig": {
  26. "characters": {
  27. "furao-casual-v4": {
  28. "name": "furao-casual-v4-half",
  29. "id": "furao-casual-v4",
  30. "frameWidth": 568,
  31. "frameHeight": 1050,
  32. "faceWidth": 160,
  33. "faceHeight": 250,
  34. "facePositionLeft": 475,
  35. "facePositionTop": 240,
  36. "facePositionLeftOffset": -272,
  37. "facePositionTopOffset": -160,
  38. "frameRate": 25,
  39. "defaultIdle": "A-idle",
  40. "idles": {
  41. "A-idle": {
  42. "id": "A-idle",
  43. "version": 4,
  44. "frameImageLength": 260,
  45. "frameImageType": "webp",
  46. "frameImageBackupType": "png",
  47. "resetFrameSingleNum": 8,
  48. "resetFrames": [
  49. 7,
  50. 15,
  51. 23,
  52. 31,
  53. 39,
  54. 47,
  55. 55,
  56. 63,
  57. 71,
  58. 79,
  59. 87,
  60. 95,
  61. 103,
  62. 111,
  63. 119,
  64. 127,
  65. 135,
  66. 143,
  67. 151,
  68. 159,
  69. 167,
  70. 175,
  71. 183,
  72. 191,
  73. 199,
  74. 207,
  75. 215,
  76. 223,
  77. 231,
  78. 239,
  79. 247,
  80. 255
  81. ]
  82. }
  83. },
  84. "gestures": {},
  85. "crops": {}
  86. }
  87. },
  88. "sourcePath": "https://commercial-cdn.xiaoice.com/assets/images/characters",
  89. "batch": 16,
  90. "minLoadFrameNum": 50
  91. },
  92. "chatConfig": {
  93. "class": "CXHubChat",
  94. "url": "https://commercial-fab.xiaoice.com/api/hub/organizations/org-qufangwang/agents/64af7b926e1ba4813c4bd6d7/environments/draft/sessions",
  95. "defaultReply": [{
  96. "text": "对不起,我没听清~",
  97. "gesture": ""
  98. }],
  99. "csChatUrl": "https://commercial-fab.xiaoice.com/api/hub/organizations/org-qufangwang/characters//sessions"
  100. },
  101. "logConfig": {
  102. "class": "AliTraceLogger",
  103. "metaData": {
  104. "role": "prod",
  105. "organizationId": "org-qufangwang",
  106. "partnerId": "dh-api",
  107. "agentId": "64af7b926e1ba4813c4bd6d7"
  108. }
  109. },
  110. "talkConfig": {
  111. "class": "CarouselTalk",
  112. "url": "https://commercial-fab.xiaoice.com",
  113. "options": {
  114. "path": "/api/v1/carousel/avatars/furao-casual-v4/socket.io",
  115. "wsPath": "/api/v1/carousel/avatars/furao-casual-v4/websocket",
  116. "transports": [
  117. "websocket",
  118. "polling"
  119. ],
  120. "query": "?image_format=.webp&voice_id=64af7b92a9d616bd022f6b6b"
  121. },
  122. "maxRetryTime": 5,
  123. "retryTimeInterval": 100
  124. }
  125. },
  126. mockReplies: ["嘻嘻", "没听清", "你真厉害"],
  127. plugin: null,
  128. messageList: [], // 消息列表
  129. }
  130. },
  131. onLoad() {
  132. let _this = this
  133. this.plugin = requirePlugin("digital-human-plugin").api;
  134. console.log(this.plugin, 'this.plugin')
  135. this.plugin.init({
  136. ...this.config,
  137. onReceivedAsrText: (text) => {
  138. console.log("获取文本:", text);
  139. setTimeout(this.customChat);
  140. // 返回false拦截默认行为(不调用内置chat接口和播放结果)
  141. return false;
  142. },
  143. onSuccess: () => {
  144. // async function talk(texts) {
  145. // // 轮播文本内容
  146. // for (let i = 0; i < texts.length; i++) {
  147. // await _this.plugin.human.talkAsync(
  148. // texts[i].text,
  149. // texts[i].gesture, {
  150. // onTalkStartOnce: (playInfo) => {
  151. // console.log("播放句子:", playInfo);
  152. // },
  153. // onTalkEndOnce: () => {
  154. // console.log("播放句子完成");
  155. // },
  156. // }
  157. // );
  158. // console.log("完成时间:", Date.now());
  159. // }
  160. // }
  161. // talk(texts);
  162. },
  163. onError: (res) => {
  164. console.log(res)
  165. }
  166. })
  167. // #ifdef MP-WEIXIN
  168. // 内存告警处理
  169. wx.onMemoryWarning((level) => {
  170. this.plugin.clearCache()
  171. })
  172. wx.setInnerAudioOption({
  173. // IOS静音键的情况下允许播放声音
  174. obeyMuteSwitch: false,
  175. // 播放声音时中断其他app端声音
  176. mixWithOther: false,
  177. })
  178. // #endif
  179. },
  180. methods: {
  181. // // 模拟聊天回复接口
  182. async getReply(text) {
  183. await uni.request({
  184. url: `${this.config.chatConfig.url}/1`,
  185. method: 'POST',
  186. data: {
  187. "text": text,
  188. "currentSceneInfo": {
  189. "sceneId": ""
  190. }
  191. },
  192. success: (res) => {
  193. const replay = res.data.sceneInfo[0].audioText[0]
  194. console.log(res)
  195. console.log(res.data.sceneInfo[0])
  196. this.messageList.push({
  197. direction: 'rside',
  198. text: text
  199. })
  200. console.log(this.messageList)
  201. this.messageList.push({
  202. direction: 'lside',
  203. text: res.data.sceneInfo[0].audioText[0]
  204. })
  205. this.plugin.human?.talkAsync(replay)
  206. this.$forceUpdate()
  207. }
  208. })
  209. },
  210. sendChat(e) {
  211. this.getReply(e.detail.value)
  212. },
  213. }
  214. }