generated from tailored/router-db-template
temp test
This commit is contained in:
@@ -60,7 +60,7 @@ export class VideoWS extends WSServer {
|
||||
|
||||
async start(opts?: Partial<OpenRequest>) {
|
||||
const chunk_size = new Array(5, 10, 5);
|
||||
|
||||
console.log('start', chunk_size);
|
||||
const request: OpenRequest = {
|
||||
chunk_size: chunk_size,
|
||||
wav_name: 'h5', //
|
||||
@@ -94,15 +94,20 @@ export class VideoWS extends WSServer {
|
||||
this.ws.send(data);
|
||||
}
|
||||
}
|
||||
async sendBuffer(data: Buffer, opts?: { isFile?: boolean; wav_format?: string }) {
|
||||
const { wav_format = 'wav' } = opts || {};
|
||||
/**
|
||||
* 发送音频数据, 离线
|
||||
* @param data 音频数据
|
||||
* @param opts 选项
|
||||
*/
|
||||
async sendBuffer(data: Buffer, opts?: { isFile?: boolean; wav_format?: string; online?: boolean }) {
|
||||
const { wav_format = 'wav', online = false } = opts || {};
|
||||
if (this.ws && this.ws.readyState === WebSocket.OPEN) {
|
||||
let sampleBuf = new Uint8Array(data);
|
||||
const ws = this;
|
||||
var chunk_size = 960; // for asr chunk_size [5, 10, 5]
|
||||
let totalsend = 0;
|
||||
let len = 0;
|
||||
ws.start({ wav_format });
|
||||
if (!online) ws.start({ wav_format });
|
||||
while (sampleBuf.length >= chunk_size) {
|
||||
const sendBuf = sampleBuf.slice(0, chunk_size);
|
||||
totalsend = totalsend + sampleBuf.length;
|
||||
@@ -111,7 +116,7 @@ export class VideoWS extends WSServer {
|
||||
ws.send(sendBuf);
|
||||
len++;
|
||||
}
|
||||
ws.stop();
|
||||
if (!online) ws.stop();
|
||||
}
|
||||
}
|
||||
async onMessage(event: MessageEvent) {
|
||||
|
||||
Reference in New Issue
Block a user