FunASR
FunASR copied to clipboard
TypeError: unsupported operand type(s) for /: 'list' and 'int'
Notice: In order to resolve issues more efficiently, please raise issue following the template. (注意:为了更加高效率解决您遇到的问题,请按照模板提问,补充细节)
🐛 Bug
使用这段代码执行:
import os
import soundfile
from funasr import AutoModel
model_name = "paraformer-zh-streaming"
model = AutoModel(model=model_name, model_revision="v2.0.4",
vad_model="fsmn-vad", vad_model_revision="v2.0.4",
punc_model="ct-punc-c", punc_model_revision="v2.0.4",
# spk_model="cam++", spk_model_revision="v2.0.2",
)
chunk_size = [0, 10, 5] # [0, 10, 5] 600ms, [0, 8, 4] 480ms
encoder_chunk_look_back = 4 # number of chunks to lookback for encoder self-attention
decoder_chunk_look_back = 1 # number of encoder chunks to lookback for decoder cross-attention
wav_file = "test-long.wav"
speech, sample_rate = soundfile.read(wav_file)
chunk_stride = chunk_size[1] * 960 # 600ms
cache = {}
total_chunk_num = int(len((speech) - 1) / chunk_stride + 1)
for i in range(total_chunk_num):
speech_chunk = speech[i * chunk_stride:(i + 1) * chunk_stride]
is_final = i == total_chunk_num - 1
res = model.generate(input=speech_chunk, cache=cache, is_final=is_final, chunk_size=chunk_size,
encoder_chunk_look_back=encoder_chunk_look_back,
decoder_chunk_look_back=decoder_chunk_look_back)
print(res)
抛出异常:
File "D:\workspace\python\python-test\venv\lib\site-packages\funasr\auto\auto_model.py", line 259, in inference res = model.inference(**batch, **kwargs) File "D:\workspace\python\python-test\venv\lib\site-packages\funasr\models\fsmn_vad_streaming\model.py", line 580, in inference chunk_stride_samples = int(chunk_size * frontend.fs / 1000) TypeError: unsupported operand type(s) for /: 'list' and 'int' python-BaseException 0%| | 0/1 [00:01<?, ?it/s]
Environment
- OS (e.g., Linux):windows
- FunASR Version (e.g., 1.0.0):1.0.20
- ModelScope Version (e.g., 1.11.0): 1.13.3
- PyTorch Version (e.g., 2.0.0): 2.2.2+cu118
- How you installed funasr (
pip, source):pip - Python version:3.9
- GPU (e.g., V100M32):4090移动版
- CUDA/cuDNN version (e.g., cuda11.7):11.8
- Docker version (e.g., funasr-runtime-sdk-cpu-0.4.1) none
- Any other relevant information:
Additional context
VAD is used for non-streaming model.