voice_translation_test.py 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. # from funasr import AutoModel
  2. # import time
  3. # def vocal_text(input_video_path):
  4. # model = AutoModel(model="./Voice_translation", model_revision="v2.0.4",
  5. # vad_model="./Endpoint_detection", vad_model_revision="v2.0.4",
  6. # punc_model="./Ct_punc", punc_model_revision="v2.0.4",
  7. # use_cuda=True,use_fast = True,
  8. # )
  9. # res = model.generate(input_video_path,
  10. # batch_size_s=30,
  11. # hotword='test')
  12. # texts = [item['text'] for item in res]
  13. # result = ' '.join(texts)
  14. # return result
  15. # if __name__ == "__main__":
  16. # start_time = time.time()
  17. # model = AutoModel(model="./Voice_translation", model_revision="v2.0.4",
  18. # vad_model="./Endpoint_detection", vad_model_revision="v2.0.4",
  19. # punc_model="./Ct_punc", punc_model_revision="v2.0.4",
  20. # )
  21. # res = model.generate(input="./data/audio/5bf77846-0193-4f35-92f7-09ce51ee3793.mp3",
  22. # batch_size_s=30,
  23. # hotword='test')
  24. # print(res)
  25. # texts = [item['text'] for item in res]
  26. # print(texts)
  27. # result = ' '.join(texts)
  28. # print(result)
  29. # # def save(input,savepath):
  30. # # outputs = open(savepath, 'w', encoding='utf-8')
  31. # # outputs.write(input+'\n')
  32. # # outputs.close()
  33. # # save(input=result,savepath=r"F:\work\voice_translation\datasets\1.txt")
  34. # end_time = time.time()
  35. # # 计算时间差
  36. # elapsed_time = end_time - start_time
  37. # print(f"耗时: {elapsed_time} 秒")