g-ai-robot3 0.1.6 → 0.1.8
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 +5 -1
- package/dist/g-ai-robot3.common.js +159 -10
- package/dist/g-ai-robot3.css +1 -1
- package/dist/g-ai-robot3.umd.js +159 -10
- package/dist/g-ai-robot3.umd.min.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# g-ai-
|
|
1
|
+
# g-ai-robot3
|
|
2
2
|
|
|
3
3
|
## 简介
|
|
4
4
|
```
|
|
@@ -35,8 +35,11 @@ import "g-ai-robot3/dist/g-ai-robot3.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-robot3/dist/g-ai-robot3.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
|
|
@@ -5752,10 +5752,14 @@ axios.default = axios;
|
|
|
5752
5752
|
// this module should only have a default export
|
|
5753
5753
|
/* harmony default export */ var lib_axios = (axios);
|
|
5754
5754
|
|
|
5755
|
+
;// CONCATENATED MODULE: ./src/package/src/log.data.js
|
|
5756
|
+
const audioConfig = {
|
|
5757
|
+
here: "http://159.75.230.122:8086/here.mp3"
|
|
5758
|
+
};
|
|
5755
5759
|
;// 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
5760
|
|
|
5757
5761
|
|
|
5758
|
-
const _withScopeId = n => ((0,external_commonjs_vue_commonjs2_vue_root_Vue_namespaceObject.pushScopeId)("data-v-
|
|
5762
|
+
const _withScopeId = n => ((0,external_commonjs_vue_commonjs2_vue_root_Vue_namespaceObject.pushScopeId)("data-v-7f452dce"), n = n(), (0,external_commonjs_vue_commonjs2_vue_root_Vue_namespaceObject.popScopeId)(), n);
|
|
5759
5763
|
const _hoisted_1 = ["src"];
|
|
5760
5764
|
const _hoisted_2 = /*#__PURE__*/_withScopeId(() => /*#__PURE__*/(0,external_commonjs_vue_commonjs2_vue_root_Vue_namespaceObject.createElementVNode)("i", {
|
|
5761
5765
|
class: "iconfont icon-guanbi"
|
|
@@ -5800,6 +5804,7 @@ const _hoisted_20 = ["src"];
|
|
|
5800
5804
|
|
|
5801
5805
|
|
|
5802
5806
|
|
|
5807
|
+
|
|
5803
5808
|
/* harmony default export */ var mainvue_type_script_setup_true_lang_js = ({
|
|
5804
5809
|
__name: 'main',
|
|
5805
5810
|
props: {
|
|
@@ -5826,7 +5831,14 @@ const _hoisted_20 = ["src"];
|
|
|
5826
5831
|
type: Boolean,
|
|
5827
5832
|
default: true
|
|
5828
5833
|
},
|
|
5829
|
-
|
|
5834
|
+
space: {
|
|
5835
|
+
type: Number,
|
|
5836
|
+
default: 3000
|
|
5837
|
+
},
|
|
5838
|
+
mode: {
|
|
5839
|
+
type: String,
|
|
5840
|
+
default: "audio"
|
|
5841
|
+
},
|
|
5830
5842
|
qaServer: {
|
|
5831
5843
|
type: String,
|
|
5832
5844
|
default: "https://172.16.103.188:8002/api21215/chatGlm/searchTextNew"
|
|
@@ -5835,10 +5847,14 @@ const _hoisted_20 = ["src"];
|
|
|
5835
5847
|
type: String,
|
|
5836
5848
|
default: "https://172.16.103.188:8002/api21215/chatGlm/tansAudioToTextByWhisperNew"
|
|
5837
5849
|
},
|
|
5850
|
+
wsServer: {
|
|
5851
|
+
type: String,
|
|
5852
|
+
default: "wss://172.16.103.188:8002/ws"
|
|
5853
|
+
},
|
|
5838
5854
|
eventFun: {
|
|
5839
5855
|
type: Array,
|
|
5840
5856
|
default: () => [{
|
|
5841
|
-
keywords: ["
|
|
5857
|
+
keywords: ["回到2023年7月22日时刻"],
|
|
5842
5858
|
//匹配关键字
|
|
5843
5859
|
trigger: "after",
|
|
5844
5860
|
//回调触发时机
|
|
@@ -5855,6 +5871,8 @@ const _hoisted_20 = ["src"];
|
|
|
5855
5871
|
let pCtx = null;
|
|
5856
5872
|
let pCanvas = null;
|
|
5857
5873
|
let drawPlayId = null;
|
|
5874
|
+
let wenetWs = null;
|
|
5875
|
+
let wenetTimer = null;
|
|
5858
5876
|
const contentRef = (0,external_commonjs_vue_commonjs2_vue_root_Vue_namespaceObject.ref)(null);
|
|
5859
5877
|
const scrollContainer = (0,external_commonjs_vue_commonjs2_vue_root_Vue_namespaceObject.ref)(null);
|
|
5860
5878
|
const props = __props;
|
|
@@ -5865,6 +5883,8 @@ const _hoisted_20 = ["src"];
|
|
|
5865
5883
|
input: "",
|
|
5866
5884
|
list: [],
|
|
5867
5885
|
findMatch: {},
|
|
5886
|
+
recorderCode: 0,
|
|
5887
|
+
//1唤醒 0沉睡
|
|
5868
5888
|
recorder: new (js_audio_recorder_default())({
|
|
5869
5889
|
sampleBits: 16,
|
|
5870
5890
|
// 采样位数,支持 8 或 16,默认是16
|
|
@@ -5874,6 +5894,119 @@ const _hoisted_20 = ["src"];
|
|
|
5874
5894
|
// compiling: false,(0.x版本中生效,1.x增加中) // 是否边录边转换,默认是false
|
|
5875
5895
|
})
|
|
5876
5896
|
});
|
|
5897
|
+
(0,external_commonjs_vue_commonjs2_vue_root_Vue_namespaceObject.onMounted)(() => {
|
|
5898
|
+
startMonitorAudio();
|
|
5899
|
+
});
|
|
5900
|
+
const initRecorder = () => {
|
|
5901
|
+
js_audio_recorder_default().getPermission().then(() => {
|
|
5902
|
+
state.recorder.start(); // 开始录音
|
|
5903
|
+
}, error => {
|
|
5904
|
+
console.log(`${error.name} : ${error.message}`);
|
|
5905
|
+
});
|
|
5906
|
+
};
|
|
5907
|
+
const initWebScoket = () => {
|
|
5908
|
+
let url = props.wsServer;
|
|
5909
|
+
if ("WebSocket" in window) {
|
|
5910
|
+
wenetWs = new WebSocket(url);
|
|
5911
|
+
wenetWs.onopen = () => {
|
|
5912
|
+
console.log("Websocket 连接成功,开始识别");
|
|
5913
|
+
// 每2S发一次语音 进行监听唤醒
|
|
5914
|
+
wenetTimer = window.setInterval(() => {
|
|
5915
|
+
sendRecorder();
|
|
5916
|
+
}, props.space);
|
|
5917
|
+
};
|
|
5918
|
+
wenetWs.onmessage = _msg => {
|
|
5919
|
+
let data = JSON.parse(_msg.data);
|
|
5920
|
+
if (data.status == 1) {
|
|
5921
|
+
if (state.recorderCode == 0) {
|
|
5922
|
+
window.clearInterval(wenetTimer);
|
|
5923
|
+
wenetTimer = null;
|
|
5924
|
+
iAmHere();
|
|
5925
|
+
state.recorderCode = 1;
|
|
5926
|
+
window.setTimeout(() => {
|
|
5927
|
+
setRecording();
|
|
5928
|
+
}, 3000);
|
|
5929
|
+
}
|
|
5930
|
+
}
|
|
5931
|
+
};
|
|
5932
|
+
wenetWs.onclose = function () {
|
|
5933
|
+
console.log("WebSocket 连接断开");
|
|
5934
|
+
};
|
|
5935
|
+
wenetWs.onerror = function () {
|
|
5936
|
+
console.log("WebSocket 连接失败");
|
|
5937
|
+
};
|
|
5938
|
+
}
|
|
5939
|
+
};
|
|
5940
|
+
const sendRecorder = () => {
|
|
5941
|
+
let wavBlob = state.recorder.getWAVBlob();
|
|
5942
|
+
let newbolb = new Blob([wavBlob], {
|
|
5943
|
+
type: "audio/wav"
|
|
5944
|
+
});
|
|
5945
|
+
//获取当时时间戳作为文件名
|
|
5946
|
+
let fileOfBlob = new File([newbolb], new Date().getTime() + ".wav");
|
|
5947
|
+
|
|
5948
|
+
// 本地播放录音文件流
|
|
5949
|
+
// let sound = new Audio();
|
|
5950
|
+
// let src = URL.createObjectURL(fileOfBlob);
|
|
5951
|
+
// sound.src = src;
|
|
5952
|
+
// sound.play();
|
|
5953
|
+
|
|
5954
|
+
wenetWs.send(fileOfBlob);
|
|
5955
|
+
state.recorder.start();
|
|
5956
|
+
};
|
|
5957
|
+
|
|
5958
|
+
// 唤醒后的录音
|
|
5959
|
+
const setRecording = () => {
|
|
5960
|
+
state.recorder.stop();
|
|
5961
|
+
state.recorder.start();
|
|
5962
|
+
window.setTimeout(() => {
|
|
5963
|
+
let wavBlob = state.recorder.getWAVBlob();
|
|
5964
|
+
let newbolb = new Blob([wavBlob], {
|
|
5965
|
+
type: "audio/wav"
|
|
5966
|
+
});
|
|
5967
|
+
//获取当时时间戳作为文件名
|
|
5968
|
+
let fileOfBlob = new File([newbolb], new Date().getTime() + ".wav");
|
|
5969
|
+
state.recorder.stop();
|
|
5970
|
+
state.recorderCode = 0;
|
|
5971
|
+
let formData = new FormData();
|
|
5972
|
+
formData.append("modelName", "medium");
|
|
5973
|
+
formData.append("audio", fileOfBlob);
|
|
5974
|
+
uploadWavFile(formData).then(result => {
|
|
5975
|
+
let res = result.data;
|
|
5976
|
+
if (res.code == 200) {
|
|
5977
|
+
let {
|
|
5978
|
+
answer: audioToText
|
|
5979
|
+
} = res.detail.content;
|
|
5980
|
+
let text = audioToText;
|
|
5981
|
+
|
|
5982
|
+
// let text = "回到2023年7月22日时刻";
|
|
5983
|
+
|
|
5984
|
+
// 检索场景
|
|
5985
|
+
matching(text);
|
|
5986
|
+
|
|
5987
|
+
// 拿到的语音进行问答
|
|
5988
|
+
let option = {
|
|
5989
|
+
searchText: text,
|
|
5990
|
+
use_tts: "True"
|
|
5991
|
+
};
|
|
5992
|
+
searchText(option).then(q => {
|
|
5993
|
+
let data = q.data;
|
|
5994
|
+
if (data && data.code == 200) {
|
|
5995
|
+
let {
|
|
5996
|
+
ttsMaleAddress
|
|
5997
|
+
} = data.detail[0];
|
|
5998
|
+
// 播放回答内容和进行小G动作
|
|
5999
|
+
// playAudio(ttsMaleAddress);
|
|
6000
|
+
if (state.findMatch && state.findMatch.fun) {
|
|
6001
|
+
state.findMatch.fun();
|
|
6002
|
+
}
|
|
6003
|
+
}
|
|
6004
|
+
});
|
|
6005
|
+
}
|
|
6006
|
+
});
|
|
6007
|
+
startMonitorAudio();
|
|
6008
|
+
}, 5 * 1000);
|
|
6009
|
+
};
|
|
5877
6010
|
const searchText = data => {
|
|
5878
6011
|
let url = props.qaServer;
|
|
5879
6012
|
return lib_axios.post(url, data);
|
|
@@ -5882,6 +6015,20 @@ const _hoisted_20 = ["src"];
|
|
|
5882
6015
|
let url = props.audioServer;
|
|
5883
6016
|
return lib_axios.post(url, data);
|
|
5884
6017
|
};
|
|
6018
|
+
const startMonitorAudio = () => {
|
|
6019
|
+
if (props.mode == "audio") {
|
|
6020
|
+
initRecorder();
|
|
6021
|
+
initWebScoket();
|
|
6022
|
+
}
|
|
6023
|
+
};
|
|
6024
|
+
const iAmHere = () => {
|
|
6025
|
+
let sound = new Audio();
|
|
6026
|
+
var url = audioConfig.here;
|
|
6027
|
+
sound.src = url;
|
|
6028
|
+
window.setTimeout(() => {
|
|
6029
|
+
sound.play();
|
|
6030
|
+
}, 1000);
|
|
6031
|
+
};
|
|
5885
6032
|
const componentDidMount = () => {
|
|
5886
6033
|
pCanvas = document.getElementById("playChart");
|
|
5887
6034
|
pCtx = pCanvas.getContext("2d");
|
|
@@ -5942,6 +6089,7 @@ const _hoisted_20 = ["src"];
|
|
|
5942
6089
|
const closeQaDrawer = () => {
|
|
5943
6090
|
state.isShow = false;
|
|
5944
6091
|
state.list = [];
|
|
6092
|
+
state.findMatch = {};
|
|
5945
6093
|
if (state.aiTimer) {
|
|
5946
6094
|
window.clearInterval(state.aiTimer);
|
|
5947
6095
|
state.aiTimer = null;
|
|
@@ -6057,7 +6205,7 @@ const _hoisted_20 = ["src"];
|
|
|
6057
6205
|
qaType: "api",
|
|
6058
6206
|
...obj
|
|
6059
6207
|
});
|
|
6060
|
-
playAudio();
|
|
6208
|
+
// playAudio();
|
|
6061
6209
|
}
|
|
6062
6210
|
});
|
|
6063
6211
|
};
|
|
@@ -6118,7 +6266,8 @@ const _hoisted_20 = ["src"];
|
|
|
6118
6266
|
};
|
|
6119
6267
|
__expose({
|
|
6120
6268
|
searchText,
|
|
6121
|
-
uploadWavFile
|
|
6269
|
+
uploadWavFile,
|
|
6270
|
+
startMonitorAudio
|
|
6122
6271
|
});
|
|
6123
6272
|
return (_ctx, _cache) => {
|
|
6124
6273
|
return (0,external_commonjs_vue_commonjs2_vue_root_Vue_namespaceObject.openBlock)(), (0,external_commonjs_vue_commonjs2_vue_root_Vue_namespaceObject.createElementBlock)("div", {
|
|
@@ -6225,15 +6374,15 @@ const _hoisted_20 = ["src"];
|
|
|
6225
6374
|
});
|
|
6226
6375
|
;// CONCATENATED MODULE: ./src/package/src/main.vue?vue&type=script&setup=true&lang=js
|
|
6227
6376
|
|
|
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=
|
|
6377
|
+
;// 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=7f452dce&lang=css
|
|
6229
6378
|
// extracted by mini-css-extract-plugin
|
|
6230
6379
|
|
|
6231
|
-
;// CONCATENATED MODULE: ./src/package/src/main.vue?vue&type=style&index=0&id=
|
|
6380
|
+
;// CONCATENATED MODULE: ./src/package/src/main.vue?vue&type=style&index=0&id=7f452dce&lang=css
|
|
6232
6381
|
|
|
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=
|
|
6382
|
+
;// 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=7f452dce&lang=less&scoped=true
|
|
6234
6383
|
// extracted by mini-css-extract-plugin
|
|
6235
6384
|
|
|
6236
|
-
;// CONCATENATED MODULE: ./src/package/src/main.vue?vue&type=style&index=1&id=
|
|
6385
|
+
;// CONCATENATED MODULE: ./src/package/src/main.vue?vue&type=style&index=1&id=7f452dce&lang=less&scoped=true
|
|
6237
6386
|
|
|
6238
6387
|
// EXTERNAL MODULE: ./node_modules/vue-loader/dist/exportHelper.js
|
|
6239
6388
|
var exportHelper = __webpack_require__(6262);
|
|
@@ -6245,7 +6394,7 @@ var exportHelper = __webpack_require__(6262);
|
|
|
6245
6394
|
|
|
6246
6395
|
|
|
6247
6396
|
|
|
6248
|
-
const __exports__ = /*#__PURE__*/(0,exportHelper/* default */.A)(mainvue_type_script_setup_true_lang_js, [['__scopeId',"data-v-
|
|
6397
|
+
const __exports__ = /*#__PURE__*/(0,exportHelper/* default */.A)(mainvue_type_script_setup_true_lang_js, [['__scopeId',"data-v-7f452dce"]])
|
|
6249
6398
|
|
|
6250
6399
|
/* harmony default export */ var main = (__exports__);
|
|
6251
6400
|
;// 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-7f452dce]{position:fixed}#g-ai-robat .robot[data-v-7f452dce]{cursor:pointer}#g-ai-robat .robot img[data-v-7f452dce]{height:86px;width:70px}#g-ai-robat .talk_main[data-v-7f452dce]{position:absolute;width:400px;height:600px;background:#f5f6f7}#g-ai-robat .talk_main.top[data-v-7f452dce]{left:50%;bottom:100px;transform:translateX(-50%)}#g-ai-robat .talk_main.bottom[data-v-7f452dce]{left:50%;top:100px;transform:translateX(-50%)}#g-ai-robat .talk_main.right[data-v-7f452dce]{left:100px;bottom:50%;transform:translateY(50%)}#g-ai-robat .talk_main.left[data-v-7f452dce]{right:100px;bottom:50%;transform:translateY(50%)}#g-ai-robat .talk_main.top-end[data-v-7f452dce]{left:100px;bottom:100px}#g-ai-robat .talk_main.top-start[data-v-7f452dce]{right:100px;bottom:100px}#g-ai-robat .talk_main.bottom-start[data-v-7f452dce]{right:100px;top:100px}#g-ai-robat .talk_main.bottom-end[data-v-7f452dce]{left:100px;top:100px}#g-ai-robat .talk_main header[data-v-7f452dce]{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-7f452dce]{font-size:16px;font-weight:700}#g-ai-robat .talk_main header span.close[data-v-7f452dce]{color:#999}#g-ai-robat .talk_main header i[data-v-7f452dce]{cursor:pointer}#g-ai-robat .talk_main .qa_body[data-v-7f452dce]{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-7f452dce]::-webkit-scrollbar{width:8px;background-color:#f9f9f9}#g-ai-robat .talk_main .qa_body[data-v-7f452dce]::-webkit-scrollbar-track{background:#e1e1e1;border-radius:10px}#g-ai-robat .talk_main .qa_body[data-v-7f452dce]::-webkit-scrollbar-thumb{background-color:#c1c1c1;border-radius:10px}#g-ai-robat .talk_main .qa_body li[data-v-7f452dce]{display:flex;margin-bottom:24px;justify-content:flex-end}#g-ai-robat .talk_main .qa_body li .is_icon[data-v-7f452dce]{width:24px;height:24px;border-radius:50%;color:#fff;display:flex}#g-ai-robat .talk_main .qa_body li .is_icon i[data-v-7f452dce]{margin:auto}#g-ai-robat .talk_main .qa_body li.is_ai[data-v-7f452dce]{justify-content:flex-start}#g-ai-robat .talk_main .qa_body li.is_ai .text_main[data-v-7f452dce]{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-7f452dce]{white-space:pre-wrap}#g-ai-robat .talk_main .qa_body li .text_main[data-v-7f452dce]{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-7f452dce]{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-7f452dce]{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-7f452dce]{filter:hue-rotate(180deg);animation:opacityCss-7f452dce 2s linear infinite}#g-ai-robat .talk_main .qa_input[data-v-7f452dce]{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-7f452dce]{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-7f452dce]:focus{outline:none;border-color:#409eff}#g-ai-robat .talk_main .qa_input .is_icon[data-v-7f452dce]{width:30px}#g-ai-robat .talk_main .qa_input .is_icon p[data-v-7f452dce]{display:flex;align-items:center;justify-content:flex-end;margin:6px 0}#g-ai-robat .talk_main .qa_input .is_icon p[data-v-7f452dce]:first-of-type{position:relative}#g-ai-robat .talk_main .qa_input .is_icon p:first-of-type #playChart[data-v-7f452dce]{bottom:30px;position:absolute;visibility:hidden}#g-ai-robat .talk_main .qa_input .is_icon p:first-of-type #playChart.show[data-v-7f452dce]{visibility:visible}#g-ai-robat .talk_main .qa_input .is_icon p:first-of-type #playChart.hiddle[data-v-7f452dce]{visibility:hidden}#g-ai-robat .talk_main .qa_input .is_icon p img[data-v-7f452dce]{width:20px;height:20px;cursor:pointer}#g-ai-robat .talk_main .qa_input .is_icon p img.close[data-v-7f452dce]{filter:hue-rotate(180deg);animation:opacityCss-7f452dce 2s linear infinite}#g-ai-robat .talk_main .qa_input .is_icon p.send img.disabled[data-v-7f452dce]{cursor:not-allowed}#g-ai-robat .talk_main .qa_input .is_icon p i[data-v-7f452dce]{cursor:pointer}@keyframes opacityCss-7f452dce{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-7f452dce]{font-family:iconfont!important;font-size:16px;font-style:normal;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.icon-guanbi[data-v-7f452dce]:before{content:"\e609"}.icon-nvsheng[data-v-7f452dce]:before{content:"\e603"}.icon-nansheng[data-v-7f452dce]:before{content:"\e604"}.icon-fuzhi[data-v-7f452dce]:before{content:"\e626"}.icon-zhongxinhuida[data-v-7f452dce]:before{content:"\e63b"}
|
package/dist/g-ai-robot3.umd.js
CHANGED
|
@@ -5770,10 +5770,14 @@ axios.default = axios;
|
|
|
5770
5770
|
// this module should only have a default export
|
|
5771
5771
|
/* harmony default export */ var lib_axios = (axios);
|
|
5772
5772
|
|
|
5773
|
+
;// CONCATENATED MODULE: ./src/package/src/log.data.js
|
|
5774
|
+
const audioConfig = {
|
|
5775
|
+
here: "http://159.75.230.122:8086/here.mp3"
|
|
5776
|
+
};
|
|
5773
5777
|
;// 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
5778
|
|
|
5775
5779
|
|
|
5776
|
-
const _withScopeId = n => ((0,external_commonjs_vue_commonjs2_vue_root_Vue_.pushScopeId)("data-v-
|
|
5780
|
+
const _withScopeId = n => ((0,external_commonjs_vue_commonjs2_vue_root_Vue_.pushScopeId)("data-v-7f452dce"), n = n(), (0,external_commonjs_vue_commonjs2_vue_root_Vue_.popScopeId)(), n);
|
|
5777
5781
|
const _hoisted_1 = ["src"];
|
|
5778
5782
|
const _hoisted_2 = /*#__PURE__*/_withScopeId(() => /*#__PURE__*/(0,external_commonjs_vue_commonjs2_vue_root_Vue_.createElementVNode)("i", {
|
|
5779
5783
|
class: "iconfont icon-guanbi"
|
|
@@ -5818,6 +5822,7 @@ const _hoisted_20 = ["src"];
|
|
|
5818
5822
|
|
|
5819
5823
|
|
|
5820
5824
|
|
|
5825
|
+
|
|
5821
5826
|
/* harmony default export */ var mainvue_type_script_setup_true_lang_js = ({
|
|
5822
5827
|
__name: 'main',
|
|
5823
5828
|
props: {
|
|
@@ -5844,7 +5849,14 @@ const _hoisted_20 = ["src"];
|
|
|
5844
5849
|
type: Boolean,
|
|
5845
5850
|
default: true
|
|
5846
5851
|
},
|
|
5847
|
-
|
|
5852
|
+
space: {
|
|
5853
|
+
type: Number,
|
|
5854
|
+
default: 3000
|
|
5855
|
+
},
|
|
5856
|
+
mode: {
|
|
5857
|
+
type: String,
|
|
5858
|
+
default: "audio"
|
|
5859
|
+
},
|
|
5848
5860
|
qaServer: {
|
|
5849
5861
|
type: String,
|
|
5850
5862
|
default: "https://172.16.103.188:8002/api21215/chatGlm/searchTextNew"
|
|
@@ -5853,10 +5865,14 @@ const _hoisted_20 = ["src"];
|
|
|
5853
5865
|
type: String,
|
|
5854
5866
|
default: "https://172.16.103.188:8002/api21215/chatGlm/tansAudioToTextByWhisperNew"
|
|
5855
5867
|
},
|
|
5868
|
+
wsServer: {
|
|
5869
|
+
type: String,
|
|
5870
|
+
default: "wss://172.16.103.188:8002/ws"
|
|
5871
|
+
},
|
|
5856
5872
|
eventFun: {
|
|
5857
5873
|
type: Array,
|
|
5858
5874
|
default: () => [{
|
|
5859
|
-
keywords: ["
|
|
5875
|
+
keywords: ["回到2023年7月22日时刻"],
|
|
5860
5876
|
//匹配关键字
|
|
5861
5877
|
trigger: "after",
|
|
5862
5878
|
//回调触发时机
|
|
@@ -5873,6 +5889,8 @@ const _hoisted_20 = ["src"];
|
|
|
5873
5889
|
let pCtx = null;
|
|
5874
5890
|
let pCanvas = null;
|
|
5875
5891
|
let drawPlayId = null;
|
|
5892
|
+
let wenetWs = null;
|
|
5893
|
+
let wenetTimer = null;
|
|
5876
5894
|
const contentRef = (0,external_commonjs_vue_commonjs2_vue_root_Vue_.ref)(null);
|
|
5877
5895
|
const scrollContainer = (0,external_commonjs_vue_commonjs2_vue_root_Vue_.ref)(null);
|
|
5878
5896
|
const props = __props;
|
|
@@ -5883,6 +5901,8 @@ const _hoisted_20 = ["src"];
|
|
|
5883
5901
|
input: "",
|
|
5884
5902
|
list: [],
|
|
5885
5903
|
findMatch: {},
|
|
5904
|
+
recorderCode: 0,
|
|
5905
|
+
//1唤醒 0沉睡
|
|
5886
5906
|
recorder: new (js_audio_recorder_default())({
|
|
5887
5907
|
sampleBits: 16,
|
|
5888
5908
|
// 采样位数,支持 8 或 16,默认是16
|
|
@@ -5892,6 +5912,119 @@ const _hoisted_20 = ["src"];
|
|
|
5892
5912
|
// compiling: false,(0.x版本中生效,1.x增加中) // 是否边录边转换,默认是false
|
|
5893
5913
|
})
|
|
5894
5914
|
});
|
|
5915
|
+
(0,external_commonjs_vue_commonjs2_vue_root_Vue_.onMounted)(() => {
|
|
5916
|
+
startMonitorAudio();
|
|
5917
|
+
});
|
|
5918
|
+
const initRecorder = () => {
|
|
5919
|
+
js_audio_recorder_default().getPermission().then(() => {
|
|
5920
|
+
state.recorder.start(); // 开始录音
|
|
5921
|
+
}, error => {
|
|
5922
|
+
console.log(`${error.name} : ${error.message}`);
|
|
5923
|
+
});
|
|
5924
|
+
};
|
|
5925
|
+
const initWebScoket = () => {
|
|
5926
|
+
let url = props.wsServer;
|
|
5927
|
+
if ("WebSocket" in window) {
|
|
5928
|
+
wenetWs = new WebSocket(url);
|
|
5929
|
+
wenetWs.onopen = () => {
|
|
5930
|
+
console.log("Websocket 连接成功,开始识别");
|
|
5931
|
+
// 每2S发一次语音 进行监听唤醒
|
|
5932
|
+
wenetTimer = window.setInterval(() => {
|
|
5933
|
+
sendRecorder();
|
|
5934
|
+
}, props.space);
|
|
5935
|
+
};
|
|
5936
|
+
wenetWs.onmessage = _msg => {
|
|
5937
|
+
let data = JSON.parse(_msg.data);
|
|
5938
|
+
if (data.status == 1) {
|
|
5939
|
+
if (state.recorderCode == 0) {
|
|
5940
|
+
window.clearInterval(wenetTimer);
|
|
5941
|
+
wenetTimer = null;
|
|
5942
|
+
iAmHere();
|
|
5943
|
+
state.recorderCode = 1;
|
|
5944
|
+
window.setTimeout(() => {
|
|
5945
|
+
setRecording();
|
|
5946
|
+
}, 3000);
|
|
5947
|
+
}
|
|
5948
|
+
}
|
|
5949
|
+
};
|
|
5950
|
+
wenetWs.onclose = function () {
|
|
5951
|
+
console.log("WebSocket 连接断开");
|
|
5952
|
+
};
|
|
5953
|
+
wenetWs.onerror = function () {
|
|
5954
|
+
console.log("WebSocket 连接失败");
|
|
5955
|
+
};
|
|
5956
|
+
}
|
|
5957
|
+
};
|
|
5958
|
+
const sendRecorder = () => {
|
|
5959
|
+
let wavBlob = state.recorder.getWAVBlob();
|
|
5960
|
+
let newbolb = new Blob([wavBlob], {
|
|
5961
|
+
type: "audio/wav"
|
|
5962
|
+
});
|
|
5963
|
+
//获取当时时间戳作为文件名
|
|
5964
|
+
let fileOfBlob = new File([newbolb], new Date().getTime() + ".wav");
|
|
5965
|
+
|
|
5966
|
+
// 本地播放录音文件流
|
|
5967
|
+
// let sound = new Audio();
|
|
5968
|
+
// let src = URL.createObjectURL(fileOfBlob);
|
|
5969
|
+
// sound.src = src;
|
|
5970
|
+
// sound.play();
|
|
5971
|
+
|
|
5972
|
+
wenetWs.send(fileOfBlob);
|
|
5973
|
+
state.recorder.start();
|
|
5974
|
+
};
|
|
5975
|
+
|
|
5976
|
+
// 唤醒后的录音
|
|
5977
|
+
const setRecording = () => {
|
|
5978
|
+
state.recorder.stop();
|
|
5979
|
+
state.recorder.start();
|
|
5980
|
+
window.setTimeout(() => {
|
|
5981
|
+
let wavBlob = state.recorder.getWAVBlob();
|
|
5982
|
+
let newbolb = new Blob([wavBlob], {
|
|
5983
|
+
type: "audio/wav"
|
|
5984
|
+
});
|
|
5985
|
+
//获取当时时间戳作为文件名
|
|
5986
|
+
let fileOfBlob = new File([newbolb], new Date().getTime() + ".wav");
|
|
5987
|
+
state.recorder.stop();
|
|
5988
|
+
state.recorderCode = 0;
|
|
5989
|
+
let formData = new FormData();
|
|
5990
|
+
formData.append("modelName", "medium");
|
|
5991
|
+
formData.append("audio", fileOfBlob);
|
|
5992
|
+
uploadWavFile(formData).then(result => {
|
|
5993
|
+
let res = result.data;
|
|
5994
|
+
if (res.code == 200) {
|
|
5995
|
+
let {
|
|
5996
|
+
answer: audioToText
|
|
5997
|
+
} = res.detail.content;
|
|
5998
|
+
let text = audioToText;
|
|
5999
|
+
|
|
6000
|
+
// let text = "回到2023年7月22日时刻";
|
|
6001
|
+
|
|
6002
|
+
// 检索场景
|
|
6003
|
+
matching(text);
|
|
6004
|
+
|
|
6005
|
+
// 拿到的语音进行问答
|
|
6006
|
+
let option = {
|
|
6007
|
+
searchText: text,
|
|
6008
|
+
use_tts: "True"
|
|
6009
|
+
};
|
|
6010
|
+
searchText(option).then(q => {
|
|
6011
|
+
let data = q.data;
|
|
6012
|
+
if (data && data.code == 200) {
|
|
6013
|
+
let {
|
|
6014
|
+
ttsMaleAddress
|
|
6015
|
+
} = data.detail[0];
|
|
6016
|
+
// 播放回答内容和进行小G动作
|
|
6017
|
+
// playAudio(ttsMaleAddress);
|
|
6018
|
+
if (state.findMatch && state.findMatch.fun) {
|
|
6019
|
+
state.findMatch.fun();
|
|
6020
|
+
}
|
|
6021
|
+
}
|
|
6022
|
+
});
|
|
6023
|
+
}
|
|
6024
|
+
});
|
|
6025
|
+
startMonitorAudio();
|
|
6026
|
+
}, 5 * 1000);
|
|
6027
|
+
};
|
|
5895
6028
|
const searchText = data => {
|
|
5896
6029
|
let url = props.qaServer;
|
|
5897
6030
|
return lib_axios.post(url, data);
|
|
@@ -5900,6 +6033,20 @@ const _hoisted_20 = ["src"];
|
|
|
5900
6033
|
let url = props.audioServer;
|
|
5901
6034
|
return lib_axios.post(url, data);
|
|
5902
6035
|
};
|
|
6036
|
+
const startMonitorAudio = () => {
|
|
6037
|
+
if (props.mode == "audio") {
|
|
6038
|
+
initRecorder();
|
|
6039
|
+
initWebScoket();
|
|
6040
|
+
}
|
|
6041
|
+
};
|
|
6042
|
+
const iAmHere = () => {
|
|
6043
|
+
let sound = new Audio();
|
|
6044
|
+
var url = audioConfig.here;
|
|
6045
|
+
sound.src = url;
|
|
6046
|
+
window.setTimeout(() => {
|
|
6047
|
+
sound.play();
|
|
6048
|
+
}, 1000);
|
|
6049
|
+
};
|
|
5903
6050
|
const componentDidMount = () => {
|
|
5904
6051
|
pCanvas = document.getElementById("playChart");
|
|
5905
6052
|
pCtx = pCanvas.getContext("2d");
|
|
@@ -5960,6 +6107,7 @@ const _hoisted_20 = ["src"];
|
|
|
5960
6107
|
const closeQaDrawer = () => {
|
|
5961
6108
|
state.isShow = false;
|
|
5962
6109
|
state.list = [];
|
|
6110
|
+
state.findMatch = {};
|
|
5963
6111
|
if (state.aiTimer) {
|
|
5964
6112
|
window.clearInterval(state.aiTimer);
|
|
5965
6113
|
state.aiTimer = null;
|
|
@@ -6075,7 +6223,7 @@ const _hoisted_20 = ["src"];
|
|
|
6075
6223
|
qaType: "api",
|
|
6076
6224
|
...obj
|
|
6077
6225
|
});
|
|
6078
|
-
playAudio();
|
|
6226
|
+
// playAudio();
|
|
6079
6227
|
}
|
|
6080
6228
|
});
|
|
6081
6229
|
};
|
|
@@ -6136,7 +6284,8 @@ const _hoisted_20 = ["src"];
|
|
|
6136
6284
|
};
|
|
6137
6285
|
__expose({
|
|
6138
6286
|
searchText,
|
|
6139
|
-
uploadWavFile
|
|
6287
|
+
uploadWavFile,
|
|
6288
|
+
startMonitorAudio
|
|
6140
6289
|
});
|
|
6141
6290
|
return (_ctx, _cache) => {
|
|
6142
6291
|
return (0,external_commonjs_vue_commonjs2_vue_root_Vue_.openBlock)(), (0,external_commonjs_vue_commonjs2_vue_root_Vue_.createElementBlock)("div", {
|
|
@@ -6243,15 +6392,15 @@ const _hoisted_20 = ["src"];
|
|
|
6243
6392
|
});
|
|
6244
6393
|
;// CONCATENATED MODULE: ./src/package/src/main.vue?vue&type=script&setup=true&lang=js
|
|
6245
6394
|
|
|
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=
|
|
6395
|
+
;// 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=7f452dce&lang=css
|
|
6247
6396
|
// extracted by mini-css-extract-plugin
|
|
6248
6397
|
|
|
6249
|
-
;// CONCATENATED MODULE: ./src/package/src/main.vue?vue&type=style&index=0&id=
|
|
6398
|
+
;// CONCATENATED MODULE: ./src/package/src/main.vue?vue&type=style&index=0&id=7f452dce&lang=css
|
|
6250
6399
|
|
|
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=
|
|
6400
|
+
;// 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=7f452dce&lang=less&scoped=true
|
|
6252
6401
|
// extracted by mini-css-extract-plugin
|
|
6253
6402
|
|
|
6254
|
-
;// CONCATENATED MODULE: ./src/package/src/main.vue?vue&type=style&index=1&id=
|
|
6403
|
+
;// CONCATENATED MODULE: ./src/package/src/main.vue?vue&type=style&index=1&id=7f452dce&lang=less&scoped=true
|
|
6255
6404
|
|
|
6256
6405
|
// EXTERNAL MODULE: ./node_modules/vue-loader/dist/exportHelper.js
|
|
6257
6406
|
var exportHelper = __webpack_require__(6262);
|
|
@@ -6263,7 +6412,7 @@ var exportHelper = __webpack_require__(6262);
|
|
|
6263
6412
|
|
|
6264
6413
|
|
|
6265
6414
|
|
|
6266
|
-
const __exports__ = /*#__PURE__*/(0,exportHelper/* default */.A)(mainvue_type_script_setup_true_lang_js, [['__scopeId',"data-v-
|
|
6415
|
+
const __exports__ = /*#__PURE__*/(0,exportHelper/* default */.A)(mainvue_type_script_setup_true_lang_js, [['__scopeId',"data-v-7f452dce"]])
|
|
6267
6416
|
|
|
6268
6417
|
/* harmony default export */ var main = (__exports__);
|
|
6269
6418
|
;// CONCATENATED MODULE: ./src/package/index.js
|