This commit is contained in:
田岩
2025-12-01 21:00:54 +08:00
parent fde86ef902
commit 67c44bc746
97 changed files with 45781 additions and 395 deletions
@@ -21,22 +21,8 @@
},
methods: {
connect() {
// 这里链接socket或者sse,并把接受到的二进制数据不断调用即可, 具体的ws请自行封装
// ws = uni.connectSocket({
// url: 'ws://10.10.10.201:8000/ws/audio',
// method: 'GET',
// success() {},
// fail(e) {
// console.log(e);
// }
// });
// ws.onMessage(arrayBuffer => {
// console.log('arrayBuffer', arrayBuffer);
// this.isStreamPlaying = true
// this.currBuffer= uni.arrayBufferToBase64(arrayBuffer)
// })
this.ws = uni.connectSocket({
url: 'ws://10.10.10.201:8000/ws/audio',
url: 'ws://172.16.89.58:8000/ws/audio',
complete: () => {
console.log('complete');
},
@@ -60,10 +46,8 @@
this.isStreamPlaying = true
this.currBuffer= uni.arrayBufferToBase64(messageData)
try {
// const str = this.arrayBufferToStringCompat(messageData);
// console.log('转换后的字符串:', str);
} catch (e) {
console.log('二进制数据解析失败:', e);
}
@@ -77,6 +61,10 @@
},
changeStreamPlaying(e) {
this.isStreamPlaying = e.type
},
appendBuffer(messageData) {
this.isStreamPlaying = true
this.currBuffer= uni.arrayBufferToBase64(messageData)
}
}
}
@@ -99,6 +87,7 @@
},
methods: {
playTTS (base64) {
console.log('base64', base64);
if(!base64)return
const binaryStr = atob(base64)
const bytes = new Uint8Array(binaryStr.length)
@@ -30,6 +30,7 @@ export class StreamPlayer {
}
appendChunk(audioData) {
console.log('this.audioQueue', this.audioQueue.length);
this.audioQueue.push(audioData);
this._processQueue();
}
@@ -1,6 +1,5 @@
<template>
<view :options="options" :change:options="record.startRecord" :status="status" :change:status="record.onStop">
</view>
</template>
<script>