AI销管
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.
 
 
 
 

202 wiersze
4.8 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. "characterConfig": {
  25. "characters": {
  26. "furao-casual-v4": {
  27. "name": "furao-casual-v4-half",
  28. "id": "furao-casual-v4",
  29. "frameWidth": 568,
  30. "frameHeight": 1050,
  31. "faceWidth": 160,
  32. "faceHeight": 250,
  33. "facePositionLeft": 475,
  34. "facePositionTop": 240,
  35. "facePositionLeftOffset": -272,
  36. "facePositionTopOffset": -160,
  37. "frameRate": 25,
  38. "defaultIdle": "A-idle",
  39. "idles": {
  40. "A-idle": {
  41. "id": "A-idle",
  42. "version": 4,
  43. "frameImageLength": 260,
  44. "frameImageType": "webp",
  45. "frameImageBackupType": "png",
  46. "resetFrameSingleNum": 8,
  47. "resetFrames": [
  48. 7,
  49. 15,
  50. 23,
  51. 31,
  52. 39,
  53. 47,
  54. 55,
  55. 63,
  56. 71,
  57. 79,
  58. 87,
  59. 95,
  60. 103,
  61. 111,
  62. 119,
  63. 127,
  64. 135,
  65. 143,
  66. 151,
  67. 159,
  68. 167,
  69. 175,
  70. 183,
  71. 191,
  72. 199,
  73. 207,
  74. 215,
  75. 223,
  76. 231,
  77. 239,
  78. 247,
  79. 255
  80. ]
  81. }
  82. },
  83. "gestures": {},
  84. "crops": {}
  85. }
  86. },
  87. "sourcePath": "https://commercial-cdn.xiaoice.com/assets/images/characters",
  88. "batch": 16,
  89. "minLoadFrameNum": 50
  90. },
  91. "chatConfig": {
  92. "class": "CXHubChat",
  93. "url": "https://commercial-fab.xiaoice.com/api/hub/organizations/org-qufangwang/agents/64af7b926e1ba4813c4bd6d7/environments/draft/sessions",
  94. "defaultReply": [{
  95. "text": "对不起,我没听清~",
  96. "gesture": ""
  97. }],
  98. "csChatUrl": "https://commercial-fab.xiaoice.com/api/hub/organizations/org-qufangwang/characters//sessions"
  99. },
  100. "logConfig": {
  101. "class": "AliTraceLogger",
  102. "metaData": {
  103. "role": "prod",
  104. "organizationId": "org-qufangwang",
  105. "partnerId": "dh-api",
  106. "agentId": "64af7b926e1ba4813c4bd6d7"
  107. }
  108. },
  109. "talkConfig": {
  110. "class": "CarouselTalk",
  111. "url": "https://commercial-fab.xiaoice.com",
  112. "options": {
  113. "path": "/api/v1/carousel/avatars/furao-casual-v4/socket.io",
  114. "wsPath": "/api/v1/carousel/avatars/furao-casual-v4/websocket",
  115. "transports": [
  116. "websocket",
  117. "polling"
  118. ],
  119. "query": "?image_format=.webp&voice_id=64af7b92a9d616bd022f6b6b"
  120. },
  121. "maxRetryTime": 5,
  122. "retryTimeInterval": 100
  123. }
  124. },
  125. mockReplies: ["嘻嘻", "没听清", "你真厉害"],
  126. plugin: null,
  127. }
  128. },
  129. onLoad() {
  130. let _this = this
  131. this.plugin = requirePlugin("digital-human-plugin").api;
  132. this.plugin.init({
  133. ...this.config,
  134. onReceivedAsrText: (text) => {
  135. console.log("获取文本:", text);
  136. setTimeout(this.customChat);
  137. // 返回false拦截默认行为(不调用内置chat接口和播放结果)
  138. return false;
  139. },
  140. onSuccess: () => {
  141. const texts = [{
  142. text: `你好啊`,
  143. gesture: ""
  144. },
  145. {
  146. text: `我叫陈喆玲`,
  147. gesture: ""
  148. },
  149. ];
  150. async function talk(texts) {
  151. // 轮播文本内容
  152. for (let i = 0; i < texts.length; i++) {
  153. await _this.plugin.human.talkAsync(
  154. texts[i].text,
  155. texts[i].gesture, {
  156. onTalkStartOnce: (playInfo) => {
  157. console.log("播放句子:", playInfo);
  158. },
  159. onTalkEndOnce: () => {
  160. console.log("播放句子完成");
  161. },
  162. }
  163. );
  164. console.log("完成时间:", Date.now());
  165. }
  166. }
  167. talk(texts);
  168. },
  169. })
  170. // #ifdef MP-WEIXIN
  171. // 内存告警处理
  172. wx.onMemoryWarning((level) => {
  173. this.plugin.clearCache()
  174. })
  175. wx.setInnerAudioOption({
  176. // IOS静音键的情况下允许播放声音
  177. obeyMuteSwitch: false,
  178. // 播放声音时中断其他app端声音
  179. mixWithOther: false,
  180. })
  181. // #endif
  182. },
  183. methods: {
  184. // // 模拟聊天回复接口
  185. async getReply(text) {
  186. return await this.mockReplies[Math.floor(Math.random() * this.mockReplies.length)]
  187. },
  188. async customChat(text) {
  189. // // 调用自定义的api获取回复
  190. const reply = await this.getReply(text)
  191. // // 主动调用播放接口,并等待播放完成
  192. await this.plugin.human?.talkAsync(reply)
  193. console.log("回复完成");
  194. }
  195. }
  196. }