gpt4 book ai didi

node.js - BinaryJS 服务器响应

转载 作者:太空宇宙 更新时间:2023-11-03 23:35:49 25 4
gpt4 key购买 nike

给出以下示例:

binaryServer = BinaryServer({port: 9001});

binaryServer.on('connection', function(client) {
console.log("new connection");


client.on('stream', function(stream, meta) {
console.log('new stream');
strean.on('data', function('data'){
//(code to store audio in buffers)});

stream.on('end', function() {
//end of stream
//(routine that calls an addon and convert speech to text)
//****Immediate response to client******
});
});
});

现在,我的目标是在生成响应后立即发送响应(给客户端)。我正在尝试使用 BinaryJS 来做到这一点但我不明白怎么做。

最佳答案

服务器端:

binaryServer = BinaryServer({port: 9001});

binaryServer.on('connection', function(client) {
console.log("new connection");


client.on('stream', function(stream, meta) {
console.log('new stream');
strean.on('data', function('data'){
//(code to store audio in buffers)});

stream.on('end', function() {
//end of stream
//(routine that calls an addon and convert speech to text)
//****Immediate response to client******
stream.write(some_variable);<---just do this
});
});
});

客户端:

client.on('open', function() {

Stream = client.createStream("some meta information);
//(some rotines)
Stream.on('data', function(data){ ///-->recebe resposta do stream.write()
console.log("RESULTADO: "+data);
});
}

);

关于node.js - BinaryJS 服务器响应,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32693740/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com