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.47k stars 688 forks source link

FunASR中grpc的demo,VAD并发报错 #509

Closed fatmop closed 1 year ago

fatmop commented 1 year ago

做项目遇到并发报错,跑到FunAsr Demo里也去执行了下,发现了同样的错误,如下:

OS: [e.g. linux] ubuntu20.04 和 Macbook都测试了 Python Version:py37-torch1.13.1 Package Version:modelscope 1.4.1 funasr 0.3.1

Model:damo/speech_paraformer-large_asr_nat-zh-cn-16k-common-vocab8404-pytorch vad_model:damo/speech_fsmn_vad_zh-cn-16k-common-pytorch punc_model:''

Demo目录:funasr/runtime/python/grpc

Command:同时执行 grpc_main_client_mic.py和grpc_main_client.py

问题描述: 并发执行asr_vad_pnuc 和单独执行vad,都会报错,单线程执行任何一个脚本都没有问题 [后述]。 为了还原同时录音的场景,对grpc_main_client_mac.py做了简单变更,把一次上传一个文件改成截断上传,每480ms一个包 在最后我贴了修改后的脚本 Error log:

user: project1_user1 , delay(ms): 282, text: 哎世界 
2023-05-12 20:49:19,406 - modelscope - INFO - Decoding with pcm files ...
2023-05-12 20:49:19,406 (asr_inference_pipeline:507) INFO: Decoding with pcm files ...
2023-05-12 20:49:19,646 - modelscope - INFO - Decoding with pcm files ...
2023-05-12 20:49:19,646 (asr_inference_pipeline:507) INFO: Decoding with pcm files ...
2023-05-12 20:49:19,651 - modelscope - INFO - Computing the result of ASR ...
2023-05-12 20:49:19,651 (asr_inference_pipeline:542) INFO: Computing the result of ASR ...
user: project1_user1 , delay(ms): 245, text: 可以呀 
user: project1_user1 , delay(ms): 0, info: waiting_for_more_voice 
2023-05-12 20:49:19,901 - modelscope - INFO - Computing the result of ASR ...
2023-05-12 20:49:19,901 (asr_inference_pipeline:542) INFO: Computing the result of ASR ...
user: project1_user1 , delay(ms): 256, text: 愿当中 
2023-05-12 20:49:20,389 - modelscope - INFO - Decoding with pcm files ...
2023-05-12 20:49:20,389 (asr_inference_pipeline:507) INFO: Decoding with pcm files ...
2023-05-12 20:49:20,701 - modelscope - INFO - Computing the result of ASR ...
2023-05-12 20:49:20,701 (asr_inference_pipeline:542) INFO: Computing the result of ASR ...
user: project1_user1 , delay(ms): 313, text: 中的两位 
2023-05-12 20:49:20,879 - modelscope - INFO - Decoding with pcm files ...
2023-05-12 20:49:20,879 (asr_inference_pipeline:507) INFO: Decoding with pcm files ...
2023-05-12 20:49:21,137 - modelscope - INFO - Computing the result of ASR ...
2023-05-12 20:49:21,137 (asr_inference_pipeline:542) INFO: Computing the result of ASR ...
user: project1_user1 , delay(ms): 258, text: 嗯 
2023-05-12 20:49:21,188 - modelscope - INFO - Decoding with pcm files ...
2023-05-12 20:49:21,188 (asr_inference_pipeline:507) INFO: Decoding with pcm files ...
2023-05-12 20:49:21,429 - modelscope - INFO - Computing the result of ASR ...
2023-05-12 20:49:21,429 (asr_inference_pipeline:542) INFO: Computing the result of ASR ...
user: project1_user1 , delay(ms): 242, text: 对李仪祥 
2023-05-12 20:49:21,915 - modelscope - INFO - Decoding with pcm files ...
2023-05-12 20:49:21,915 (asr_inference_pipeline:507) INFO: Decoding with pcm files ...
2023-05-12 20:49:22,171 - modelscope - INFO - Computing the result of ASR ...
2023-05-12 20:49:22,171 (asr_inference_pipeline:542) INFO: Computing the result of ASR ...
user: project1_user1 , delay(ms): 257, text: 小姐姐 
2023-05-12 20:49:22,654 - modelscope - INFO - Decoding with pcm files ...
2023-05-12 20:49:22,654 (asr_inference_pipeline:507) INFO: Decoding with pcm files ...
2023-05-12 20:49:22,955 - modelscope - INFO - Computing the result of ASR ...
2023-05-12 20:49:22,955 (asr_inference_pipeline:542) INFO: Computing the result of ASR ...
user: project1_user1 , delay(ms): 301, text: 点一 
2023-05-12 20:49:23,221 - modelscope - INFO - Decoding with pcm files ...
2023-05-12 20:49:23,221 (asr_inference_pipeline:507) INFO: Decoding with pcm files ...
2023-05-12 20:49:23,442 - modelscope - INFO - Decoding with pcm files ...
2023-05-12 20:49:23,442 (asr_inference_pipeline:507) INFO: Decoding with pcm files ...
2023-05-12 20:49:23,490 - modelscope - INFO - Computing the result of ASR ...
2023-05-12 20:49:23,490 (asr_inference_pipeline:542) INFO: Computing the result of ASR ...
user: project1_user1 , delay(ms): 270, text: 状态 
2023-05-12 20:49:23,730 - modelscope - INFO - Computing the result of ASR ...
2023-05-12 20:49:23,730 (asr_inference_pipeline:542) INFO: Computing the result of ASR ...
user: project1_user1 , delay(ms): 289, text: 也是刚刚 
user: project1_user1 , delay(ms): 1, info: waiting_for_more_voice 
user: project1_user1 , delay(ms): 1, info: waiting_for_more_voice 
2023-05-12 20:49:24,217 - modelscope - INFO - Decoding with pcm files ...
2023-05-12 20:49:24,217 (asr_inference_pipeline:507) INFO: Decoding with pcm files ...
user: project1_user1 , delay(ms): 0, info: waiting_for_more_voice 
2023-05-12 20:49:24,521 - modelscope - INFO - Computing the result of ASR ...
2023-05-12 20:49:24,521 (asr_inference_pipeline:542) INFO: Computing the result of ASR ...
user: project1_user1 , delay(ms): 305, text: 刚踏入 
user: project1_user1 , delay(ms): 1, info: waiting_for_more_voice 
user: project1_user1 , delay(ms): 0, info: waiting_for_more_voice 
user: project1_user1 , delay(ms): 0, info: waiting_for_more_voice 
user: project1_user1 , delay(ms): 0, info: waiting_for_more_voice 
2023-05-12 20:49:25,495 - modelscope - INFO - Decoding with pcm files ...
2023-05-12 20:49:25,495 (asr_inference_pipeline:507) INFO: Decoding with pcm files ...
2023-05-12 20:49:25,762 - modelscope - INFO - Computing the result of ASR ...
2023-05-12 20:49:25,762 (asr_inference_pipeline:542) INFO: Computing the result of ASR ...
user: project1_user1 , delay(ms): 268, text: 年轻人 
2023-05-12 20:49:26,245 - modelscope - INFO - Decoding with pcm files ...
2023-05-12 20:49:26,245 (asr_inference_pipeline:507) INFO: Decoding with pcm files ...
user: project1_user1 , delay(ms): 0, info: waiting_for_more_voice 
2023-05-12 20:49:26,558 - modelscope - INFO - Computing the result of ASR ...
2023-05-12 20:49:26,558 (asr_inference_pipeline:542) INFO: Computing the result of ASR ...
user: project1_user1 , delay(ms): 314, text: 嗯特步 
user: project1_user1 , delay(ms): 0, info: waiting_for_more_voice 
2023-05-12 20:49:27,044 - modelscope - INFO - Decoding with pcm files ...
2023-05-12 20:49:27,044 (asr_inference_pipeline:507) INFO: Decoding with pcm files ...
2023-05-12 20:49:27,293 - modelscope - INFO - Computing the result of ASR ...
2023-05-12 20:49:27,293 (asr_inference_pipeline:542) INFO: Computing the result of ASR ...
user: project1_user1 , delay(ms): 251, text: 不可以求 
user: project1_user1 , delay(ms): 0, info: waiting_for_more_voice 
2023-05-12 20:49:27,781 - modelscope - INFO - Decoding with pcm files ...
2023-05-12 20:49:27,781 (asr_inference_pipeline:507) INFO: Decoding with pcm files ...
2023-05-12 20:49:28,037 - modelscope - INFO - Computing the result of ASR ...
2023-05-12 20:49:28,037 (asr_inference_pipeline:542) INFO: Computing the result of ASR ...
user: project1_user1 , delay(ms): 257, text: 请大家给 
user: project1_user1 , delay(ms): 1, info: waiting_for_more_voice 
2023-05-12 20:49:28,523 - modelscope - INFO - Decoding with pcm files ...
2023-05-12 20:49:28,523 (asr_inference_pipeline:507) INFO: Decoding with pcm files ...
user: project1_user1 , delay(ms): 1, info: waiting_for_more_voice 
2023-05-12 20:49:28,782 - modelscope - INFO - Computing the result of ASR ...
2023-05-12 20:49:28,782 (asr_inference_pipeline:542) INFO: Computing the result of ASR ...
user: project1_user1 , delay(ms): 260, text: 给他们多 
2023-05-12 20:49:29,270 - modelscope - INFO - Decoding with pcm files ...
2023-05-12 20:49:29,270 (asr_inference_pipeline:507) INFO: Decoding with pcm files ...
2023-05-12 20:49:29,574 - modelscope - INFO - Computing the result of ASR ...
2023-05-12 20:49:29,574 (asr_inference_pipeline:542) INFO: Computing the result of ASR ...
user: project1_user1 , delay(ms): 306, text: 可不可以不点宽 
2023-05-12 20:49:30,072 - modelscope - INFO - Decoding with pcm files ...
2023-05-12 20:49:30,072 (asr_inference_pipeline:507) INFO: Decoding with pcm files ...
2023-05-12 20:49:30,076 - modelscope - INFO - Decoding with pcm files ...
2023-05-12 20:49:30,076 (asr_inference_pipeline:507) INFO: Decoding with pcm files ...
warning
Something wrong with the VAD algorithm
warning
Something wrong with the VAD algorithm
warning
Something wrong with the VAD algorithm
warning
Something wrong with the VAD algorithm
warning
Something wrong with the VAD algorithm
warning
Something wrong with the VAD algorithm
warning
Something wrong with the VAD algorithm
warning
Something wrong with the VAD algorithm
warning
Something wrong with the VAD algorithm
warning
Something wrong with the VAD algorithm
warning
Something wrong with the VAD algorithm
warning
Something wrong with the VAD algorithm
warning
Something wrong with the VAD algorithm
warning
Something wrong with the VAD algorithm
warning
Something wrong with the VAD algorithm
warning
Something wrong with the VAD algorithm
warning
Something wrong with the VAD algorithm
warning
Something wrong with the VAD algorithm
warning
Something wrong with the VAD algorithm
warning
Something wrong with the VAD algorithm
warning
Something wrong with the VAD algorithm
warning
Something wrong with the VAD algorithm
warning
Something wrong with the VAD algorithm
warning
Something wrong with the VAD algorithm
warning
Something wrong with the VAD algorithm
warning
Something wrong with the VAD algorithm
warning
Something wrong with the VAD algorithm
warning
Something wrong with the VAD algorithm
warning
Something wrong with the VAD algorithm
warning
Something wrong with the VAD algorithm
warning
Something wrong with the VAD algorithm
warning
Something wrong with the VAD algorithm
warning
Something wrong with the VAD algorithm
warning
Something wrong with the VAD algorithm
warning
Something wrong with the VAD algorithm
2023-05-12 20:49:30,108 (_server:528) ERROR: Exception iterating responses: list index out of range
Traceback (most recent call last):
  File "/Users/hailong/Develop/miniconda3/envs/modelscope37/lib/python3.7/site-packages/grpc/_server.py", line 518, in _take_response_from_response_iterator
    return next(response_iterator), True
  File "/Users/hailong/Source/work/FunASR/funasr/runtime/python/grpc/grpc_server.py", line 106, in Recognize
    asr_result = self.inference_16k_pipeline(audio_in=tmp_data, audio_fs = self.sample_rate)
  File "/Users/hailong/Develop/miniconda3/envs/modelscope37/lib/python3.7/site-packages/modelscope/pipelines/audio/asr_inference_pipeline.py", line 258, in __call__
    output = self.forward(output, **kwargs)
  File "/Users/hailong/Develop/miniconda3/envs/modelscope37/lib/python3.7/site-packages/modelscope/pipelines/audio/asr_inference_pipeline.py", line 533, in forward
    inputs['asr_result'] = self.run_inference(self.cmd, **kwargs)
  File "/Users/hailong/Develop/miniconda3/envs/modelscope37/lib/python3.7/site-packages/modelscope/pipelines/audio/asr_inference_pipeline.py", line 612, in run_inference
    cmd['fs'], cmd['param_dict'], **kwargs)
  File "/Users/hailong/Source/work/FunASR/funasr/bin/asr_inference_paraformer_vad.py", line 286, in _forward
    vad_results = speech2vadsegment(**batch)
  File "/Users/hailong/Develop/miniconda3/envs/modelscope37/lib/python3.7/site-packages/torch/autograd/grad_mode.py", line 27, in decorate_context
    return func(*args, **kwargs)
  File "/Users/hailong/Source/work/FunASR/funasr/bin/vad_inference.py", line 135, in __call__
    segments_part, in_cache = self.vad_model(**batch)
  File "/Users/hailong/Develop/miniconda3/envs/modelscope37/lib/python3.7/site-packages/torch/nn/modules/module.py", line 1194, in _call_impl
    return forward_call(*input, **kwargs)
  File "/Users/hailong/Source/work/FunASR/funasr/models/e2e_vad.py", line 482, in forward
    self.DetectLastFrames()
  File "/Users/hailong/Source/work/FunASR/funasr/models/e2e_vad.py", line 554, in DetectLastFrames
    frame_state = self.GetFrameState(self.frm_cnt - 1 - i)
  File "/Users/hailong/Source/work/FunASR/funasr/models/e2e_vad.py", line 431, in GetFrameState
    cur_decibel = self.decibel[t]
