AI销管
No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.
 
 
 
 

225 líneas
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. }
  129. },
  130. onLoad() {
  131. let _this = this
  132. this.plugin = requirePlugin("digital-human-plugin").api;
  133. console.log(this.plugin, 'this.plugin')
  134. this.plugin.init({
  135. ...this.config,
  136. onReceivedAsrText: (text) => {
  137. console.log("获取文本:", text);
  138. setTimeout(this.customChat);
  139. // 返回false拦截默认行为(不调用内置chat接口和播放结果)
  140. return false;
  141. },
  142. onSuccess: () => {
  143. const texts = [{
  144. text: `你好啊`,
  145. gesture: ""
  146. },
  147. {
  148. text: `我叫韩晓东`,
  149. gesture: ""
  150. },
  151. ];
  152. async function talk(texts) {
  153. // 轮播文本内容
  154. for (let i = 0; i < texts.length; i++) {
  155. await _this.plugin.human.talkAsync(
  156. texts[i].text,
  157. texts[i].gesture, {
  158. onTalkStartOnce: (playInfo) => {
  159. console.log("播放句子:", playInfo);
  160. },
  161. onTalkEndOnce: () => {
  162. console.log("播放句子完成");
  163. },
  164. }
  165. );
  166. console.log("完成时间:", Date.now());
  167. }
  168. }
  169. talk(texts);
  170. },
  171. })
  172. // #ifdef MP-WEIXIN
  173. // 内存告警处理
  174. wx.onMemoryWarning((level) => {
  175. this.plugin.clearCache()
  176. })
  177. wx.setInnerAudioOption({
  178. // IOS静音键的情况下允许播放声音
  179. obeyMuteSwitch: false,
  180. // 播放声音时中断其他app端声音
  181. mixWithOther: false,
  182. })
  183. // #endif
  184. },
  185. methods: {
  186. // // 模拟聊天回复接口
  187. async getReply(text) {
  188. return await uni.request({
  189. url: `${this.config.chatConfig.url}/1`,
  190. method: 'POST',
  191. data: {
  192. "text": text,
  193. "currentSceneInfo": {
  194. "sceneId": ""
  195. }
  196. },
  197. success: (res) => {
  198. console.log(res)
  199. }
  200. })
  201. // return await this.mockReplies[Math.floor(Math.random() * this.mockReplies.length)]
  202. },
  203. sendChat(e) {
  204. this.customChat(e.detail.value)
  205. },
  206. async customChat(text) {
  207. console.log(text)
  208. // // 调用自定义的api获取回复
  209. const reply = await this.getReply(text)
  210. // // 主动调用播放接口,并等待播放完成
  211. await this.plugin.human?.talkAsync(reply)
  212. console.log("回复完成");
  213. }
  214. }
  215. }