Comments (7)
Maybe you could develop it with the doc.
from funasr.
I've tried send data, the most complicated part is splite data with nodejs.
from funasr.
I don't finger out how many bytes should I send per time. Even I send them all, I could not get answer from server, too. this is my test code.
async function connect(): Promise<WebSocket> {
const uri = `wss://0.0.0.0:10095`;
return new Promise<WebSocket>((resolve, reject) => {
const ws = new WebSocket(uri, [], {
rejectUnauthorized: false,
// secureOptions: SSL_OP_NO_TLSv1_2,
});
ws.on('open', () => {
console.log('连接成功');
resolve(ws);
setInterval(() => {
ws.send('ping');
}, 1000);
});
ws.on('message', (raw) => {
const data = JSON.parse(Buffer.from(raw as Buffer).toString('utf-8')) as {
text: string;
timestamp: string;
wav_name: string;
is_final: boolean;
mode: '2pass-offline';
stamp_sents: {
end: number;
punc: string;
start: number;
text_seg: string;
ts_list: number[];
}[];
};
console.log('收到消息', data.text);
});
ws.on('error', (err) => {
console.log('连接失败', err);
reject(err);
});
});
}
async function main(): Promise<void> {
const filepath = '/home/taoqf/Downloads/testmp4.wav';
const mode = '2pass';
// const mode = 'offline';
const useItn = true;
// 读取hotword文件并构建fst_dict
const fstDict = {
'产教': 10,
// '铲掉': 0
};
const hotwordMessage = JSON.stringify(fstDict);
console.log(hotwordMessage);
const ws = await connect();
console.log('开始发送数据');
// 模拟sample_rate和wav_format
const sampleRate = 8000; // 假设的采样率
const wavFormat = 'pcm';
const chunk_size = [5, 10, 5]; // 表示流式模型latency配置,`[5,10,5]`,表示当前音频为600ms,并且回看300ms,又看300ms。
const chunk_interval = 10;
// 发送第一条消息
// {"audio_fs":8000,"chunk_interval":10,"chunk_size":[5,10,5],"hotwords":"","is_speaking":true,"itn":true,"mode":"offline","wav_format":"pcm","wav_name":"demo"}, msg_data->msg={"access_num":0,"audio_fs":8000,"is_eof":false,"itn":true,"mode":"offline","wav_format":"pcm","wav_name":"demo"}
const message = JSON.stringify({
mode,
chunk_size,
chunk_interval,
audio_fs: sampleRate,
wav_name: 'demo', // 假设的wav名称
wav_format: wavFormat,
is_speaking: true,
hotwords: hotwordMessage,
itn: useItn
});
await ws.send(message);
// 处理wav文件
const buf = await readFile(filepath);
let i = 0; // skip first 44 wav header
// ws.send(buf);
const int_chunk_size = 60 * chunk_size[1] / chunk_interval;
const chunk = sampleRate / 1000 * int_chunk_size;
console.log('开始发送文件内容', buf.length, chunk);
while (i < buf.length) {
const sub = buf.subarray(i, i += chunk * 2);
ws.send(sub);
console.log('发送', i);
await sleep(100);
}
console.log('文件内容发送结束');
// await sleep(100000);
// end
const endMessage = JSON.stringify({ is_speaking: false });
await ws.send(endMessage);
console.log('发送结束');
// await ws.close();
console.log('end');
}
from funasr.
@LauraGPT Could you please guid me? I really get into a dead end. I tried to call python client in nodejs, but I could only get results when the whole response is finished.
from funasr.
Is there anyone can help me?
from funasr.
@LauraGPT Could you please guid me? I really get into a dead end. I tried to call python client in nodejs, but I could only get results when the whole response is finished.
I do not have any skills about JS.
from funasr.
@LauraGPT Thank you anyway. btw, the doc need to be updated, there is no chunk param in the doc. but in fact, I could not send whole file to the server.
from funasr.
Related Issues (20)
- speech_ngram_lm_zh-cn-ai-wesp-fst 这个模型怎么做增量训练
- any support for fine-tune audio data longer than 1 minute?
- 离线文件服务websocket解析音频后,返回的结果不对
- windows on arm64 电脑 编译FunASR : onnx runtime for windows 这里,你应该说明ffmpeg版本 HOT 4
- 不行,windows11 on arm64 电脑上运行不了
- AssertionError: paraformer-zh-streaming is not registered HOT 1
- funasr-runtime-sdk-gpu-0.1.1版本运行过程中出现异常 HOT 3
- 基于paraformer & whisper 的离线转写网页,时间戳断句试听,生成字幕等 HOT 2
- ValueError: math domain error HOT 1
- 音频开始有个类似开幕音,会被识别为“嗯”。这需要如何配置,还是需要微调
- 在一台服务器上,开多个服务,推理速度上不去 HOT 4
- funasr:funasr-runtime-sdk-gpu-0.1.1和funasr:funasr-runtime-sdk-gpu-0.1.0镜像怎么都下载不了了 HOT 1
- Paraformer-zh模型不加载VAD模型无法识别标点 HOT 1
- 热词和时间戳无法同时生效 HOT 7
- 下载funasr:funasr-runtime-sdk-gpu-0.1.1,下到一半提示这个是什么问题
- 可以区分说话人角色和数量 HOT 2
- sencevoice模型无法和punc模型与cam模型一起加载 HOT 1
- 40/10000 实时翻译 40/10000 real-time translation: In the fine tuned inference results, the ID is confused, which makes it inconvenient to calculate the error rate. Is there a solution? Translation: In the fine tuned inference result, the ID is garbled, making it inconvenient to calculate the error rate. Is there a solution 划译 In the fine tuned Inference result, the ID is garbled, making it inconvenient to calculate the error rate. Is there a solution
- In the fine tuned Inference result, the ID is garbled, making it inconvenient to calculate the error rate. Is there a solution?
- 2pass模式下,部署funasr的英文识别结果,最后两个单词之间没有空格 HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from funasr.