Views
No views yet
model.pth: PyTorch model weightsconfig.yaml: Model configurationhotwords.txt:hotwords list1 python>=3.8
2 torch>=1.13
3 torchaudio1 git clone https://github.com/alibaba/FunASR.git && cd FunASR
2 pip3 install -e ./
3 pip install huggingface huggingface_hub1import torch
2from funasr import AutoModel
3
4# 下载模型
5from huggingface_hub import snapshot_download
6snapshot_download(repo_id="JoeyPilgrim/paraformer_sc_kws", local_dir="your_model_path")
7
8# 加载热词
9with open("your_model_path/hotwords.txt", "r") as f:
10 hotwords = " ".join([word.strip() for word in f.readlines()])
11# 加载模型
12model = AutoModel(model="your_model_path")
13
14result = model.generate(input="your_audio.wav", hotword=hotwords)
15if result[0]["text"] in hotwords:
16 print(result)
17else:
18 print("")