IndexError: list index out of range
2023-05-12 20:49:30,345 - modelscope - INFO - Computing the result of ASR ...
2023-05-12 20:49:30,345 (asr_inference_pipeline:542) INFO: Computing the result of ASR ...
user: project1_user1 , delay(ms): 274, text: 我首先 
2023-05-12 20:49:31,098 - modelscope - INFO - Decoding with pcm files ...
2023-05-12 20:49:31,098 (asr_inference_pipeline:507) INFO: Decoding with pcm files ...
2023-05-12 20:49:31,334 - modelscope - INFO - Computing the result of ASR ...
2023-05-12 20:49:31,334 (asr_inference_pipeline:542) INFO: Computing the result of ASR ...
user: project1_user1 , delay(ms): 236, text: 唱的好听吗 
user: project1_user1 , delay(ms): 1, info: waiting_for_more_voice 
user: project1_user1 , delay(ms): 0, info: waiting_for_more_voice 
2023-05-12 20:49:39,958 - modelscope - INFO - Decoding with pcm files ...
2023-05-12 20:49:39,958 (asr_inference_pipeline:507) INFO: Decoding with pcm files ...
2023-05-12 20:49:39,970 - modelscope - INFO - Computing the result of ASR ...
2023-05-12 20:49:39,970 (asr_inference_pipeline:542) INFO: Computing the result of ASR ...
user: project1_user1 , delay(ms): 13, text:  
user: project1_user1 , delay(ms): 0, info: waiting_for_more_voice 
user: project1_user1 , delay(ms): 1, info: waiting_for_more_voice 
user: project1_user1 , delay(ms): 0, info: waiting_for_more_voice 
2023-05-12 20:49:42,761 - modelscope - INFO - Decoding with pcm files ...
2023-05-12 20:49:42,761 (asr_inference_pipeline:507) INFO: Decoding with pcm files ...
2023-05-12 20:49:42,774 - modelscope - INFO - Computing the result of ASR ...
2023-05-12 20:49:42,774 (asr_inference_pipeline:542) INFO: Computing the result of ASR ...
user: project1_user1 , delay(ms): 13, text:  
user: project1_user1 , delay(ms): 0, info: waiting_for_more_voice 
user: project1_user1 , delay(ms): 0, info: waiting_for_more_voice 
user: project1_user1 , delay(ms): 0, info: waiting_for_more_voice 
user: project1_user1 , delay(ms): 0, info: waiting_for_more_voice 
user: project1_user1 , delay(ms): 1, info: waiting_for_more_voice 
2023-05-12 20:49:48,724 - modelscope - INFO - Decoding with pcm files ...
2023-05-12 20:49:48,724 (asr_inference_pipeline:507) INFO: Decoding with pcm files ...
2023-05-12 20:49:48,743 - modelscope - INFO - Computing the result of ASR ...
2023-05-12 20:49:48,743 (asr_inference_pipeline:542) INFO: Computing the result of ASR ...
user: project1_user1 , delay(ms): 19, text:  
user: project1_user1 , delay(ms): 1, info: waiting_for_more_voice 
user: project1_user1 , delay(ms): 0, info: waiting_for_more_voice 
2023-05-12 20:49:51,124 - modelscope - INFO - Decoding with pcm files ...
2023-05-12 20:49:51,124 (asr_inference_pipeline:507) INFO: Decoding with pcm files ...
2023-05-12 20:49:51,139 - modelscope - INFO - Computing the result of ASR ...
2023-05-12 20:49:51,139 (asr_inference_pipeline:542) INFO: Computing the result of ASR ...
user: project1_user1 , delay(ms): 16, text:  
user: project1_user1 , delay(ms): 0, info: waiting_for_more_voice 
user: project1_user1 , delay(ms): 0, info: waiting_for_more_voice 
user: project1_user1 , delay(ms): 0, info: waiting_for_more_voice 
user: project1_user1 , delay(ms): 0, info: waiting_for_more_voice 
user: project1_user1 , delay(ms): 1, info: waiting_for_more_voice 
user: project1_user1 , delay(ms): 0, info: waiting_for_more_voice 
user: project1_user1 , delay(ms): 1, info: waiting_for_more_voice 
user: project1_user1 , delay(ms): 1, info: waiting_for_more_voice 
user: project1_user1 , delay(ms): 0, info: waiting_for_more_voice 
user: project1_user1 , delay(ms): 0, info: waiting_for_more_voice 
user: project1_user1 , delay(ms): 0, info: waiting_for_more_voice 
user: project1_user1 , delay(ms): 0, info: waiting_for_more_voice 
user: project1_user1 , delay(ms): 1, info: waiting_for_more_voice 
user: project1_user1 , delay(ms): 0, info: waiting_for_more_voice 
user: project1_user1 , delay(ms): 0, info: waiting_for_more_voice 
user: project1_user1 , delay(ms): 0, info: waiting_for_more_voice 
user: project1_user1 , delay(ms): 1, info: waiting_for_more_voice 
user: project1_user1 , delay(ms): 0, info: waiting_for_more_voice 
user: project1_user1 , delay(ms): 0, info: waiting_for_more_voice 
2023-05-12 20:50:05,955 - modelscope - INFO - Decoding with pcm files ...
2023-05-12 20:50:05,955 (asr_inference_pipeline:507) INFO: Decoding with pcm files ...
2023-05-12 20:50:05,969 - modelscope - INFO - Computing the result of ASR ...
2023-05-12 20:50:05,969 (asr_inference_pipeline:542) INFO: Computing the result of ASR ...
user: project1_user1 , delay(ms): 15, text:  
user: project1_user1 , delay(ms): 1, info: waiting_for_more_voice 
user: project1_user1 , delay(ms): 0, info: waiting_for_more_voice 
2023-05-12 20:50:07,137 - modelscope - INFO - Decoding with pcm files ...
2023-05-12 20:50:07,137 (asr_inference_pipeline:507) INFO: Decoding with pcm files ...
2023-05-12 20:50:07,149 - modelscope - INFO - Computing the result of ASR ...
2023-05-12 20:50:07,149 (asr_inference_pipeline:542) INFO: Computing the result of ASR ...
user: project1_user1 , delay(ms): 13, text:  
user: project1_user1 , delay(ms): 0, info: waiting_for_more_voice 
user: project1_user1 , delay(ms): 1, info: waiting_for_more_voice 
2023-05-12 20:50:10,145 - modelscope - INFO - Decoding with pcm files ...
2023-05-12 20:50:10,145 (asr_inference_pipeline:507) INFO: Decoding with pcm files ...
2023-05-12 20:50:10,160 - modelscope - INFO - Computing the result of ASR ...
2023-05-12 20:50:10,160 (asr_inference_pipeline:542) INFO: Computing the result of ASR ...
user: project1_user1 , delay(ms): 15, text:  
2023-05-12 20:50:10,753 - modelscope - INFO - Decoding with pcm files ...
2023-05-12 20:50:10,753 (asr_inference_pipeline:507) INFO: Decoding with pcm files ...
2023-05-12 20:50:10,768 - modelscope - INFO - Computing the result of ASR ...
2023-05-12 20:50:10,768 (asr_inference_pipeline:542) INFO: Computing the result of ASR ...
user: project1_user1 , delay(ms): 16, text:  
user: project1_user1 , delay(ms): 0, info: waiting_for_more_voice 
user: project1_user1 , delay(ms): 0, info: waiting_for_more_voice 
user: project1_user1 , delay(ms): 0, info: waiting_for_more_voice 
2023-05-12 20:50:14,475 - modelscope - INFO - Decoding with pcm files ...
2023-05-12 20:50:14,475 (asr_inference_pipeline:507) INFO: Decoding with pcm files ...
2023-05-12 20:50:14,489 - modelscope - INFO - Computing the result of ASR ...
2023-05-12 20:50:14,489 (asr_inference_pipeline:542) INFO: Computing the result of ASR ...
user: project1_user1 , delay(ms): 15, text:  
user: project1_user1 , delay(ms): 0, info: waiting_for_more_voice 
user: project1_user1 , delay(ms): 0, info: waiting_for_more_voice 
user: project1_user1 , delay(ms): 0, info: waiting_for_more_voice 
user: project1_user1 , delay(ms): 0, info: waiting_for_more_voice 
user: project1_user1 , delay(ms): 0, info: waiting_for_more_voice 
2023-05-12 20:50:19,603 - modelscope - INFO - Decoding with pcm files ...
2023-05-12 20:50:19,603 (asr_inference_pipeline:507) INFO: Decoding with pcm files ...
2023-05-12 20:50:19,617 - modelscope - INFO - Computing the result of ASR ...
2023-05-12 20:50:19,617 (asr_inference_pipeline:542) INFO: Computing the result of ASR ...
user: project1_user1 , delay(ms): 15, text:  
2023-05-12 20:50:20,345 - modelscope - INFO - Decoding with pcm files ...
2023-05-12 20:50:20,345 (asr_inference_pipeline:507) INFO: Decoding with pcm files ...
2023-05-12 20:50:20,360 - modelscope - INFO - Computing the result of ASR ...
2023-05-12 20:50:20,360 (asr_inference_pipeline:542) INFO: Computing the result of ASR ...
user: project1_user1 , delay(ms): 16, text:  
user: project1_user1 , delay(ms): 0, info: waiting_for_more_voice 
2023-05-12 20:50:21,874 - modelscope - INFO - Decoding with pcm files ...
2023-05-12 20:50:21,874 (asr_inference_pipeline:507) INFO: Decoding with pcm files ...
2023-05-12 20:50:21,888 - modelscope - INFO - Computing the result of ASR ...
2023-05-12 20:50:21,888 (asr_inference_pipeline:542) INFO: Computing the result of ASR ...
user: project1_user1 , delay(ms): 15, text:  
2023-05-12 20:50:22,442 - modelscope - INFO - Decoding with pcm files ...
2023-05-12 20:50:22,442 (asr_inference_pipeline:507) INFO: Decoding with pcm files ...
2023-05-12 20:50:22,456 - modelscope - INFO - Computing the result of ASR ...
2023-05-12 20:50:22,456 (asr_inference_pipeline:542) INFO: Computing the result of ASR ...
user: project1_user1 , delay(ms): 15, text:  
2023-05-12 20:50:23,054 - modelscope - INFO - Decoding with pcm files ...
2023-05-12 20:50:23,054 (asr_inference_pipeline:507) INFO: Decoding with pcm files ...
2023-05-12 20:50:23,079 - modelscope - INFO - Computing the result of ASR ...
2023-05-12 20:50:23,079 (asr_inference_pipeline:542) INFO: Computing the result of ASR ...
user: project1_user1 , delay(ms): 26, text:  
user: project1_user1 , delay(ms): 0, info: waiting_for_more_voice 
user: project1_user1 , delay(ms): 0, info: waiting_for_more_voice 
user: project1_user1 , delay(ms): 0, info: waiting_for_more_voice 
user: project1_user1 , delay(ms): 0, info: waiting_for_more_voice 
2023-05-12 20:50:27,430 - modelscope - INFO - Decoding with pcm files ...
2023-05-12 20:50:27,430 (asr_inference_pipeline:507) INFO: Decoding with pcm files ...
2023-05-12 20:50:27,445 - modelscope - INFO - Computing the result of ASR ...
2023-05-12 20:50:27,445 (asr_inference_pipeline:542) INFO: Computing the result of ASR ...
user: project1_user1 , delay(ms): 15, text:  
user: project1_user1 , delay(ms): 1, info: waiting_for_more_voice 
user: project1_user1 , delay(ms): 0, info: waiting_for_more_voice 
user: project1_user1 , delay(ms): 1, info: waiting_for_more_voice 
user: project1_user1 , delay(ms): 0, info: waiting_for_more_voice 
user: project1_user1 , delay(ms): 0, info: waiting_for_more_voice 
user: project1_user1 , delay(ms): 1, info: waiting_for_more_voice 
2023-05-12 20:50:32,683 - modelscope - INFO - Decoding with pcm files ...
2023-05-12 20:50:32,683 (asr_inference_pipeline:507) INFO: Decoding with pcm files ...
2023-05-12 20:50:32,697 - modelscope - INFO - Computing the result of ASR ...
2023-05-12 20:50:32,697 (asr_inference_pipeline:542) INFO: Computing the result of ASR ...
user: project1_user1 , delay(ms): 14, text:  
2023-05-12 20:50:33,511 - modelscope - INFO - Decoding with pcm files ...
2023-05-12 20:50:33,511 (asr_inference_pipeline:507) INFO: Decoding with pcm files ...
2023-05-12 20:50:33,529 - modelscope - INFO - Computing the result of ASR ...
2023-05-12 20:50:33,529 (asr_inference_pipeline:542) INFO: Computing the result of ASR ...
user: project1_user1 , delay(ms): 19, text:  
user: project1_user1 , delay(ms): 0, info: waiting_for_more_voice 
user: project1_user1 , delay(ms): 1, info: waiting_for_more_voice 
user: project1_user1 , delay(ms): 0, info: waiting_for_more_voice 
user: project1_user1 , delay(ms): 0, info: waiting_for_more_voice 
user: project1_user1 , delay(ms): 1, info: waiting_for_more_voice 
user: project1_user1 , delay(ms): 0, info: waiting_for_more_voice 
2023-05-12 20:50:39,450 - modelscope - INFO - Decoding with pcm files ...
2023-05-12 20:50:39,450 (asr_inference_pipeline:507) INFO: Decoding with pcm files ...
2023-05-12 20:50:39,468 - modelscope - INFO - Computing the result of ASR ...
2023-05-12 20:50:39,468 (asr_inference_pipeline:542) INFO: Computing the result of ASR ...
user: project1_user1 , delay(ms): 18, text:  
user: project1_user1 , delay(ms): 0, info: waiting_for_more_voice 
user: project1_user1 , delay(ms): 0, info: waiting_for_more_voice 
user: project1_user1 , delay(ms): 1, info: waiting_for_more_voice 
user: project1_user1 , delay(ms): 0, info: waiting_for_more_voice 
2023-05-12 20:50:42,395 - modelscope - INFO - Decoding with pcm files ...
2023-05-12 20:50:42,395 (asr_inference_pipeline:507) INFO: Decoding with pcm files ...
2023-05-12 20:50:42,409 - modelscope - INFO - Computing the result of ASR ...
2023-05-12 20:50:42,409 (asr_inference_pipeline:542) INFO: Computing the result of ASR ...
user: project1_user1 , delay(ms): 14, text:  
2023-05-12 20:50:43,545 - modelscope - INFO - Decoding with pcm files ...
2023-05-12 20:50:43,545 (asr_inference_pipeline:507) INFO: Decoding with pcm files ...
2023-05-12 20:50:43,572 - modelscope - INFO - Computing the result of ASR ...
2023-05-12 20:50:43,572 (asr_inference_pipeline:542) INFO: Computing the result of ASR ...
user: project1_user1 , delay(ms): 28, text:  
user: project1_user1 , delay(ms): 0, info: waiting_for_more_voice 
user: project1_user1 , delay(ms): 0, info: waiting_for_more_voice 
user: project1_user1 , delay(ms): 0, info: waiting_for_more_voice 
user: project1_user1 , delay(ms): 0, info: waiting_for_more_voice 
user: project1_user1 , delay(ms): 0, info: waiting_for_more_voice 
user: project1_user1 , delay(ms): 0, info: waiting_for_more_voice 
fatmop commented 1 year ago
import grpc
import json
import time
import asyncio
import soundfile as sf
import argparse

