FunASR
FunASR copied to clipboard
VAD检测,不支持非16K采样的音频吗?
Notice: In order to resolve issues more efficiently, please raise issue following the template. (注意:为了更加高效率解决您遇到的问题,请按照模板提问,补充细节)
❓ Questions and Help
import logging, os, tqdm
# 1. 让 ModelScope 闭嘴
logging.getLogger("modelscope").setLevel(logging.ERROR)
# 2. 把 tqdm 全局屏蔽(funasr 里调的就是它)
tqdm.tqdm = lambda *_, **__: iter(_)
from funasr import AutoModel
chunk_size = 200 # ms
model = AutoModel(model="fsmn-vad", model_revision="v2.0.4",disable_update=True,disable_log=True)
import soundfile
wav_file = "./data/testvad_v1.wav"
speech, sample_rate = soundfile.read(wav_file)
chunk_stride = int(chunk_size * sample_rate / 1000)
print(len(speech), sample_rate)
cache = {}
total_chunk_num = int(len((speech)-1)/chunk_stride+1)
#print(f"total_chunk_num is {total_chunk_num},{chunk_size},chunk_stride is {chunk_stride}")
for i in range(total_chunk_num):
speech_chunk = speech[i*chunk_stride:(i+1)*chunk_stride]
is_final = i == total_chunk_num - 1
if speech_chunk is None:
print(i)
continue
#print(f"speech_chunk is {len(speech_chunk)}")
try:
res = model.generate(input=speech_chunk, cache=cache, is_final=is_final, chunk_size=chunk_size)
if len(res[0]["value"]):
print(res)
except Exception as e:
print(f'error is {e}')
continue
报错信息:
620544 48000
error is 'NoneType' object is not subscriptable
error is 'NoneType' object is not subscriptable
error is 'NoneType' object is not subscriptable
error is 'NoneType' object is not subscriptable
error is 'NoneType' object is not subscriptable
error is 'NoneType' object is not subscriptable
error is 'NoneType' object is not subscriptable
error is 'NoneType' object is not subscriptable
error is 'NoneType' object is not subscriptable
error is 'NoneType' object is not subscriptable
error is 'NoneType' object is not subscriptable
Before asking:
- search the issues.
- search the docs.
What is your question?
Code
What have you tried?
What's your environment?
- OS (e.g., Linux):
- FunASR Version (e.g., 1.0.0): 1.2.7
- ModelScope Version (e.g., 1.11.0):
- PyTorch Version (e.g., 2.0.0):
- How you installed funasr (
pip, source): - Python version:
- GPU (e.g., V100M32)
- CUDA/cuDNN version (e.g., cuda11.7):
- Docker version (e.g., funasr-runtime-sdk-cpu-0.4.1)
- Any other relevant information: