无脑018——win11部署whisper,语音转文字

1.conda创建环境

bash 复制代码
conda create -n whisper python==3.9
conda activate whisper

安装pytorch

bash 复制代码
pip install torch==1.8.1+cu101 torchvision==0.9.1+cu101 torchaudio==0.8.1 -f https://download.pytorch.org/whl/torch_stable.html

安装whisper

bash 复制代码
pip install -U openai-whisper

2.准备模型和测试音频

因为我的电脑是GTX 1060 显存只有6G

最大运行的模型是medium

所以去官网下载medium.pt模型

连接在这里:

https://github.com/openai/whisper/blob/main/whisper/**init** .py

然后自己录制一段mp3格式的音频放在如下文件夹中

G:\desktop\whisper

3.语音转文字

3.1方法一:

打开conda窗口,进入该文件夹,

用command窗口执行的命令:

bash 复制代码
(whisper) G:\desktop\whisper>whisper test1.mp3 --model medium.pt
Detecting language using up to the first 30 seconds. Use `--language` to specify the language
Detected language: Chinese
[00:00.000 --> 00:06.700] 我现在正在测试OpenAI Whisper的翻译效 果
[00:06.700 --> 00:08.000] 这里是中文
[00:08.000 --> 00:09.300] 现在是英文
[00:09.300 --> 00:10.200] English
[00:10.200 --> 00:11.300] American
[00:11.300 --> 00:12.000] China
[00:12.000 --> 00:12.900] People
[00:14.400 --> 00:16.900] 现在录制时长是15分钟
[00:16.900 --> 00:21.500] Now this is 18 second
[00:22.000 --> 00:26.300] And we will wait for 1 minute
[00:26.600 --> 00:28.800] 我们要一直等到1分钟
[00:28.800 --> 00:30.200] 这个视频结束
[00:30.200 --> 00:34.800] 来测试一下长视频的长音频的翻译效果
[00:39.100 --> 00:50.700] 37 38 40 41 42 43 44 45 46 47 48 49 50
[00:50.700 --> 00:59.700] 5 4 3 2 1
[00:59.700 --> 01:01.200] 现在是1分钟
[01:01.200 --> 01:03.200] This is 1 minute
                           

3.2 方法二:

写一个python文件test.py调用:

test.py内容如下

bash 复制代码
import whisper
model = whisper.load_model("medium.pt")
result = model.transcribe("test1.mp3")
print(result["text"])

运行方式

bash 复制代码
(whisper) G:\desktop\whisper>python test.py
我现在正在测试OpenAI Whisper的翻译效果这里是中文现在是英文EnglishAmericanChinaPeople现在录制时长是15分钟Now this is 18 secondsAnd we will wait for 1 minute我们要一直等到1分钟这个视频结束来测试一下长视频的长音频的翻译效果3738404142434445464748495054321现在是1分钟This is 1 minute

3.3 两者的区别

用command输出自动给你按照时间分类了,python代码要自己补充

command输出其他的文件,其中test1.txt是保存的识别的文字

祝大家开心!

相关推荐
lili-felicity2 天前
CANN加速Whisper语音识别推理:流式处理与实时转录优化
人工智能·whisper·语音识别
阿里巴啦4 天前
python+yt-dlp开源项目,支持 YouTube, Bilibili, TikTok/抖音,快手 等多个平台的视频/音频/字幕下载/ai摘要等功能
python·ffmpeg·whisper·音视频·视频处理·ai摘要·音视频转录
普通网友4 天前
极致压缩:Whisper.cpp 量化版本清单与 ggml 格式模型下载
whisper
天空中最亮的一颗星4 天前
如何下载、安装whisper、faster_whisper?
whisper
runner365.git6 天前
ffmpeg8.0合入whisper,语音识别模型终于进入ffmpeg
ffmpeg·whisper·语音识别
Blossom.1187 天前
从单点工具到智能流水线:企业级多智能体AI开发工作流架构实战
人工智能·笔记·python·深度学习·神经网络·架构·whisper
Blossom.1187 天前
从“金鱼记忆“到“超级大脑“:2025年AI智能体记忆机制与MoE架构的融合革命
人工智能·python·算法·架构·自动化·whisper·哈希算法
Blossom.11813 天前
把大模型塞进蓝牙耳机:1.46MB 的 Whisper-Lite 落地全记录
人工智能·笔记·python·深度学习·神经网络·chatgpt·whisper
love530love18 天前
彻底解决 ComfyUI Mixlab 插件 Whisper.available False 的报错
人工智能·windows·python·whisper·win_comfyui