demo_paraformer_offline.py 679 B

1234567891011121314
  1. from funasr_onnx import Paraformer
  2. from pathlib import Path
  3. model_dir = "damo/speech_paraformer-large_asr_nat-zh-cn-16k-common-vocab8404-pytorch"
  4. model = Paraformer(model_dir, batch_size=1, quantize=True)
  5. # model = Paraformer(model_dir, batch_size=1, device_id=0) # gpu
  6. # when using paraformer-large-vad-punc model, you can set plot_timestamp_to="./xx.png" to get figure of alignment besides timestamps
  7. # model = Paraformer(model_dir, batch_size=1, plot_timestamp_to="test.png")
  8. wav_path = ['{}/.cache/modelscope/hub/damo/speech_paraformer-large_asr_nat-zh-cn-16k-common-vocab8404-pytorch/example/asr_example.wav'.format(Path.home())]
  9. result = model(wav_path)
  10. print(result)