languageAssistant.vue 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748
  1. <template>
  2. <div class="languageAssistant">
  3. <div class="la_coco">
  4. <el-image
  5. style="width: 105px; height: 105px"
  6. v-show="showIndex == 2"
  7. :src="require('../../../assets/icon/course/aiVanish.svg')"
  8. fit="fill"
  9. ></el-image>
  10. <el-image
  11. style="width: 105px; height: 105px;transform: scale(1.7,1.7);"
  12. v-show="showIndex == 0"
  13. :src="require('../../../assets/icon/course/aiWait2.svg')"
  14. fit="fill"
  15. ></el-image>
  16. <el-image
  17. style="width: 105px; height: 105px"
  18. v-show="showIndex == 1"
  19. :src="require('../../../assets/icon/course/aiTalk.svg')"
  20. fit="fill"
  21. ></el-image>
  22. </div>
  23. <div
  24. class="la_message"
  25. :style="show ? '' : 'height:calc(100% - 170px - 200px - 40px)'"
  26. ref="messageRef"
  27. >
  28. <div class="la_m_talk" v-if="show && openMessage">
  29. <div v-if="showTextIndex == 0" v-html="htmlContent(aiText)"></div>
  30. <div v-if="showTextIndex == 1">{{ userText }}</div>
  31. <div v-if="showTextIndex == 2">正在组织语言...</div>
  32. </div>
  33. <div class="la_m_talk" v-if="!openMessage">
  34. <div>你好,我是可可同学,是个小小百事通,你有什么想和我聊一聊?</div>
  35. </div>
  36. </div>
  37. <div class="la_btn">
  38. <div class="la_b_noTel" v-if="!show">
  39. <el-tooltip class="item" effect="light" content="通话" placement="top">
  40. <span>
  41. <svg
  42. @click.stop="recordStart"
  43. t="1721367811838"
  44. viewBox="0 0 1024 1024"
  45. version="1.1"
  46. xmlns="http://www.w3.org/2000/svg"
  47. p-id="4525"
  48. width="64"
  49. height="64"
  50. >
  51. <path
  52. d="M65.771 502.182c0 246.632 199.937 446.566 446.57 446.565 246.613 0 446.549-199.934 446.551-446.565 0-246.633-199.936-446.549-446.55-446.55-246.635 0.001-446.57 199.917-446.571 446.55z m651.885-173.77c31.489 31.473 1.642 148.828-114.292 264.773C487.396 709.131 370.06 738.929 338.589 707.492c-27.278-27.315-74.96-60.574-12.892-110.423 62.087-49.886 79.429-25.343 107.582 2.772 19.674 19.711 69.436-21.368 112.394-64.328 42.94-42.996 83.986-92.719 64.368-112.43-28.155-28.153-52.679-45.511-2.792-107.562 49.904-62.049 83.125-14.405 110.406 12.891z"
  53. p-id="4526"
  54. ></path>
  55. </svg>
  56. </span>
  57. </el-tooltip>
  58. </div>
  59. <div class="la_b_isTel" v-else>
  60. <el-tooltip
  61. class="item"
  62. effect="light"
  63. content="暂停语音"
  64. placement="top"
  65. v-if="talkLoading"
  66. >
  67. <span @click.stop="stopTalk">
  68. <img :src="require('../../../assets/icon/course/stop1.png')" />
  69. <!-- <svg
  70. @click.stop="recordStart"
  71. t="1721367811838"
  72. viewBox="0 0 1024 1024"
  73. version="1.1"
  74. xmlns="http://www.w3.org/2000/svg"
  75. p-id="4525"
  76. width="64"
  77. height="64"
  78. >
  79. <path
  80. d="M65.771 502.182c0 246.632 199.937 446.566 446.57 446.565 246.613 0 446.549-199.934 446.551-446.565 0-246.633-199.936-446.549-446.55-446.55-246.635 0.001-446.57 199.917-446.571 446.55z m651.885-173.77c31.489 31.473 1.642 148.828-114.292 264.773C487.396 709.131 370.06 738.929 338.589 707.492c-27.278-27.315-74.96-60.574-12.892-110.423 62.087-49.886 79.429-25.343 107.582 2.772 19.674 19.711 69.436-21.368 112.394-64.328 42.94-42.996 83.986-92.719 64.368-112.43-28.155-28.153-52.679-45.511-2.792-107.562 49.904-62.049 83.125-14.405 110.406 12.891z"
  81. p-id="4526"
  82. ></path>
  83. </svg> -->
  84. </span>
  85. </el-tooltip>
  86. <el-tooltip
  87. class="item"
  88. effect="light"
  89. content="朗读"
  90. placement="top"
  91. v-else
  92. >
  93. <span class="readAloud" @click.stop="talkAllText">
  94. <img :src="require('../../../assets/icon/course/start2.png')" />
  95. <!-- <svg
  96. t="1721117381559"
  97. viewBox="0 0 1024 1024"
  98. version="1.1"
  99. xmlns="http://www.w3.org/2000/svg"
  100. p-id="12941"
  101. width="64"
  102. height="64"
  103. >
  104. <path
  105. d="M161.2 839.9v-654c0-56.1 60.7-91.1 109.3-63.1l566.3 327c48.6 28 48.6 98.1 0 126.2L270.4 903c-48.5 28-109.2-7.1-109.2-63.1z"
  106. p-id="12942"
  107. ></path>
  108. </svg> -->
  109. </span>
  110. </el-tooltip>
  111. <el-tooltip class="item" effect="light" content="挂断" placement="top">
  112. <svg
  113. @click.stop="stopRecord"
  114. t="1721367811838"
  115. viewBox="0 0 1024 1024"
  116. version="1.1"
  117. xmlns="http://www.w3.org/2000/svg"
  118. p-id="4525"
  119. width="64"
  120. height="64"
  121. >
  122. <path
  123. d="M65.771 502.182c0 246.632 199.937 446.566 446.57 446.565 246.613 0 446.549-199.934 446.551-446.565 0-246.633-199.936-446.549-446.55-446.55-246.635 0.001-446.57 199.917-446.571 446.55z m651.885-173.77c31.489 31.473 1.642 148.828-114.292 264.773C487.396 709.131 370.06 738.929 338.589 707.492c-27.278-27.315-74.96-60.574-12.892-110.423 62.087-49.886 79.429-25.343 107.582 2.772 19.674 19.711 69.436-21.368 112.394-64.328 42.94-42.996 83.986-92.719 64.368-112.43-28.155-28.153-52.679-45.511-2.792-107.562 49.904-62.049 83.125-14.405 110.406 12.891z"
  124. p-id="4526"
  125. ></path>
  126. </svg>
  127. </el-tooltip>
  128. <el-tooltip class="item" effect="light" content="中断" placement="top">
  129. <span @click.stop="interrupt">
  130. <img :src="require('../../../assets/icon/course/stop2.png')" />
  131. <!-- <svg
  132. t="1721372012678"
  133. class="icon"
  134. viewBox="0 0 1024 1024"
  135. version="1.1"
  136. xmlns="http://www.w3.org/2000/svg"
  137. p-id="5554"
  138. width="64"
  139. height="64"
  140. >
  141. <path
  142. d="M885.6 413.8c-32.3 0-60.1 19.8-71.9 47.9h-18.1c-16.6 0-30 13.4-30 30s13.4 30 30 30h18.1c11.8 28.1 39.5 47.9 71.9 47.9 42.9 0 77.9-34.9 77.9-77.9 0-42.9-35-77.9-77.9-77.9zM690.4 461.7h-21.1c-16.6 0-30 13.4-30 30s13.4 30 30 30h21.1c16.6 0 30-13.4 30-30s-13.4-30-30-30zM564.1 461.7h-10c-16.6 0-30 13.4-30 30s13.4 30 30 30h10c16.6 0 30-13.4 30-30s-13.4-30-30-30zM709.7 115.7c-13.7-9.4-32.3-5.9-41.7 7.8L436.5 461.8c-0.8-0.1-1.6-0.1-2.3-0.1H212.5c-11.8-28.1-39.5-47.9-71.9-47.9-39.4 0-72.1 29.5-77.2 67.5-1.2 3.2-1.8 6.7-1.8 10.3 0 3.6 0.6 7.1 1.8 10.3 5.1 38.1 37.7 67.5 77.2 67.5 32.3 0 60.1-19.8 71.9-47.9h183l-240.1 351c-9.4 13.7-5.9 32.3 7.8 41.7 5.2 3.5 11.1 5.2 16.9 5.2 9.6 0 19-4.6 24.8-13.1l512.6-749c9.4-13.5 5.9-32.2-7.8-41.6z"
  143. p-id="5555"
  144. ></path>
  145. </svg> -->
  146. </span>
  147. </el-tooltip>
  148. </div>
  149. <div class="openMessage" v-if="show">
  150. <el-checkbox v-model="openMessage">开启字幕</el-checkbox>
  151. </div>
  152. </div>
  153. <!-- 录音转文字 -->
  154. <iframe
  155. allow="camera *; microphone *;display-capture;midi;encrypted-media;"
  156. src="https://beta.cloud.cocorobo.cn/browser/public/index.html"
  157. ref="iiframe"
  158. v-show="false"
  159. ></iframe>
  160. <!-- 文字转语音-->
  161. <iframe
  162. allow="camera *; microphone *;display-capture;midi;encrypted-media;"
  163. src="https://beta.cloud.cocorobo.cn/browser/public/index1.html"
  164. ref="iiframe2"
  165. v-show="false"
  166. ></iframe>
  167. </div>
  168. </template>
  169. <script>
  170. import { v4 as uuidv4 } from "uuid";
  171. import MarkdownIt from "markdown-it";
  172. export default {
  173. props: {},
  174. data() {
  175. return {
  176. show: false,
  177. showIndex: 2, //0 :在说话 1 : 接收 2:待命
  178. aiStatus: 0,
  179. aiText: "我是可可同学,我是个小小百事通,你有什么想和我聊一聊?",
  180. userText: "",
  181. showTextIndex: 0, //0:ai,1:用户, 2:组织语言 3: 无
  182. timer: null,
  183. isOpen: false,
  184. userId: this.$route.query.userid,
  185. chatLoading: false,
  186. talkLoading: false,
  187. source: null,
  188. talkTextList: [],
  189. openMessage: true
  190. };
  191. },
  192. computed: {
  193. htmlContent() {
  194. const md = new MarkdownIt();
  195. return _md => {
  196. return md.render(_md);
  197. };
  198. }
  199. },
  200. methods: {
  201. scrollBottom() {
  202. this.$nextTick(() => {
  203. this.$refs.messageRef.scrollTop = this.$refs.messageRef.scrollHeight;
  204. });
  205. },
  206. talkAllText() {
  207. if (this.talkLoading && this.aiText == "") return;
  208. let _resultText = this.removeMarkdown(this.aiText);
  209. this.talkTextList.push(_resultText);
  210. this.talkText();
  211. },
  212. recordStart(_text) {
  213. try {
  214. let iiframe = this.$refs["iiframe"];
  215. iiframe.contentWindow.window.document.getElementById(
  216. "languageOptions"
  217. ).selectedIndex = 2; //普通话
  218. iiframe.contentWindow.testdoContinuousPronunciationAssessment();
  219. // return
  220. var OpenCC = require("opencc-js");
  221. let converter = OpenCC.Converter({
  222. from: "hk",
  223. to: "cn"
  224. });
  225. this.show = true;
  226. this.showIndex = 0;
  227. this.showTextIndex = 0;
  228. this.chatLoading = false;
  229. this.talkLoading = false;
  230. this.isOpen = true;
  231. this.show = true;
  232. this.aiText = "我是可可同学,我是个小小百事通,你有什么想和我聊一聊?";
  233. iiframe.contentWindow.onRecognizedResult = e => {
  234. let _msg = converter(e.privText);
  235. console.log("👇");
  236. console.log(_msg);
  237. // _msg = converter(_msg)
  238. if (!_msg) return console.log("输出为空");
  239. if (this.show == true) {
  240. if (
  241. _msg.indexOf(converter("可可同学")) != -1 &&
  242. _msg.indexOf(converter("停止")) != -1
  243. ) {
  244. this.stopTalk();
  245. } else if (
  246. this.showTextIndex == 2 ||
  247. this.chatLoading ||
  248. this.talkLoading
  249. ) {
  250. return console.log("组织语言中");
  251. // }else if(_msg.indexOf('可可同学')!=-1 && _msg.indexOf("停止")!=-1){
  252. // this.stopTalk();
  253. } else {
  254. this.showTextIndex = 1;
  255. this.aiText = "";
  256. this.userText += _msg;
  257. this.scrollBottom();
  258. this.aiStatus = 1;
  259. if (this.timer) {
  260. clearTimeout(this.timer);
  261. this.timer = null;
  262. }
  263. this.timer = setTimeout(() => {
  264. if (this.userText.indexOf(converter("关闭语音助手")) != -1) {
  265. // return setTimeout(()=>{
  266. this.show = false;
  267. this.showTextIndex = 3;
  268. this.showIndex = 2;
  269. this.aiStatus = 2;
  270. this.aiText = "";
  271. this.userText = "";
  272. this.stopRecord();
  273. return;
  274. // },1000)
  275. }
  276. this.showTextIndex = 2;
  277. this.aiText = "";
  278. let regExp = new RegExp(
  279. converter("计时") + "(.+)" + converter("分钟")
  280. );
  281. if (false && regExp.test(this.userText)) {
  282. // setTimeout(() => {
  283. // let _number = this.userText.match(regExp)[1];
  284. // let _time = 0;
  285. // if (!/^\d+$/.test(_number)) {
  286. // _time = this.chineseToNumber(_number) * 60;
  287. // } else {
  288. // _time = parseInt(_numberList[1]) * 60;
  289. // }
  290. // this.$emit("startTime", _time);
  291. // this.aiStatus = 0;
  292. // this.showTextIndex = 0;
  293. // this.aiText =
  294. // "好的,我已为您计时" +
  295. // this.userText.match(regExp)[1] +
  296. // "分钟。";
  297. // this.userText = "";
  298. // this.timer = setTimeout(() => {
  299. // this.showTextIndex = 3;
  300. // this.aiStatus = 2;
  301. // this.aiText = "";
  302. // this.userText = "";
  303. // }, 3000);
  304. // }, 2000);
  305. } else {
  306. this.chatLoading = true;
  307. const _uuid = uuidv4();
  308. let params = {
  309. assistant_id: "f8e1ebb2-2e0d-11ef-8bf4-12e77c4cb76b",
  310. userId: this.userId,
  311. message: this.userText,
  312. session_name: _uuid + "-qgt",
  313. uid: _uuid,
  314. file_ids: [],
  315. model: "gpt-4o-2024-08-06"
  316. };
  317. this.ajax
  318. // .post("https://claude3.cocorobo.cn/chat", params)
  319. // .post("https://gpt4.cocorobo.cn/chat", params)
  320. .post(
  321. "https://gpt4.cocorobo.cn/ai_agent_park_chat_new",
  322. params
  323. )
  324. .then(res => {
  325. if (
  326. converter(res.data.FunctionResponse.result) ==
  327. converter("发送成功")
  328. ) {
  329. this.userText = "";
  330. this.showIndex = 0;
  331. } else {
  332. // this.$message.warning(res.data.FunctionResponse.result);
  333. console.log(res.data.FunctionResponse.result);
  334. this.chatLoading = false;
  335. this.aiStatus = 0;
  336. this.showTextIndex = 0;
  337. this.showIndex = 0;
  338. this.aiText = "对不起,我无法理解您的问题,请重新提问";
  339. // this.timer = setTimeout(() => {
  340. // this.showTextIndex = 3;
  341. // this.aiStatus = 2;
  342. // this.aiText = "";
  343. // this.userText = "";
  344. // }, 3000);
  345. }
  346. })
  347. .catch(e => {
  348. console.log(e);
  349. this.chatLoading = false;
  350. this.aiStatus = 0;
  351. this.showTextIndex = 0;
  352. this.showIndex = 0;
  353. this.aiText = "对不起,我无法理解您的问题,请重新提问";
  354. // this.timer = setTimeout(() => {
  355. // this.showTextIndex = 3;
  356. // this.aiStatus = 2;
  357. // this.aiText = "";
  358. // this.userText = "";
  359. // }, 3000);
  360. });
  361. // 通过流获取ai对话数据
  362. this.getAtAuContent(_uuid);
  363. }
  364. }, 5000);
  365. }
  366. } else {
  367. console.log("不响应");
  368. }
  369. };
  370. } catch (error) {
  371. console.log(error)
  372. this.recordStart();
  373. }
  374. },
  375. stopRecord() {
  376. this.$parent.changeItemType(1);
  377. this.show = false;
  378. this.showIndex = 2;
  379. let iiframe = this.$refs["iiframe"];
  380. iiframe.contentWindow.window.document
  381. .getElementById("scenarioStopButton")
  382. .click();
  383. if (this.talkLoading) {
  384. this.stopTalk();
  385. }
  386. // this.stopTalk();
  387. // 录音借宿
  388. iiframe.contentWindow.onSessionStopped = (s, e) => {
  389. this.isOpen = false;
  390. this.show = false;
  391. this.showTextIndex = 3;
  392. this.showIndex = 2;
  393. this.$message.success("已关闭语音助手");
  394. if (this.talkLoading) {
  395. this.$refs.iiframe2.contentWindow.closesynthesizer();
  396. }
  397. this.userText = "";
  398. this.aiText = "";
  399. };
  400. },
  401. chineseToNumber(chinese) {
  402. var OpenCC = require("opencc-js");
  403. let converter = OpenCC.Converter({
  404. from: "hk",
  405. to: "cn"
  406. });
  407. chinese = converter(chinese);
  408. const chineseNumbers = {
  409. 零: 0,
  410. 一: 1,
  411. 二: 2,
  412. 三: 3,
  413. 四: 4,
  414. 五: 5,
  415. 六: 6,
  416. 七: 7,
  417. 八: 8,
  418. 九: 9,
  419. 十: 10,
  420. 百: 100,
  421. 千: 1000,
  422. 万: 10000,
  423. 亿: 100000000
  424. };
  425. let result = 0;
  426. let tempNum = 0; // 用于累积处理
  427. let sectionNum = 0; // 每个段的值
  428. for (let i = 0; i < chinese.length; i++) {
  429. const char = chinese[i];
  430. const num = chineseNumbers[char];
  431. if (num === undefined) {
  432. throw new Error(`Unexpected character: ${char}`);
  433. }
  434. if (
  435. num === 10 ||
  436. num === 100 ||
  437. num === 1000 ||
  438. num === 10000 ||
  439. num === 100000000
  440. ) {
  441. if (tempNum === 0) tempNum = 1; // 如果前面没有数,默认是1
  442. tempNum *= num;
  443. if (num === 10000 || num === 100000000) {
  444. sectionNum += tempNum;
  445. result += sectionNum;
  446. tempNum = 0;
  447. sectionNum = 0;
  448. }
  449. } else {
  450. tempNum += num;
  451. }
  452. }
  453. result += sectionNum + tempNum;
  454. return result;
  455. },
  456. removeMarkdown(text) {
  457. return text
  458. .replace(/[#*_~`>+\-]/g, "") // 移除 #、*、_、~、`、>、+、- 符号
  459. .replace(/!\[.*?\]\(.*?\)/g, "") // 移除图片
  460. .replace(/\[.*?\]\(.*?\)/g, "") // 移除链接
  461. .replace(/```[\s\S]*?```/g, "") // 移除代码块(不使用 s 标志)
  462. .replace(/`[^`]*`/g, "") // 移除行内代码
  463. .replace(/\d+\./g, "") // 移除有序列表
  464. .replace(/^\s*[-*+]\s+/gm, "") // 移除无序列表
  465. .replace(/\s+/g, " ") // 将多个空白字符替换为一个空格
  466. .trim(); // 去除字符串两端的空白字符
  467. },
  468. getAtAuContent(_uid) {
  469. this.source = new EventSource(
  470. `https://gpt4.cocorobo.cn/question/${_uid}`
  471. );
  472. //http://gpt4.cocorobo.cn:8011/question/ https://gpt4.cocorobo.cn/question/
  473. let _allText = "";
  474. let _mdText = "";
  475. let _talkText = "";
  476. // let _talkIndex = 0;
  477. // const md = new MarkdownIt();
  478. this.source.onmessage = _e => {
  479. this.showIndex = 0;
  480. let _eData = JSON.parse(_e.data);
  481. if (_eData.content.replace("'", "").replace("'", "") == "[DONE]") {
  482. this.source.close();
  483. this.source = null;
  484. let _result = [];
  485. if ("result" in _eData) {
  486. _result = _eData.result;
  487. for (let i = 0; i < _result.length; i++) {
  488. _mdText = _mdText.replace(_result[i].text, _result[i].fileName);
  489. }
  490. }
  491. _mdText = _mdText.replace("_", "");
  492. this.aiText = _mdText;
  493. this.scrollBottom();
  494. if (_talkText != "") {
  495. let _resultText = this.removeMarkdown(_talkText);
  496. this.talkTextList.push(_resultText);
  497. _talkText = "";
  498. if (!this.talkLoading) this.talkText();
  499. }
  500. this.chatLoading = false;
  501. } else {
  502. // _talkIndex+=1;
  503. let _text = _eData.content.replace("'", "").replace("'", "");
  504. if (_allText == "") {
  505. _allText = _text.replace(/^\n+/, ""); //去掉回复消息中偶尔开头就存在的连续换行符
  506. _talkText += _text.replace(/^\n+/, "");
  507. } else {
  508. _allText += _text;
  509. _talkText += _text;
  510. }
  511. `~`;
  512. _mdText = _allText + "_";
  513. _mdText = _mdText.replace(/\\n/g, "\n");
  514. _mdText = _mdText.replace(/\\/g, "");
  515. if (_allText.split("```").length % 2 == 0) _mdText += "\n```\n";
  516. this.aiText = _mdText;
  517. this.showTextIndex = 0;
  518. this.scrollBottom();
  519. if (/[,。:;?!)]/.test(_talkText)) {
  520. let _resultText = this.removeMarkdown(_talkText);
  521. this.talkTextList.push(_resultText);
  522. _talkText = "";
  523. if (!this.talkLoading) this.talkText();
  524. }
  525. }
  526. };
  527. },
  528. talkText() {
  529. let _text = this.talkTextList.shift();
  530. let _talkTextIiframe2 = this.$refs.iiframe2;
  531. if (_text) {
  532. this.talkLoading = true;
  533. if (this.timer) {
  534. clearTimeout(this.timer);
  535. this.timer = null;
  536. }
  537. console.log(`👉转语音:${_text}`);
  538. _talkTextIiframe2.contentWindow.texttospeech(
  539. _text,
  540. this.talkText,
  541. this.endTalk
  542. );
  543. } else {
  544. _talkTextIiframe2.contentWindow.closesynthesizer();
  545. }
  546. },
  547. endTalk() {
  548. console.log("👉转语音结束👈");
  549. this.talkLoading = false;
  550. },
  551. stopTalk() {
  552. // return this.$message.info("停止")
  553. this.talkTextList = [];
  554. try {
  555. let _talkTextIiframe2 = this.$refs.iiframe2;
  556. _talkTextIiframe2.contentWindow.pausesynthesizer();
  557. _talkTextIiframe2.contentWindow.closesynthesizer();
  558. this.talkLoading = false;
  559. } catch (error) {
  560. this.talkLoading = false;
  561. }
  562. },
  563. interrupt() {
  564. // return this.$message.info("打断")
  565. if (this.source) {
  566. try {
  567. this.source.close();
  568. } catch (error) {
  569. console.log(error);
  570. }
  571. }
  572. this.stopTalk();
  573. }
  574. },
  575. mounted() {
  576. this.$nextTick(() => {
  577. this.recordStart();
  578. });
  579. }
  580. };
  581. </script>
  582. <style scoped>
  583. .languageAssistant {
  584. width: 100%;
  585. height: 100%;
  586. border-radius: 10px 0 0 10px;
  587. /* background-image: linear-gradient(to top, #007adf 0%, #00ecbc 100%);
  588. */
  589. background-image: url("../../../assets/icon/course/aibgImage.png");
  590. background-repeat: no-repeat;
  591. background-size: 100% 100%;
  592. /* display: flex;
  593. flex-direction: column;
  594. align-items: center; */
  595. /* justify-content: center; */
  596. overflow: auto;
  597. text-align: center;
  598. }
  599. .la_coco {
  600. height: 170px;
  601. width: 100%;
  602. display: flex;
  603. justify-content: center;
  604. align-items: flex-end;
  605. }
  606. .la_message {
  607. /* max-height: 400px; */
  608. /* min-height: 400px; */
  609. height: auto;
  610. max-height: calc(100% - 170px - 200px - 40px);
  611. width: 100%;
  612. /* display: flex; */
  613. padding: 10px;
  614. box-sizing: border-box;
  615. margin: 20px 0;
  616. overflow: auto;
  617. }
  618. .la_m_talk {
  619. /* width:100%; */
  620. height: auto;
  621. /* max-height: calc(100% - 170px - 200px - 40px); */
  622. box-sizing: border-box;
  623. }
  624. .la_m_talk > div {
  625. /* padding: 10px; */
  626. padding: 20px 24px 20px 24px;
  627. box-sizing: border-box;
  628. border-radius: 12px;
  629. text-align: left;
  630. background: #00000042;
  631. color: #fff;
  632. }
  633. .la_btn {
  634. height: 220px;
  635. width: 100%;
  636. display: flex;
  637. flex-direction: column;
  638. justify-content: center;
  639. align-items: center;
  640. }
  641. .la_b_noTel {
  642. width: 100%;
  643. height: 100%;
  644. display: flex;
  645. justify-content: center;
  646. align-items: center;
  647. }
  648. .la_b_noTel > span > svg {
  649. fill: #52c41a;
  650. width: 80px;
  651. height: 80px;
  652. cursor: pointer;
  653. }
  654. .la_b_isTel {
  655. width: 100%;
  656. height: 100%;
  657. display: flex;
  658. justify-content: center;
  659. align-items: center;
  660. }
  661. .la_b_isTel > svg {
  662. fill: #ff0e55;
  663. width: 80px;
  664. height: 80px;
  665. cursor: pointer;
  666. transform: rotate(-135deg);
  667. }
  668. .la_b_isTel > span > svg,
  669. img {
  670. cursor: pointer;
  671. }
  672. .la_b_isTel > span {
  673. width: 56px;
  674. height: 56px;
  675. display: flex;
  676. justify-content: center;
  677. align-items: center;
  678. margin: 0 30px;
  679. }
  680. /* .readAloud {
  681. border-radius: 100%;
  682. background-color: #517291;
  683. cursor: pointer;
  684. box-shadow: 0px 2px 4px -1px #0000001f;
  685. box-shadow: 0px 4px 5px 0px #00000014;
  686. box-shadow: 0px 1px 10px 0px #0000000d;
  687. }
  688. .readAloud > svg {
  689. width: 22px;
  690. height: 22px;
  691. fill: #fff;
  692. } */
  693. .openMessage {
  694. width: 100%;
  695. height: auto;
  696. display: flex;
  697. justify-content: center;
  698. margin-top: -30px;
  699. }
  700. .openMessage >>> .el-checkbox {
  701. display: flex;
  702. align-items: center;
  703. justify-content: center;
  704. color: #fff !important;
  705. }
  706. .openMessage >>> .el-checkbox > .el-checkbox__label {
  707. color: #fff !important;
  708. }
  709. .openMessage >>> .el-checkbox > .el-checkbox__input > .el-checkbox__inner {
  710. color: #fff !important;
  711. background: none !important;
  712. border-color: #fff !important;
  713. border-radius: 100% !important;
  714. }
  715. </style>