Browse Source

Merge branch 'dev_des' of http://123.60.98.226:3000/jiazhipeng/EpicSoul into dev_des

dev_des
zhangminghao 3 weeks ago
parent
commit
1a8c18092c
  1. 2
      components/GPT/index.vue
  2. 1
      components/GPT/utils/ClientData.js
  3. 4
      components/GPT/utils/audio.js
  4. 7
      components/GPT/utils/socket.js

2
components/GPT/index.vue

@ -220,6 +220,7 @@ export default {
console.log(1111, str)
},
async init() {
console.log("------agentId参数-----", this.agentId);
this.player = new PCMPlayer({
sampleRate: 16000,
onPlay: (obj) => {
@ -408,7 +409,6 @@ export default {
this.scrollToBottom(1000)
await this.socketObj.init()
this.$ClientData = new ClientData()
console.log(this.$ClientData,'ClientData')
this.$ClientData.init()
this.$ClientData.setAttr({ socketObj: this.socketObj })
this.robotObj = this.socketObj.robotObj

1
components/GPT/utils/ClientData.js

@ -1,3 +1,4 @@
import Vue from "vue";
import { MESSAGE_TYPE } from "./chat_constant";
import { getQueryVariable, generateRequestId, arrayUnique } from "./util";
import { v4 as uuidv4 } from "uuid";

4
components/GPT/utils/audio.js

@ -45,6 +45,7 @@ export default class Audio {
async createSocket(options) {
console.log("开始创建socket", options);
return new Promise(async (resolve, reject) => {
if (this.selfCloseStatus) {return}
// const origin = "wss://des.js-dyyj.com/xcx/tts-websocket";
const origin = "wss://des.dayunyuanjian.cn/xcx/tts-websocket";
// 建立连接
@ -63,6 +64,9 @@ export default class Audio {
console.log("socket.onOpen", e);
// 监听发送
options && options.complete && options.complete();
if (this.selfCloseStatus) {
this.destroy()
}
});
socket.onMessage((e) => {

7
components/GPT/utils/socket.js

@ -68,6 +68,8 @@ export default class Socket {
this.robotObj = res.data.requestInfo;
console.log("获取token:", mainToken);
if (this.selfCloseStatus) {return}
// 建立连接
const socket = wx.connectSocket({
url: `${origin}${path}?EIO=4&transport=websocket`,
@ -116,6 +118,11 @@ export default class Socket {
}
options && options.complete && options.complete()
if (this.selfCloseStatus) {
this.destroy()
}
});
socket.onMessage((e) => {

Loading…
Cancel
Save