model = WhisperModel(model_size, device="cuda", compute_type="int8_float16")
start_time = time.time()
segments, info = model.transcribe("1.mp3", beam_size=5)
end_time = time.time()
elapsed_time = end_time - start_time
print("[识别用时]%.2fs" % elapsed_time)
for segment in segments:
print("[识别结果] %s" % (segment.text))
复制代码
识别结果:
PS:faster-whisper最新版只支持cuda12版本,对于cuda11.x的版本,会报错:
RuntimeError: Library cublas64_12.dll is not found or cannot be loaded,请参考RuntimeError: Library cublas64_12.dll is not found or cannot be loaded-CSDN博客完成修改。