g-ai-robot3 0.1.5 → 0.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -3
- package/dist/g-ai-robot3.common.js +160 -9
- package/dist/g-ai-robot3.css +1 -1
- package/dist/g-ai-robot3.umd.js +160 -9
- package/dist/g-ai-robot3.umd.min.js +1 -1
- package/dist/media/here.a1c85e18.mp3 +0 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -13,11 +13,11 @@ npm install g-ai-robot3 --save
|
|
|
13
13
|
### 使用
|
|
14
14
|
``` javascript
|
|
15
15
|
import gAiRobot from "g-ai-robot";
|
|
16
|
-
import "g-ai-
|
|
16
|
+
import "g-ai-robot3/dist/g-ai-robot3.css"
|
|
17
17
|
|
|
18
18
|
<g-ai-robot
|
|
19
|
-
:robotCss="{ zIndex: 9999,
|
|
20
|
-
placement="
|
|
19
|
+
:robotCss="{ zIndex: 9999, left: '10px', bottom: '300px' }"
|
|
20
|
+
placement="top-end"
|
|
21
21
|
>
|
|
22
22
|
</g-ai-robot>
|
|
23
23
|
|
|
@@ -35,8 +35,11 @@ import "g-ai-robot/dist/g-ai-robot.css"
|
|
|
35
35
|
| robotCss | 机器人在视口中的位置 | object | - | left: "10px", bottom: "10px" |
|
|
36
36
|
| placement | 问答弹窗位置 |String | left/right/top/bottom/top-start/top-end/bottom-start/bottom-end | top-end |
|
|
37
37
|
| useAudio | 语音功能 |Boolean | true/false | true |
|
|
38
|
+
| space | 监听时间间隔 |Number | - | 3000 |
|
|
39
|
+
| mode | 交互模式 |String | text/audio | text |
|
|
38
40
|
| qaServer | 问答服务地址 |String | - | - |
|
|
39
41
|
| audioServer | 语音服务地址 |String | - | - |
|
|
42
|
+
| wsServer | 语音监听地址 |String | - | - |
|
|
40
43
|
| eventFun | 触发事件 |Array | - | - |
|
|
41
44
|
|
|
42
45
|
|
|
@@ -44,6 +47,7 @@ import "g-ai-robot/dist/g-ai-robot.css"
|
|
|
44
47
|
| 参数 | 说明 | 参数 |
|
|
45
48
|
|---------- |------------------ |--------------|
|
|
46
49
|
| searchText | 问答接口 |接收一个参数:{searchText} 问题的字符串 |
|
|
50
|
+
| startMonitorAudio | 开启语音监听 | - |
|
|
47
51
|
| uploadWavFile | 语音转文字接口 |接收一个参数(formData类型):{modelName,audio} modelName:语音模型(tiny/base/small/medium/large), audio:语音文件流 |
|
|
48
52
|
|
|
49
53
|
# Slot
|
|
@@ -87,6 +87,14 @@ module.exports = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACQAAAAlCAYAAAAq
|
|
|
87
87
|
|
|
88
88
|
/***/ }),
|
|
89
89
|
|
|
90
|
+
/***/ 6382:
|
|
91
|
+
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
|
|
92
|
+
|
|
93
|
+
"use strict";
|
|
94
|
+
module.exports = __webpack_require__.p + "media/here.a1c85e18.mp3";
|
|
95
|
+
|
|
96
|
+
/***/ }),
|
|
97
|
+
|
|
90
98
|
/***/ 9306:
|
|
91
99
|
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
|
|
92
100
|
|
|
@@ -5755,7 +5763,7 @@ axios.default = axios;
|
|
|
5755
5763
|
;// CONCATENATED MODULE: ./node_modules/thread-loader/dist/cjs.js!./node_modules/babel-loader/lib/index.js??clonedRuleSet-40.use[1]!./node_modules/vue-loader/dist/index.js??ruleSet[0].use[0]!./src/package/src/main.vue?vue&type=script&setup=true&lang=js
|
|
5756
5764
|
|
|
5757
5765
|
|
|
5758
|
-
const _withScopeId = n => ((0,external_commonjs_vue_commonjs2_vue_root_Vue_namespaceObject.pushScopeId)("data-v-
|
|
5766
|
+
const _withScopeId = n => ((0,external_commonjs_vue_commonjs2_vue_root_Vue_namespaceObject.pushScopeId)("data-v-e900adf2"), n = n(), (0,external_commonjs_vue_commonjs2_vue_root_Vue_namespaceObject.popScopeId)(), n);
|
|
5759
5767
|
const _hoisted_1 = ["src"];
|
|
5760
5768
|
const _hoisted_2 = /*#__PURE__*/_withScopeId(() => /*#__PURE__*/(0,external_commonjs_vue_commonjs2_vue_root_Vue_namespaceObject.createElementVNode)("i", {
|
|
5761
5769
|
class: "iconfont icon-guanbi"
|
|
@@ -5826,7 +5834,14 @@ const _hoisted_20 = ["src"];
|
|
|
5826
5834
|
type: Boolean,
|
|
5827
5835
|
default: true
|
|
5828
5836
|
},
|
|
5829
|
-
|
|
5837
|
+
space: {
|
|
5838
|
+
type: Number,
|
|
5839
|
+
default: 3000
|
|
5840
|
+
},
|
|
5841
|
+
mode: {
|
|
5842
|
+
type: String,
|
|
5843
|
+
default: "text"
|
|
5844
|
+
},
|
|
5830
5845
|
qaServer: {
|
|
5831
5846
|
type: String,
|
|
5832
5847
|
default: "https://172.16.103.188:8002/api21215/chatGlm/searchTextNew"
|
|
@@ -5835,10 +5850,14 @@ const _hoisted_20 = ["src"];
|
|
|
5835
5850
|
type: String,
|
|
5836
5851
|
default: "https://172.16.103.188:8002/api21215/chatGlm/tansAudioToTextByWhisperNew"
|
|
5837
5852
|
},
|
|
5853
|
+
wsServer: {
|
|
5854
|
+
type: String,
|
|
5855
|
+
default: "wss://172.16.103.188:8002/ws"
|
|
5856
|
+
},
|
|
5838
5857
|
eventFun: {
|
|
5839
5858
|
type: Array,
|
|
5840
5859
|
default: () => [{
|
|
5841
|
-
keywords: ["
|
|
5860
|
+
keywords: ["回到2023年7月22日时刻"],
|
|
5842
5861
|
//匹配关键字
|
|
5843
5862
|
trigger: "after",
|
|
5844
5863
|
//回调触发时机
|
|
@@ -5855,6 +5874,8 @@ const _hoisted_20 = ["src"];
|
|
|
5855
5874
|
let pCtx = null;
|
|
5856
5875
|
let pCanvas = null;
|
|
5857
5876
|
let drawPlayId = null;
|
|
5877
|
+
let wenetWs = null;
|
|
5878
|
+
let wenetTimer = null;
|
|
5858
5879
|
const contentRef = (0,external_commonjs_vue_commonjs2_vue_root_Vue_namespaceObject.ref)(null);
|
|
5859
5880
|
const scrollContainer = (0,external_commonjs_vue_commonjs2_vue_root_Vue_namespaceObject.ref)(null);
|
|
5860
5881
|
const props = __props;
|
|
@@ -5865,6 +5886,8 @@ const _hoisted_20 = ["src"];
|
|
|
5865
5886
|
input: "",
|
|
5866
5887
|
list: [],
|
|
5867
5888
|
findMatch: {},
|
|
5889
|
+
recorderCode: 0,
|
|
5890
|
+
//1唤醒 0沉睡
|
|
5868
5891
|
recorder: new (js_audio_recorder_default())({
|
|
5869
5892
|
sampleBits: 16,
|
|
5870
5893
|
// 采样位数,支持 8 或 16,默认是16
|
|
@@ -5874,6 +5897,119 @@ const _hoisted_20 = ["src"];
|
|
|
5874
5897
|
// compiling: false,(0.x版本中生效,1.x增加中) // 是否边录边转换,默认是false
|
|
5875
5898
|
})
|
|
5876
5899
|
});
|
|
5900
|
+
(0,external_commonjs_vue_commonjs2_vue_root_Vue_namespaceObject.onMounted)(() => {
|
|
5901
|
+
startMonitorAudio();
|
|
5902
|
+
});
|
|
5903
|
+
const initRecorder = () => {
|
|
5904
|
+
js_audio_recorder_default().getPermission().then(() => {
|
|
5905
|
+
state.recorder.start(); // 开始录音
|
|
5906
|
+
}, error => {
|
|
5907
|
+
console.log(`${error.name} : ${error.message}`);
|
|
5908
|
+
});
|
|
5909
|
+
};
|
|
5910
|
+
const initWebScoket = () => {
|
|
5911
|
+
let url = props.wsServer;
|
|
5912
|
+
if ("WebSocket" in window) {
|
|
5913
|
+
wenetWs = new WebSocket(url);
|
|
5914
|
+
wenetWs.onopen = () => {
|
|
5915
|
+
console.log("Websocket 连接成功,开始识别");
|
|
5916
|
+
// 每2S发一次语音 进行监听唤醒
|
|
5917
|
+
wenetTimer = window.setInterval(() => {
|
|
5918
|
+
sendRecorder();
|
|
5919
|
+
}, props.space);
|
|
5920
|
+
};
|
|
5921
|
+
wenetWs.onmessage = _msg => {
|
|
5922
|
+
let data = JSON.parse(_msg.data);
|
|
5923
|
+
if (data.status == 1) {
|
|
5924
|
+
if (state.recorderCode == 0) {
|
|
5925
|
+
window.clearInterval(wenetTimer);
|
|
5926
|
+
wenetTimer = null;
|
|
5927
|
+
iAmHere();
|
|
5928
|
+
state.recorderCode = 1;
|
|
5929
|
+
window.setTimeout(() => {
|
|
5930
|
+
setRecording();
|
|
5931
|
+
}, 3000);
|
|
5932
|
+
}
|
|
5933
|
+
}
|
|
5934
|
+
};
|
|
5935
|
+
wenetWs.onclose = function () {
|
|
5936
|
+
console.log("WebSocket 连接断开");
|
|
5937
|
+
};
|
|
5938
|
+
wenetWs.onerror = function () {
|
|
5939
|
+
console.log("WebSocket 连接失败");
|
|
5940
|
+
};
|
|
5941
|
+
}
|
|
5942
|
+
};
|
|
5943
|
+
const sendRecorder = () => {
|
|
5944
|
+
let wavBlob = state.recorder.getWAVBlob();
|
|
5945
|
+
let newbolb = new Blob([wavBlob], {
|
|
5946
|
+
type: "audio/wav"
|
|
5947
|
+
});
|
|
5948
|
+
//获取当时时间戳作为文件名
|
|
5949
|
+
let fileOfBlob = new File([newbolb], new Date().getTime() + ".wav");
|
|
5950
|
+
|
|
5951
|
+
// 本地播放录音文件流
|
|
5952
|
+
// let sound = new Audio();
|
|
5953
|
+
// let src = URL.createObjectURL(fileOfBlob);
|
|
5954
|
+
// sound.src = src;
|
|
5955
|
+
// sound.play();
|
|
5956
|
+
|
|
5957
|
+
wenetWs.send(fileOfBlob);
|
|
5958
|
+
state.recorder.start();
|
|
5959
|
+
};
|
|
5960
|
+
|
|
5961
|
+
// 唤醒后的录音
|
|
5962
|
+
const setRecording = () => {
|
|
5963
|
+
state.recorder.stop();
|
|
5964
|
+
state.recorder.start();
|
|
5965
|
+
window.setTimeout(() => {
|
|
5966
|
+
let wavBlob = state.recorder.getWAVBlob();
|
|
5967
|
+
let newbolb = new Blob([wavBlob], {
|
|
5968
|
+
type: "audio/wav"
|
|
5969
|
+
});
|
|
5970
|
+
//获取当时时间戳作为文件名
|
|
5971
|
+
let fileOfBlob = new File([newbolb], new Date().getTime() + ".wav");
|
|
5972
|
+
state.recorder.stop();
|
|
5973
|
+
state.recorderCode = 0;
|
|
5974
|
+
let formData = new FormData();
|
|
5975
|
+
formData.append("modelName", "medium");
|
|
5976
|
+
formData.append("audio", fileOfBlob);
|
|
5977
|
+
uploadWavFile(formData).then(result => {
|
|
5978
|
+
let res = result.data;
|
|
5979
|
+
if (res.code == 200) {
|
|
5980
|
+
let {
|
|
5981
|
+
answer: audioToText
|
|
5982
|
+
} = res.detail.content;
|
|
5983
|
+
let text = audioToText;
|
|
5984
|
+
|
|
5985
|
+
// let text = "回到2023年7月22日时刻";
|
|
5986
|
+
|
|
5987
|
+
// 检索场景
|
|
5988
|
+
matching(text);
|
|
5989
|
+
|
|
5990
|
+
// 拿到的语音进行问答
|
|
5991
|
+
let option = {
|
|
5992
|
+
searchText: text,
|
|
5993
|
+
use_tts: "True"
|
|
5994
|
+
};
|
|
5995
|
+
searchText(option).then(q => {
|
|
5996
|
+
let data = q.data;
|
|
5997
|
+
if (data && data.code == 200) {
|
|
5998
|
+
let {
|
|
5999
|
+
ttsMaleAddress
|
|
6000
|
+
} = data.detail[0];
|
|
6001
|
+
// 播放回答内容和进行小G动作
|
|
6002
|
+
playAudio(ttsMaleAddress);
|
|
6003
|
+
if (state.findMatch && state.findMatch.fun) {
|
|
6004
|
+
state.findMatch.fun();
|
|
6005
|
+
}
|
|
6006
|
+
}
|
|
6007
|
+
});
|
|
6008
|
+
}
|
|
6009
|
+
});
|
|
6010
|
+
startMonitorAudio();
|
|
6011
|
+
}, 5 * 1000);
|
|
6012
|
+
};
|
|
5877
6013
|
const searchText = data => {
|
|
5878
6014
|
let url = props.qaServer;
|
|
5879
6015
|
return lib_axios.post(url, data);
|
|
@@ -5882,6 +6018,20 @@ const _hoisted_20 = ["src"];
|
|
|
5882
6018
|
let url = props.audioServer;
|
|
5883
6019
|
return lib_axios.post(url, data);
|
|
5884
6020
|
};
|
|
6021
|
+
const startMonitorAudio = () => {
|
|
6022
|
+
if (props.mode == "audio") {
|
|
6023
|
+
initRecorder();
|
|
6024
|
+
initWebScoket();
|
|
6025
|
+
}
|
|
6026
|
+
};
|
|
6027
|
+
const iAmHere = () => {
|
|
6028
|
+
let sound = new Audio();
|
|
6029
|
+
var url = __webpack_require__(6382);
|
|
6030
|
+
sound.src = url;
|
|
6031
|
+
window.setTimeout(() => {
|
|
6032
|
+
sound.play();
|
|
6033
|
+
}, 1000);
|
|
6034
|
+
};
|
|
5885
6035
|
const componentDidMount = () => {
|
|
5886
6036
|
pCanvas = document.getElementById("playChart");
|
|
5887
6037
|
pCtx = pCanvas.getContext("2d");
|
|
@@ -5942,6 +6092,7 @@ const _hoisted_20 = ["src"];
|
|
|
5942
6092
|
const closeQaDrawer = () => {
|
|
5943
6093
|
state.isShow = false;
|
|
5944
6094
|
state.list = [];
|
|
6095
|
+
state.findMatch = {};
|
|
5945
6096
|
if (state.aiTimer) {
|
|
5946
6097
|
window.clearInterval(state.aiTimer);
|
|
5947
6098
|
state.aiTimer = null;
|
|
@@ -6057,7 +6208,7 @@ const _hoisted_20 = ["src"];
|
|
|
6057
6208
|
qaType: "api",
|
|
6058
6209
|
...obj
|
|
6059
6210
|
});
|
|
6060
|
-
playAudio();
|
|
6211
|
+
// playAudio();
|
|
6061
6212
|
}
|
|
6062
6213
|
});
|
|
6063
6214
|
};
|
|
@@ -6225,15 +6376,15 @@ const _hoisted_20 = ["src"];
|
|
|
6225
6376
|
});
|
|
6226
6377
|
;// CONCATENATED MODULE: ./src/package/src/main.vue?vue&type=script&setup=true&lang=js
|
|
6227
6378
|
|
|
6228
|
-
;// CONCATENATED MODULE: ./node_modules/mini-css-extract-plugin/dist/loader.js??clonedRuleSet-12.use[0]!./node_modules/css-loader/dist/cjs.js??clonedRuleSet-12.use[1]!./node_modules/vue-loader/dist/stylePostLoader.js!./node_modules/postcss-loader/dist/cjs.js??clonedRuleSet-12.use[2]!./node_modules/vue-loader/dist/index.js??ruleSet[0].use[0]!./src/package/src/main.vue?vue&type=style&index=0&id=
|
|
6379
|
+
;// CONCATENATED MODULE: ./node_modules/mini-css-extract-plugin/dist/loader.js??clonedRuleSet-12.use[0]!./node_modules/css-loader/dist/cjs.js??clonedRuleSet-12.use[1]!./node_modules/vue-loader/dist/stylePostLoader.js!./node_modules/postcss-loader/dist/cjs.js??clonedRuleSet-12.use[2]!./node_modules/vue-loader/dist/index.js??ruleSet[0].use[0]!./src/package/src/main.vue?vue&type=style&index=0&id=e900adf2&lang=css
|
|
6229
6380
|
// extracted by mini-css-extract-plugin
|
|
6230
6381
|
|
|
6231
|
-
;// CONCATENATED MODULE: ./src/package/src/main.vue?vue&type=style&index=0&id=
|
|
6382
|
+
;// CONCATENATED MODULE: ./src/package/src/main.vue?vue&type=style&index=0&id=e900adf2&lang=css
|
|
6232
6383
|
|
|
6233
|
-
;// CONCATENATED MODULE: ./node_modules/mini-css-extract-plugin/dist/loader.js??clonedRuleSet-32.use[0]!./node_modules/css-loader/dist/cjs.js??clonedRuleSet-32.use[1]!./node_modules/vue-loader/dist/stylePostLoader.js!./node_modules/postcss-loader/dist/cjs.js??clonedRuleSet-32.use[2]!./node_modules/less-loader/dist/cjs.js??clonedRuleSet-32.use[3]!./node_modules/vue-loader/dist/index.js??ruleSet[0].use[0]!./src/package/src/main.vue?vue&type=style&index=1&id=
|
|
6384
|
+
;// CONCATENATED MODULE: ./node_modules/mini-css-extract-plugin/dist/loader.js??clonedRuleSet-32.use[0]!./node_modules/css-loader/dist/cjs.js??clonedRuleSet-32.use[1]!./node_modules/vue-loader/dist/stylePostLoader.js!./node_modules/postcss-loader/dist/cjs.js??clonedRuleSet-32.use[2]!./node_modules/less-loader/dist/cjs.js??clonedRuleSet-32.use[3]!./node_modules/vue-loader/dist/index.js??ruleSet[0].use[0]!./src/package/src/main.vue?vue&type=style&index=1&id=e900adf2&lang=less&scoped=true
|
|
6234
6385
|
// extracted by mini-css-extract-plugin
|
|
6235
6386
|
|
|
6236
|
-
;// CONCATENATED MODULE: ./src/package/src/main.vue?vue&type=style&index=1&id=
|
|
6387
|
+
;// CONCATENATED MODULE: ./src/package/src/main.vue?vue&type=style&index=1&id=e900adf2&lang=less&scoped=true
|
|
6237
6388
|
|
|
6238
6389
|
// EXTERNAL MODULE: ./node_modules/vue-loader/dist/exportHelper.js
|
|
6239
6390
|
var exportHelper = __webpack_require__(6262);
|
|
@@ -6245,7 +6396,7 @@ var exportHelper = __webpack_require__(6262);
|
|
|
6245
6396
|
|
|
6246
6397
|
|
|
6247
6398
|
|
|
6248
|
-
const __exports__ = /*#__PURE__*/(0,exportHelper/* default */.A)(mainvue_type_script_setup_true_lang_js, [['__scopeId',"data-v-
|
|
6399
|
+
const __exports__ = /*#__PURE__*/(0,exportHelper/* default */.A)(mainvue_type_script_setup_true_lang_js, [['__scopeId',"data-v-e900adf2"]])
|
|
6249
6400
|
|
|
6250
6401
|
/* harmony default export */ var main = (__exports__);
|
|
6251
6402
|
;// CONCATENATED MODULE: ./src/package/index.js
|
package/dist/g-ai-robot3.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
.ellipsisText{display:inline-block;width:20px;height:24px;position:relative}.ellipsisText:after{position:absolute;left:0;top:4px;content:"···";animation:loading-animation 1s linear infinite}@keyframes loading-animation{0%{content:"·"}50%{content:"··"}to{content:"···"}}#g-ai-robat[data-v-
|
|
1
|
+
.ellipsisText{display:inline-block;width:20px;height:24px;position:relative}.ellipsisText:after{position:absolute;left:0;top:4px;content:"···";animation:loading-animation 1s linear infinite}@keyframes loading-animation{0%{content:"·"}50%{content:"··"}to{content:"···"}}#g-ai-robat[data-v-e900adf2]{position:fixed}#g-ai-robat .robot[data-v-e900adf2]{cursor:pointer}#g-ai-robat .robot img[data-v-e900adf2]{height:86px;width:70px}#g-ai-robat .talk_main[data-v-e900adf2]{position:absolute;width:400px;height:600px;background:#f5f6f7}#g-ai-robat .talk_main.top[data-v-e900adf2]{left:50%;bottom:100px;transform:translateX(-50%)}#g-ai-robat .talk_main.bottom[data-v-e900adf2]{left:50%;top:100px;transform:translateX(-50%)}#g-ai-robat .talk_main.right[data-v-e900adf2]{left:100px;bottom:50%;transform:translateY(50%)}#g-ai-robat .talk_main.left[data-v-e900adf2]{right:100px;bottom:50%;transform:translateY(50%)}#g-ai-robat .talk_main.top-end[data-v-e900adf2]{left:100px;bottom:100px}#g-ai-robat .talk_main.top-start[data-v-e900adf2]{right:100px;bottom:100px}#g-ai-robat .talk_main.bottom-start[data-v-e900adf2]{right:100px;top:100px}#g-ai-robat .talk_main.bottom-end[data-v-e900adf2]{left:100px;top:100px}#g-ai-robat .talk_main header[data-v-e900adf2]{height:44px;background:linear-gradient(90deg,#ebf1ff,#e5faf8,#f2ebfe);display:flex;padding:0 16px;align-items:center;justify-content:space-between;cursor:move}#g-ai-robat .talk_main header span[data-v-e900adf2]{font-size:16px;font-weight:700}#g-ai-robat .talk_main header span.close[data-v-e900adf2]{color:#999}#g-ai-robat .talk_main header i[data-v-e900adf2]{cursor:pointer}#g-ai-robat .talk_main .qa_body[data-v-e900adf2]{list-style:none;padding:16px;box-sizing:border-box;margin:0;height:calc(100% - 116px);overflow-y:auto}#g-ai-robat .talk_main .qa_body[data-v-e900adf2]::-webkit-scrollbar{width:8px;background-color:#f9f9f9}#g-ai-robat .talk_main .qa_body[data-v-e900adf2]::-webkit-scrollbar-track{background:#e1e1e1;border-radius:10px}#g-ai-robat .talk_main .qa_body[data-v-e900adf2]::-webkit-scrollbar-thumb{background-color:#c1c1c1;border-radius:10px}#g-ai-robat .talk_main .qa_body li[data-v-e900adf2]{display:flex;margin-bottom:24px;justify-content:flex-end}#g-ai-robat .talk_main .qa_body li .is_icon[data-v-e900adf2]{width:24px;height:24px;border-radius:50%;color:#fff;display:flex}#g-ai-robat .talk_main .qa_body li .is_icon i[data-v-e900adf2]{margin:auto}#g-ai-robat .talk_main .qa_body li.is_ai[data-v-e900adf2]{justify-content:flex-start}#g-ai-robat .talk_main .qa_body li.is_ai .text_main[data-v-e900adf2]{box-shadow:0 4px 20px 0 #0476ed29;border:1px solid;border-image-source:linear-gradient(180deg,#fff,hsla(0,0%,100%,.5) 104.31%);background:linear-gradient(92.03deg,rgba(119,241,255,.222) -2.18%,rgba(237,250,255,.6) 48.06%,rgba(91,168,255,.174) 107.05%)}#g-ai-robat .talk_main .qa_body li.is_ai .text_main>.value[data-v-e900adf2]{white-space:pre-wrap}#g-ai-robat .talk_main .qa_body li .text_main[data-v-e900adf2]{padding:10px;max-width:calc(100% - 100px);border:1px solid;margin:0 8px;border-image-source:linear-gradient(90deg,#fff,hsla(0,0%,100%,.5));box-shadow:0 4px 20px 0 #0476ed29;background:linear-gradient(90.81deg,rgba(244,252,255,.6) 1.75%,hsla(0,0%,100%,.6) 32.33%,rgba(238,246,255,.6) 102.86%);border-radius:6px}#g-ai-robat .talk_main .qa_body li .text_main>.value[data-v-e900adf2]{display:flex;align-items:center;overflow-wrap:break-word;word-wrap:break-word;font-size:14px;font-weight:400}#g-ai-robat .talk_main .qa_body li .text_main .btn i[data-v-e900adf2]{font-size:14px;font-weight:400;color:#037aff;margin-right:10px;cursor:pointer;text-decoration:underline}#g-ai-robat .talk_main .qa_body li .text_main .btn i.close[data-v-e900adf2]{filter:hue-rotate(180deg);animation:opacityCss-e900adf2 2s linear infinite}#g-ai-robat .talk_main .qa_input[data-v-e900adf2]{padding:10px 16px;display:flex;align-items:center;justify-content:space-between;position:absolute;bottom:0;left:0;right:0;box-sizing:border-box}#g-ai-robat .talk_main .qa_input textarea[data-v-e900adf2]{width:100%;height:68px;resize:none;background-color:#fff;border:1px solid #dcdfe6;color:#606266;padding:6px}#g-ai-robat .talk_main .qa_input textarea[data-v-e900adf2]:focus{outline:none;border-color:#409eff}#g-ai-robat .talk_main .qa_input .is_icon[data-v-e900adf2]{width:30px}#g-ai-robat .talk_main .qa_input .is_icon p[data-v-e900adf2]{display:flex;align-items:center;justify-content:flex-end;margin:6px 0}#g-ai-robat .talk_main .qa_input .is_icon p[data-v-e900adf2]:first-of-type{position:relative}#g-ai-robat .talk_main .qa_input .is_icon p:first-of-type #playChart[data-v-e900adf2]{bottom:30px;position:absolute;visibility:hidden}#g-ai-robat .talk_main .qa_input .is_icon p:first-of-type #playChart.show[data-v-e900adf2]{visibility:visible}#g-ai-robat .talk_main .qa_input .is_icon p:first-of-type #playChart.hiddle[data-v-e900adf2]{visibility:hidden}#g-ai-robat .talk_main .qa_input .is_icon p img[data-v-e900adf2]{width:20px;height:20px;cursor:pointer}#g-ai-robat .talk_main .qa_input .is_icon p img.close[data-v-e900adf2]{filter:hue-rotate(180deg);animation:opacityCss-e900adf2 2s linear infinite}#g-ai-robat .talk_main .qa_input .is_icon p.send img.disabled[data-v-e900adf2]{cursor:not-allowed}#g-ai-robat .talk_main .qa_input .is_icon p i[data-v-e900adf2]{cursor:pointer}@keyframes opacityCss-e900adf2{0%{opacity:1}25%{opacity:.5}50%{opacity:.1}70%{opacity:.15}to{opacity:1}}@font-face{font-family:iconfont;src:url(//at.alicdn.com/t/c/font_4633255_xm549qw7rxj.woff2?t=1721900327001) format("woff2"),url(//at.alicdn.com/t/c/font_4633255_xm549qw7rxj.woff?t=1721900327001) format("woff"),url(//at.alicdn.com/t/c/font_4633255_xm549qw7rxj.ttf?t=1721900327001) format("truetype")}.iconfont[data-v-e900adf2]{font-family:iconfont!important;font-size:16px;font-style:normal;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.icon-guanbi[data-v-e900adf2]:before{content:"\e609"}.icon-nvsheng[data-v-e900adf2]:before{content:"\e603"}.icon-nansheng[data-v-e900adf2]:before{content:"\e604"}.icon-fuzhi[data-v-e900adf2]:before{content:"\e626"}.icon-zhongxinhuida[data-v-e900adf2]:before{content:"\e63b"}
|
package/dist/g-ai-robot3.umd.js
CHANGED
|
@@ -97,6 +97,14 @@ module.exports = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACQAAAAlCAYAAAAq
|
|
|
97
97
|
|
|
98
98
|
/***/ }),
|
|
99
99
|
|
|
100
|
+
/***/ 6382:
|
|
101
|
+
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
|
|
102
|
+
|
|
103
|
+
"use strict";
|
|
104
|
+
module.exports = __webpack_require__.p + "media/here.a1c85e18.mp3";
|
|
105
|
+
|
|
106
|
+
/***/ }),
|
|
107
|
+
|
|
100
108
|
/***/ 9274:
|
|
101
109
|
/***/ (function(module) {
|
|
102
110
|
|
|
@@ -5773,7 +5781,7 @@ axios.default = axios;
|
|
|
5773
5781
|
;// CONCATENATED MODULE: ./node_modules/thread-loader/dist/cjs.js!./node_modules/babel-loader/lib/index.js??clonedRuleSet-82.use[1]!./node_modules/vue-loader/dist/index.js??ruleSet[0].use[0]!./src/package/src/main.vue?vue&type=script&setup=true&lang=js
|
|
5774
5782
|
|
|
5775
5783
|
|
|
5776
|
-
const _withScopeId = n => ((0,external_commonjs_vue_commonjs2_vue_root_Vue_.pushScopeId)("data-v-
|
|
5784
|
+
const _withScopeId = n => ((0,external_commonjs_vue_commonjs2_vue_root_Vue_.pushScopeId)("data-v-e900adf2"), n = n(), (0,external_commonjs_vue_commonjs2_vue_root_Vue_.popScopeId)(), n);
|
|
5777
5785
|
const _hoisted_1 = ["src"];
|
|
5778
5786
|
const _hoisted_2 = /*#__PURE__*/_withScopeId(() => /*#__PURE__*/(0,external_commonjs_vue_commonjs2_vue_root_Vue_.createElementVNode)("i", {
|
|
5779
5787
|
class: "iconfont icon-guanbi"
|
|
@@ -5844,7 +5852,14 @@ const _hoisted_20 = ["src"];
|
|
|
5844
5852
|
type: Boolean,
|
|
5845
5853
|
default: true
|
|
5846
5854
|
},
|
|
5847
|
-
|
|
5855
|
+
space: {
|
|
5856
|
+
type: Number,
|
|
5857
|
+
default: 3000
|
|
5858
|
+
},
|
|
5859
|
+
mode: {
|
|
5860
|
+
type: String,
|
|
5861
|
+
default: "text"
|
|
5862
|
+
},
|
|
5848
5863
|
qaServer: {
|
|
5849
5864
|
type: String,
|
|
5850
5865
|
default: "https://172.16.103.188:8002/api21215/chatGlm/searchTextNew"
|
|
@@ -5853,10 +5868,14 @@ const _hoisted_20 = ["src"];
|
|
|
5853
5868
|
type: String,
|
|
5854
5869
|
default: "https://172.16.103.188:8002/api21215/chatGlm/tansAudioToTextByWhisperNew"
|
|
5855
5870
|
},
|
|
5871
|
+
wsServer: {
|
|
5872
|
+
type: String,
|
|
5873
|
+
default: "wss://172.16.103.188:8002/ws"
|
|
5874
|
+
},
|
|
5856
5875
|
eventFun: {
|
|
5857
5876
|
type: Array,
|
|
5858
5877
|
default: () => [{
|
|
5859
|
-
keywords: ["
|
|
5878
|
+
keywords: ["回到2023年7月22日时刻"],
|
|
5860
5879
|
//匹配关键字
|
|
5861
5880
|
trigger: "after",
|
|
5862
5881
|
//回调触发时机
|
|
@@ -5873,6 +5892,8 @@ const _hoisted_20 = ["src"];
|
|
|
5873
5892
|
let pCtx = null;
|
|
5874
5893
|
let pCanvas = null;
|
|
5875
5894
|
let drawPlayId = null;
|
|
5895
|
+
let wenetWs = null;
|
|
5896
|
+
let wenetTimer = null;
|
|
5876
5897
|
const contentRef = (0,external_commonjs_vue_commonjs2_vue_root_Vue_.ref)(null);
|
|
5877
5898
|
const scrollContainer = (0,external_commonjs_vue_commonjs2_vue_root_Vue_.ref)(null);
|
|
5878
5899
|
const props = __props;
|
|
@@ -5883,6 +5904,8 @@ const _hoisted_20 = ["src"];
|
|
|
5883
5904
|
input: "",
|
|
5884
5905
|
list: [],
|
|
5885
5906
|
findMatch: {},
|
|
5907
|
+
recorderCode: 0,
|
|
5908
|
+
//1唤醒 0沉睡
|
|
5886
5909
|
recorder: new (js_audio_recorder_default())({
|
|
5887
5910
|
sampleBits: 16,
|
|
5888
5911
|
// 采样位数,支持 8 或 16,默认是16
|
|
@@ -5892,6 +5915,119 @@ const _hoisted_20 = ["src"];
|
|
|
5892
5915
|
// compiling: false,(0.x版本中生效,1.x增加中) // 是否边录边转换,默认是false
|
|
5893
5916
|
})
|
|
5894
5917
|
});
|
|
5918
|
+
(0,external_commonjs_vue_commonjs2_vue_root_Vue_.onMounted)(() => {
|
|
5919
|
+
startMonitorAudio();
|
|
5920
|
+
});
|
|
5921
|
+
const initRecorder = () => {
|
|
5922
|
+
js_audio_recorder_default().getPermission().then(() => {
|
|
5923
|
+
state.recorder.start(); // 开始录音
|
|
5924
|
+
}, error => {
|
|
5925
|
+
console.log(`${error.name} : ${error.message}`);
|
|
5926
|
+
});
|
|
5927
|
+
};
|
|
5928
|
+
const initWebScoket = () => {
|
|
5929
|
+
let url = props.wsServer;
|
|
5930
|
+
if ("WebSocket" in window) {
|
|
5931
|
+
wenetWs = new WebSocket(url);
|
|
5932
|
+
wenetWs.onopen = () => {
|
|
5933
|
+
console.log("Websocket 连接成功,开始识别");
|
|
5934
|
+
// 每2S发一次语音 进行监听唤醒
|
|
5935
|
+
wenetTimer = window.setInterval(() => {
|
|
5936
|
+
sendRecorder();
|
|
5937
|
+
}, props.space);
|
|
5938
|
+
};
|
|
5939
|
+
wenetWs.onmessage = _msg => {
|
|
5940
|
+
let data = JSON.parse(_msg.data);
|
|
5941
|
+
if (data.status == 1) {
|
|
5942
|
+
if (state.recorderCode == 0) {
|
|
5943
|
+
window.clearInterval(wenetTimer);
|
|
5944
|
+
wenetTimer = null;
|
|
5945
|
+
iAmHere();
|
|
5946
|
+
state.recorderCode = 1;
|
|
5947
|
+
window.setTimeout(() => {
|
|
5948
|
+
setRecording();
|
|
5949
|
+
}, 3000);
|
|
5950
|
+
}
|
|
5951
|
+
}
|
|
5952
|
+
};
|
|
5953
|
+
wenetWs.onclose = function () {
|
|
5954
|
+
console.log("WebSocket 连接断开");
|
|
5955
|
+
};
|
|
5956
|
+
wenetWs.onerror = function () {
|
|
5957
|
+
console.log("WebSocket 连接失败");
|
|
5958
|
+
};
|
|
5959
|
+
}
|
|
5960
|
+
};
|
|
5961
|
+
const sendRecorder = () => {
|
|
5962
|
+
let wavBlob = state.recorder.getWAVBlob();
|
|
5963
|
+
let newbolb = new Blob([wavBlob], {
|
|
5964
|
+
type: "audio/wav"
|
|
5965
|
+
});
|
|
5966
|
+
//获取当时时间戳作为文件名
|
|
5967
|
+
let fileOfBlob = new File([newbolb], new Date().getTime() + ".wav");
|
|
5968
|
+
|
|
5969
|
+
// 本地播放录音文件流
|
|
5970
|
+
// let sound = new Audio();
|
|
5971
|
+
// let src = URL.createObjectURL(fileOfBlob);
|
|
5972
|
+
// sound.src = src;
|
|
5973
|
+
// sound.play();
|
|
5974
|
+
|
|
5975
|
+
wenetWs.send(fileOfBlob);
|
|
5976
|
+
state.recorder.start();
|
|
5977
|
+
};
|
|
5978
|
+
|
|
5979
|
+
// 唤醒后的录音
|
|
5980
|
+
const setRecording = () => {
|
|
5981
|
+
state.recorder.stop();
|
|
5982
|
+
state.recorder.start();
|
|
5983
|
+
window.setTimeout(() => {
|
|
5984
|
+
let wavBlob = state.recorder.getWAVBlob();
|
|
5985
|
+
let newbolb = new Blob([wavBlob], {
|
|
5986
|
+
type: "audio/wav"
|
|
5987
|
+
});
|
|
5988
|
+
//获取当时时间戳作为文件名
|
|
5989
|
+
let fileOfBlob = new File([newbolb], new Date().getTime() + ".wav");
|
|
5990
|
+
state.recorder.stop();
|
|
5991
|
+
state.recorderCode = 0;
|
|
5992
|
+
let formData = new FormData();
|
|
5993
|
+
formData.append("modelName", "medium");
|
|
5994
|
+
formData.append("audio", fileOfBlob);
|
|
5995
|
+
uploadWavFile(formData).then(result => {
|
|
5996
|
+
let res = result.data;
|
|
5997
|
+
if (res.code == 200) {
|
|
5998
|
+
let {
|
|
5999
|
+
answer: audioToText
|
|
6000
|
+
} = res.detail.content;
|
|
6001
|
+
let text = audioToText;
|
|
6002
|
+
|
|
6003
|
+
// let text = "回到2023年7月22日时刻";
|
|
6004
|
+
|
|
6005
|
+
// 检索场景
|
|
6006
|
+
matching(text);
|
|
6007
|
+
|
|
6008
|
+
// 拿到的语音进行问答
|
|
6009
|
+
let option = {
|
|
6010
|
+
searchText: text,
|
|
6011
|
+
use_tts: "True"
|
|
6012
|
+
};
|
|
6013
|
+
searchText(option).then(q => {
|
|
6014
|
+
let data = q.data;
|
|
6015
|
+
if (data && data.code == 200) {
|
|
6016
|
+
let {
|
|
6017
|
+
ttsMaleAddress
|
|
6018
|
+
} = data.detail[0];
|
|
6019
|
+
// 播放回答内容和进行小G动作
|
|
6020
|
+
playAudio(ttsMaleAddress);
|
|
6021
|
+
if (state.findMatch && state.findMatch.fun) {
|
|
6022
|
+
state.findMatch.fun();
|
|
6023
|
+
}
|
|
6024
|
+
}
|
|
6025
|
+
});
|
|
6026
|
+
}
|
|
6027
|
+
});
|
|
6028
|
+
startMonitorAudio();
|
|
6029
|
+
}, 5 * 1000);
|
|
6030
|
+
};
|
|
5895
6031
|
const searchText = data => {
|
|
5896
6032
|
let url = props.qaServer;
|
|
5897
6033
|
return lib_axios.post(url, data);
|
|
@@ -5900,6 +6036,20 @@ const _hoisted_20 = ["src"];
|
|
|
5900
6036
|
let url = props.audioServer;
|
|
5901
6037
|
return lib_axios.post(url, data);
|
|
5902
6038
|
};
|
|
6039
|
+
const startMonitorAudio = () => {
|
|
6040
|
+
if (props.mode == "audio") {
|
|
6041
|
+
initRecorder();
|
|
6042
|
+
initWebScoket();
|
|
6043
|
+
}
|
|
6044
|
+
};
|
|
6045
|
+
const iAmHere = () => {
|
|
6046
|
+
let sound = new Audio();
|
|
6047
|
+
var url = __webpack_require__(6382);
|
|
6048
|
+
sound.src = url;
|
|
6049
|
+
window.setTimeout(() => {
|
|
6050
|
+
sound.play();
|
|
6051
|
+
}, 1000);
|
|
6052
|
+
};
|
|
5903
6053
|
const componentDidMount = () => {
|
|
5904
6054
|
pCanvas = document.getElementById("playChart");
|
|
5905
6055
|
pCtx = pCanvas.getContext("2d");
|
|
@@ -5960,6 +6110,7 @@ const _hoisted_20 = ["src"];
|
|
|
5960
6110
|
const closeQaDrawer = () => {
|
|
5961
6111
|
state.isShow = false;
|
|
5962
6112
|
state.list = [];
|
|
6113
|
+
state.findMatch = {};
|
|
5963
6114
|
if (state.aiTimer) {
|
|
5964
6115
|
window.clearInterval(state.aiTimer);
|
|
5965
6116
|
state.aiTimer = null;
|
|
@@ -6075,7 +6226,7 @@ const _hoisted_20 = ["src"];
|
|
|
6075
6226
|
qaType: "api",
|
|
6076
6227
|
...obj
|
|
6077
6228
|
});
|
|
6078
|
-
playAudio();
|
|
6229
|
+
// playAudio();
|
|
6079
6230
|
}
|
|
6080
6231
|
});
|
|
6081
6232
|
};
|
|
@@ -6243,15 +6394,15 @@ const _hoisted_20 = ["src"];
|
|
|
6243
6394
|
});
|
|
6244
6395
|
;// CONCATENATED MODULE: ./src/package/src/main.vue?vue&type=script&setup=true&lang=js
|
|
6245
6396
|
|
|
6246
|
-
;// CONCATENATED MODULE: ./node_modules/mini-css-extract-plugin/dist/loader.js??clonedRuleSet-54.use[0]!./node_modules/css-loader/dist/cjs.js??clonedRuleSet-54.use[1]!./node_modules/vue-loader/dist/stylePostLoader.js!./node_modules/postcss-loader/dist/cjs.js??clonedRuleSet-54.use[2]!./node_modules/vue-loader/dist/index.js??ruleSet[0].use[0]!./src/package/src/main.vue?vue&type=style&index=0&id=
|
|
6397
|
+
;// CONCATENATED MODULE: ./node_modules/mini-css-extract-plugin/dist/loader.js??clonedRuleSet-54.use[0]!./node_modules/css-loader/dist/cjs.js??clonedRuleSet-54.use[1]!./node_modules/vue-loader/dist/stylePostLoader.js!./node_modules/postcss-loader/dist/cjs.js??clonedRuleSet-54.use[2]!./node_modules/vue-loader/dist/index.js??ruleSet[0].use[0]!./src/package/src/main.vue?vue&type=style&index=0&id=e900adf2&lang=css
|
|
6247
6398
|
// extracted by mini-css-extract-plugin
|
|
6248
6399
|
|
|
6249
|
-
;// CONCATENATED MODULE: ./src/package/src/main.vue?vue&type=style&index=0&id=
|
|
6400
|
+
;// CONCATENATED MODULE: ./src/package/src/main.vue?vue&type=style&index=0&id=e900adf2&lang=css
|
|
6250
6401
|
|
|
6251
|
-
;// CONCATENATED MODULE: ./node_modules/mini-css-extract-plugin/dist/loader.js??clonedRuleSet-74.use[0]!./node_modules/css-loader/dist/cjs.js??clonedRuleSet-74.use[1]!./node_modules/vue-loader/dist/stylePostLoader.js!./node_modules/postcss-loader/dist/cjs.js??clonedRuleSet-74.use[2]!./node_modules/less-loader/dist/cjs.js??clonedRuleSet-74.use[3]!./node_modules/vue-loader/dist/index.js??ruleSet[0].use[0]!./src/package/src/main.vue?vue&type=style&index=1&id=
|
|
6402
|
+
;// CONCATENATED MODULE: ./node_modules/mini-css-extract-plugin/dist/loader.js??clonedRuleSet-74.use[0]!./node_modules/css-loader/dist/cjs.js??clonedRuleSet-74.use[1]!./node_modules/vue-loader/dist/stylePostLoader.js!./node_modules/postcss-loader/dist/cjs.js??clonedRuleSet-74.use[2]!./node_modules/less-loader/dist/cjs.js??clonedRuleSet-74.use[3]!./node_modules/vue-loader/dist/index.js??ruleSet[0].use[0]!./src/package/src/main.vue?vue&type=style&index=1&id=e900adf2&lang=less&scoped=true
|
|
6252
6403
|
// extracted by mini-css-extract-plugin
|
|
6253
6404
|
|
|
6254
|
-
;// CONCATENATED MODULE: ./src/package/src/main.vue?vue&type=style&index=1&id=
|
|
6405
|
+
;// CONCATENATED MODULE: ./src/package/src/main.vue?vue&type=style&index=1&id=e900adf2&lang=less&scoped=true
|
|
6255
6406
|
|
|
6256
6407
|
// EXTERNAL MODULE: ./node_modules/vue-loader/dist/exportHelper.js
|
|
6257
6408
|
var exportHelper = __webpack_require__(6262);
|
|
@@ -6263,7 +6414,7 @@ var exportHelper = __webpack_require__(6262);
|
|
|
6263
6414
|
|
|
6264
6415
|
|
|
6265
6416
|
|
|
6266
|
-
const __exports__ = /*#__PURE__*/(0,exportHelper/* default */.A)(mainvue_type_script_setup_true_lang_js, [['__scopeId',"data-v-
|
|
6417
|
+
const __exports__ = /*#__PURE__*/(0,exportHelper/* default */.A)(mainvue_type_script_setup_true_lang_js, [['__scopeId',"data-v-e900adf2"]])
|
|
6267
6418
|
|
|
6268
6419
|
/* harmony default export */ var main = (__exports__);
|
|
6269
6420
|
;// CONCATENATED MODULE: ./src/package/index.js
|