generated from tailored/router-template
42 lines
1.0 KiB
TypeScript
42 lines
1.0 KiB
TypeScript
import { VideoWS } from '../ws.ts';
|
|
import net from 'net';
|
|
import { Recording } from '../../../../recorder/index.ts';
|
|
import Stream from 'stream';
|
|
|
|
const recorder = new Recording();
|
|
const writeStream = new Stream.Writable();
|
|
const ws = new VideoWS({
|
|
url: 'wss://192.168.31.220:10095',
|
|
isFile: false,
|
|
onConnect: async () => {
|
|
console.log('onConnect');
|
|
let chunks: Buffer = Buffer.alloc(0);
|
|
var chunk_size = 960; // for asr chunk_size [5, 10, 5]
|
|
let totalsend = 0;
|
|
let len = 0;
|
|
recorder.stream().on('data', (chunk) => {
|
|
chunks = Buffer.concat([chunks, chunk]);
|
|
if (chunks.length > chunk_size) {
|
|
ws.send(chunks);
|
|
totalsend += chunks.length;
|
|
chunks = Buffer.alloc(0);
|
|
}
|
|
});
|
|
ws.start();
|
|
setTimeout(() => {
|
|
ws.stop();
|
|
setTimeout(() => {
|
|
process.exit(0);
|
|
}, 1000);
|
|
console.log('len', len);
|
|
}, 20000);
|
|
},
|
|
});
|
|
|
|
const server = net.createServer((socket) => {
|
|
socket.on('data', (data) => {
|
|
console.log('data', data);
|
|
});
|
|
});
|
|
server.listen(10096);
|