当前位置: 首页 > news >正文

windows基于cpu安装pytorch运行faster-whisper-large-v3实现语音转文字

1.创建虚拟环境
conda create -n faster-whisper python=3.10
conda activate faster-whisper

2.安装cpu版本的pytorch
pip3 install torch torchvision torchaudio -i https://pypi.tuna.tsinghua.edu.cn/simple

3.验证pytorch安装结果

(faster-whisper) H:\big-model\faster-whisper-large-v3>python
Python 3.10.16 | packaged by Anaconda, Inc. | (main, Dec 11 2024, 16:19:12) [MSC v.1929 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>
>>> import torch
>>> import torchvision
>>> import torchaudio
>>>
>>> print(f"PyTorch version: {torch.__version__}")
PyTorch version: 2.6.0+cpu
>>> print(f"torchvision version: {torchvision.__version__}")
torchvision version: 0.21.0+cpu
>>> print(f"torchaudio version: {torchaudio.__version__}")
torchaudio version: 2.6.0+cpu
>>> print(f"NumPy version: {torch.__version__}")
NumPy version: 2.6.0+cpu
>>>

4.安装ctranslate2和faster-whisper
pip3 install ctranslate2 faster-whisper -i https://pypi.tuna.tsinghua.edu.cn/simple

5.下载faster-whisper-large-v3模型
执行下面的python语句会去外网Hugging Face Hub自动下载,要翻墙,下载慢。

>>> model = WhisperModel("large-v3")

可以手动下载放到H:\big-model\faster-whisper-large-v3目录下

下载地址:https://huggingface.co/Systran/faster-whisper-large-v3/tree/main

6.测试语音转文字

>>> from faster_whisper import WhisperModel
>>> model_path = "H:\\big-model\\faster-whisper-large-v3"
>>> model = WhisperModel(model_path, device="cpu")
[2025-02-12 21:39:43.689] [ctranslate2] [thread 2996] [warning] The compute type inferred from the saved model is float16, but the target device or backend do not support efficient float16 computation. The model weights have been automatically converted to use the float32 compute type instead.
>>> 
>>>
>>> audio_file = "H:\\big-model\\audio\\628941565166328648.mp3"
>>> segments, info = model.transcribe(audio_file, beam_size=5)
>>> for segment in segments:
...     print("[%.2fs -> %.2fs] %s" % (segment.start, segment.end, segment.text))
...
[0.00s -> 2.70s] 下面我们来看一下理财的三要素
[2.70s -> 6.38s] 安全性、流动性和收益性
[6.38s -> 11.94s] 世界上任何的投资行为都是在这三性中综合考量

done

http://www.lryc.cn/news/536869.html

相关文章:

  • AI大模型(如GPT、BERT等)可以通过自然语言处理(NLP)和机器学习技术,显著提升测试效率
  • 【Prometheus】prometheus黑盒监控balckbox全面解析与应用实战
  • CSS实现单行、多行文本溢出显示省略号(…)
  • 服务器中部署大模型DeepSeek-R1 | 本地部署DeepSeek-R1大模型 | deepseek-r1部署详细教程
  • 元学习之孪生网络Siamese Network
  • 深入HBase——引入
  • Python创建FastApi项目模板
  • TCNE 网络安全
  • 车规MCU处理器选择Cortex-M7还是Cortex-R52?
  • 什么是计算机中的 “终端”?
  • LeetCode刷题---字符串---819
  • SSH IBM AIX服务器相关指标解读
  • Wireshark TS | 再谈虚假的 TCP Spurious Retransmission
  • 基于kafka、celery的日志收集报警项目
  • QML使用ChartView绘制饼状图
  • 头歌实验--面向对象程序设计
  • DeepSeek-R1 蒸馏 Qwen 和 Llama 架构 企业级RAG知识库
  • App UI自动化--Appium学习--第二篇
  • 【SpringBoot实现全局API限频】 最佳实践
  • Day1 25/2/14 FRI
  • 开发板适配之I2C-RTC
  • vuedraggable固定某一item的记录
  • 我的新书《青少年Python趣学编程(微课视频版)》出版了!
  • 前端开发入门一
  • Linux(Centos 7.6)命令详解:head
  • HTTP请求X-Forwarded-For注入
  • 《生息之地》入围柏林主竞赛,总制片人蒋浩助力青年导演走向国际
  • 实践记录--电脑故障的问题定位和处理回顾--磁盘故障已解决
  • uni-app 学习(一)
  • Ubuntu 22.04 Desktop企业级基础配置操作指南