feat:修改

feat/meeting
gaotian 8 months ago
parent 15b627ed8f
commit 4f9587a7ec
  1. 32
      meeting/online/index.vue

@ -61,6 +61,9 @@ export default {
recorderManager: null,
innerAudioContext: {},
isRecording: false,
ws: null,
webSocketUrl: "",
VITE_APP_WS: "wss://u140106-8027-537a5c07.westx.seetacloud.com:8443/api/stt/service"
};
},
onLoad() {
@ -74,8 +77,37 @@ export default {
// console.log('recorder stop' + JSON.stringify(res));
// self.voicePath = res.tempFilePath;
// });
this.initWebSocket();
},
methods: {
async initWebSocket() {
let url = this.VITE_APP_WS;
var audio_type = "mic_stream";
var hot_words = "碳丝路 元梦空间";
var hot_words2 = "碳丝路元梦空间";
var language = "zh";
var sample_rate = "16000";
var timestamp = Math.floor(Date.now() / 1000);
var api_key = "AT_syAHhLp3vqOA!@+T9Cocxc0^6z@^9";
var auth = `api_key=${api_key}&audio_type=${audio_type}&hot_words=${hot_words2}&language=${language}&sample_rate=${sample_rate}&stream=True&timestamp=${timestamp}`;
const sign = await this.sha256(auth);
url = `${url}?audio_type=${audio_type}&hot_words=${encodeURIComponent(hot_words)}&language=${language}&sample_rate=${sample_rate}&timestamp=${timestamp}&api_key=${encodeURIComponent(api_key)}&auth=${sign}`;
createdWebSocket(url);
},
async sha256(str) {
//
const encoder = new TextEncoder();
const data = encoder.encode(str);
// SubtleCrypto APISHA-256
return crypto.subtle.digest("SHA-256", data).then(buffer => {
//
const hexArray = Array.from(new Uint8Array(buffer));
const hexString = hexArray
.map(byte => byte.toString(16).padStart(2, "0"))
.join("");
return hexString;
});
},
confirm() {
this.popConfig.show = false;
},

Loading…
Cancel
Save