SanHQin 11 月之前
父節點
當前提交
4e655c7edb
共有 1 個文件被更改,包括 50 次插入42 次删除
  1. 50 42
      src/components/classRoomHelper/component/levitatedSphere.vue

+ 50 - 42
src/components/classRoomHelper/component/levitatedSphere.vue

@@ -73,59 +73,67 @@ export default {
   },
   methods: {
     recordStart() {
-      let iiframe = this.$refs["iiframe"];
+      try {
+				let iiframe = this.$refs["iiframe"];
       iiframe.contentWindow.window.document.getElementById(
         "languageOptions"
       ).selectedIndex = 2; //普通话
       iiframe.contentWindow.testdoContinuousPronunciationAssessment();
       iiframe.contentWindow.onRecognizedResult = e => {
-      let _msg = e.privText;
-      // let _msg = _text;
-      // console.log("👇");
-      // console.log(_msg);
-      if (_msg.indexOf("可可同学") != -1 && !this.show) {
-        this.aiText = "您好,我是小可,有什么可以帮助您的?";
-        this.aiStatus = 0;
-        this.showIndex = 0;
-        this.show = true;
-        console.log("已唤醒可可同学");
-      } else if (this.show == true) {
-        if (this.showTextIndex == 2) {
-          console.log("ai在组织语言");
-        } else {
-          this.showTextIndex = 1;
-          this.aiText = "";
-          this.userText += _msg;
-          this.aiStatus = 1;
-          if (this.timer) {
-            clearTimeout(this.timer);
-            this.timer = null;
-          }
-          this.timer = setTimeout(() => {
-            this.showTextIndex = 2;
+        let _msg = e.privText;
+        // let _msg = _text;
+        // console.log("👇");
+        // console.log(_msg);
+        if (_msg.indexOf("可可同学") != -1 && !this.show) {
+          this.aiText = "您好,我是小可,有什么可以帮助您的?";
+          this.aiStatus = 0;
+          this.showIndex = 0;
+          this.show = true;
+          console.log("已唤醒可可同学");
+        } else if (this.show == true) {
+          if (this.showTextIndex == 2) {
+            console.log("ai在组织语言");
+          } else {
+            this.showTextIndex = 1;
             this.aiText = "";
-            console.log("开始思考");
-            setTimeout(() => {
-              this.aiStatus = 0;
-              this.showTextIndex = 0;
-              this.aiText = "不知道,请您稍后再问...。";
-              this.timer = setTimeout(() => {
-                this.showTextIndex = 3;
-                this.aiStatus = 2;
-                this.aiText = "";
-                this.userText = "";
-              }, 5000);
-            }, 3000);
-          }, 5000);
+            this.userText += _msg;
+            this.aiStatus = 1;
+            if (this.timer) {
+              clearTimeout(this.timer);
+              this.timer = null;
+            }
+            this.timer = setTimeout(() => {
+              this.showTextIndex = 2;
+              this.aiText = "";
+              console.log("开始思考");
+              setTimeout(() => {
+                this.aiStatus = 0;
+                this.showTextIndex = 0;
+                this.aiText = "不知道,请您稍后再问...。";
+                this.timer = setTimeout(() => {
+                  this.showTextIndex = 3;
+                  this.aiStatus = 2;
+                  this.aiText = "";
+                  this.userText = "";
+                }, 5000);
+              }, 3000);
+            }, 5000);
+          }
+        } else {
+          console.log("不响应");
         }
-      } else {
-        console.log("不响应");
-      }
       };
+			} catch (error) {
+				console.log("ai录音报错👇")
+				console.log(error)
+				setTimeout(()=>{
+					this.recordStart();
+				},1000)
+			}
     }
   },
   mounted() {
-		this.recordStart();
+    this.recordStart();
     // setTimeout(() => {
     //   this.recordStart("嘿哟黑");
     //   setTimeout(() => {