维石
2024-06-03 509d09f50d4ed73cec79e6a73de8bf30ab798e8c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
from funasr_torch import Paraformer
from pathlib import Path
 
 
model_dir = (
    "iic/speech_paraformer-large_asr_nat-zh-cn-16k-common-vocab8404-pytorch"
)
 
model = Paraformer(model_dir, batch_size=1)  # cpu
# model = Paraformer(model_dir, batch_size=1, device_id=0)  # gpu
 
# when using paraformer-large-vad-punc model, you can set plot_timestamp_to="./xx.png" to get figure of alignment besides timestamps
# model = Paraformer(model_dir, batch_size=1, plot_timestamp_to="test.png")
 
wav_path = "{}/.cache/modelscope/hub/{}/example/asr_example.wav".format(Path.home(), model_dir)
 
result = model(wav_path)
print(result)