无脑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是保存的识别的文字

祝大家开心!

相关推荐
skywalk81632 天前
DuMate帮着在Windows10 编译安装Whisper-CPP
人工智能·whisper
skywalk81634 天前
Windows下安装编译安装Whisper-CPP:一个语音实现框架集和高性能推理模型
人工智能·windows·whisper
linux开发之路5 天前
C++实现Whisper+Kimi端到端AI智能语音助手
c++·人工智能·llm·whisper·openai
吱夏cz11 天前
安装whisper
whisper
Jay星晴12 天前
Whisper-large-v3语音识别效果对比:与Whisper v2/v1在中文长语音场景差异
whisper·语音识别·asr·星图gpu
FishPotatoChen15 天前
【OpenAI】Whisper 模型架构详解
whisper
weixin_4462608516 天前
[特殊字符] Insanely Fast Whisper - 超快音频转录工具!
whisper·音视频
x-cmd17 天前
[260326] x-cmd v0.8.10:跨 Shell 统一配置命令短名;自动装好依赖运行 WhisperLiveKit 实时语音转写
linux·人工智能·ai·whisper·shortcut·x-cmd
ughome1 个月前
我做了一个本地字幕提取工具:软字幕优先 + Whisper 转写回退(支持链接/本地文件)
whisper·视频字幕提取
PengShuaiD51 个月前
【AI编码】用ChatGPT基于Whisper+ffmpeg实现一个根据视频字幕执行自动化裁剪本地小工具
人工智能·chatgpt·ffmpeg·whisper