|
@@ -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(() => {
|