from grpc_client import transcribe_audio_bytes
from paraformer_pb2_grpc import ASRStub

# send the audio data once
async def grpc_rec(wav_scp, grpc_uri, asr_user, language):
    with grpc.insecure_channel(grpc_uri) as channel:
        stub = ASRStub(channel)
        for line in wav_scp:
            wav_file = line.split()[1]
            wav, _ = sf.read(wav_file, dtype='int16')
            speech_length = wav.shape[0]

            sample_offset = 0
            chunk_size = [8, 8, 4]  # [5, 10, 5] 600ms, [8, 8, 4] 480ms
            stride_size = chunk_size[1] * 960
            for sample_offset in range(0, speech_length, min(stride_size, speech_length - sample_offset)):
                if sample_offset + stride_size >= speech_length - 1:
                    stride_size = speech_length - sample_offset

                b = time.time()
                response = transcribe_audio_bytes(stub, wav[sample_offset: sample_offset + stride_size].tobytes(), user=asr_user, language=language, speaking=True, isEnd=False)
                response = transcribe_audio_bytes(stub, None,
                                                  user=asr_user, language=language, speaking=False, isEnd=False)

                resp = response.next()
                text = ''
                if 'decoding' == resp.action:
                    resp = response.next()
                    if 'finish' == resp.action:
                        text = json.loads(resp.sentence)['text']

                        res= {'text': text, 'time': time.time() - b}
                        print(res)
                time.sleep(0.48)
        response = transcribe_audio_bytes(stub, None, user=asr_user, language=language, speaking=False, isEnd=True)

