Notice: In order to resolve issues more efficiently, please raise issue following the template.
(注意:为了更加高效率解决您遇到的问题,请按照模板提问,补充细节)
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
Notice: In order to resolve issues more efficiently, please raise issue following the template.
(注意:为了更加高效率解决您遇到的问题,请按照模板提问,补充细节)
❓ Questions and Help
报错信息:
Before asking:
What is your question?
Code
What have you tried?
What's your environment?
pip, source):