modelscope / FunASR

A Fundamental End-to-End Speech Recognition Toolkit and Open Source SOTA Pretrained Models, Supporting Speech Recognition, Voice Activity Detection, Text Post-processing etc.
https://www.funasr.com
Other
6.95k stars 738 forks source link

C++ Websocket多线程卡住 #2180

Closed monsterlyg closed 1 week ago

monsterlyg commented 2 weeks ago

客户端请求线程数大于1时,第一个线程处理完后,后面卡死;

服务端日志: I20241029 12:25:47.567818 24235 websocket-server.cpp:411] model successfully inited I20241029 12:25:47.567828 24235 websocket-server.cpp:413] initAsr run check_and_clean_connection I20241029 12:25:47.567963 24235 websocket-server.cpp:416] initAsr run check_and_clean_connection finished I20241029 12:25:47.567978 24235 funasr-wss-server.cpp:485] decoder-thread-num: 32 I20241029 12:25:47.567987 24235 funasr-wss-server.cpp:486] io-thread-num: 2 I20241029 12:25:47.567996 24235 funasr-wss-server.cpp:487] model-thread-num: 4 I20241029 12:25:47.568003 24235 funasr-wss-server.cpp:488] asr model init finished. listen on port:10095 I20241029 12:26:06.766250 24304 websocket-server.cpp:170] on_open, active connections: 1 I20241029 12:26:06.766355 24303 websocket-server.cpp:170] on_open, active connections: 2 I20241029 12:26:06.772610 24304 websocket-server.cpp:343] hotwords: I20241029 12:26:06.772665 24304 websocket-server.cpp:346] 阿里巴巴 : 20 I20241029 12:26:06.772688 24304 websocket-server.cpp:346] 通义实验室 : 30 I20241029 12:26:06.772758 24304 paraformer.cpp:640] 阿里巴巴 I20241029 12:26:06.772794 24304 paraformer.cpp:640] 通义实验室 I20241029 12:26:06.772825 24304 paraformer.cpp:664] clas shape 3 10 I20241029 12:26:06.822302 24303 websocket-server.cpp:365] client done I20241029 12:26:40.593922 24236 websocket-server.cpp:125] buffer.size=5254058,result json= dummy I20241029 12:26:40.594755 24304 websocket-server.cpp:187] on_close, active connections: 2 I20241029 12:26:42.569332 24302 websocket-server.cpp:246] connection is closed. I20241029 12:26:42.569416 24302 websocket-server.cpp:207] remove one connection

客户端: ./bin/funasr-wss-client --server-ip 127.0.0.1 --port 10095 --wav-path /data8/liyinggang/Assets/audios/zhihuijiaoshi.wav --is-ssl 0 --thread-num 2 I20241029 12:26:06.785463 24331 funasr-wss-client.cpp:316] Thread: 140489488205568, sended data len=5254058 I20241029 12:26:40.594415 24334 funasr-wss-client.cpp:102] Thread: 140489463027456, total_recv=1 I20241029 12:26:40.594481 24334 funasr-wss-client.cpp:107] Thread: 140489463027456, close client thread

lyblsgo commented 2 weeks ago

--wav_path 可以是音频或者文件列表,"the input could be: wav_path, e.g.: asr_example.wav; pcm_path, e.g.: asr_example.pcm; wav.scp, kaldi style wav list (wav_id \t wav_path)" --thread-num的含义是多线程去处理列表中的音频 你开了两个线程,只给了一个音频 --wav-path /data8/liyinggang/Assets/audios/zhihuijiaoshi.wav

monsterlyg commented 2 weeks ago

--wav_path 可以是音频或者文件列表,"the input could be: wav_path, e.g.: asr_example.wav; pcm_path, e.g.: asr_example.pcm; wav.scp, kaldi style wav list (wav_id \t wav_path)" --thread-num的含义是多线程去处理列表中的音频 你开了两个线程,只给了一个音频 --wav-path /data8/liyinggang/Assets/audios/zhihuijiaoshi.wav

是这个原因,多谢;看了代码,多余的线程接收不到close的信号,asio_thread一直阻塞;