async def test(args):
    wav_scp = open(args.wav_scp, "r").readlines()
    uri = '{}:{}'.format(args.host, args.port)
    res = await grpc_rec(wav_scp, uri, args.user_allowed, language = 'zh-CN')

if __name__ == '__main__':
    parser = argparse.ArgumentParser()
    parser.add_argument("--host",
                        type=str,
                        default="127.0.0.1",
                        required=False,
                        help="grpc server host ip")
    parser.add_argument("--port",
                        type=int,
                        default=10108,
                        required=False,
                        help="grpc server port")              
    parser.add_argument("--user_allowed",
                        type=str,
                        default="project1_user1",
                        help="allowed user for grpc client")
    parser.add_argument("--sample_rate",
                        type=int,
                        default=16000,
                        help="audio sample_rate from client") 
    parser.add_argument("--wav_scp",
                        type=str,
                        required=True,
                        help="audio wav scp")                    
    args = parser.parse_args()

    asyncio.run(test(args))
onfireAI commented 10 months ago

遇到了同样的错误

PangziZhang523 commented 6 months ago

也遇到了Something wrong with the VAD algorithm,有什么解决办法吗?

icowan commented 5 months ago

遇到了同样的问题

Tongjilibo commented 4 months ago

+1

wuhongsheng commented 4 months ago

+1

Nancis1130 commented 2 months ago

解决了吗?