demo_funasr.py 609 B

1234567891011121314151617181920212223242526
  1. #!/usr/bin/env python3
  2. # -*- encoding: utf-8 -*-
  3. # Copyright FunASR (https://github.com/alibaba-damo-academy/FunASR). All Rights Reserved.
  4. # MIT License (https://opensource.org/licenses/MIT)
  5. import sys
  6. from funasr import AutoModel
  7. model_dir = "iic/SenseVoiceSmall"
  8. input_file = (
  9. "https://isv-data.oss-cn-hangzhou.aliyuncs.com/ics/MaaS/ASR/test_audio/asr_example_zh.wav"
  10. )
  11. model = AutoModel(
  12. model=model_dir,
  13. trust_remote_code=True,
  14. )
  15. res = model.generate(
  16. input=input_file,
  17. cache={},
  18. language="auto", # "zn", "en", "yue", "ja", "ko", "nospeech"
  19. use_itn=False,
  20. )
  21. print(res)