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

祝大家开心!

相关推荐
言京谅4 天前
Jetson 部署 Faster Whisper
人工智能·whisper·语音识别·jetson nano
@我们的天空10 天前
【AIGC】Whisper语音识别模型概述,应用场景和具体实例及如何本地搭建Whisper语音识别模型?
人工智能·python·深度学习·机器学习·whisper·aigc·语音识别
AI逍遥子11 天前
如何本地搭建Whisper语音识别模型
人工智能·whisper·语音识别·ai编程
不会代码的小林13 天前
如何本地搭建Whisper语音识别模型
whisper
rhythmcc15 天前
【whisper】使用whisper实现语音转文字
whisper
营赢盈英15 天前
OpenAI transcription API bad request
javascript·ai·node.js·whisper·axios·openai api
LQS202015 天前
本地搭建和运行Whisper语音识别模型小记
whisper
营赢盈英16 天前
Python Poetry fails to add openai-whisper due to triton installation error
python·ai·whisper·openai·poetry
一只老虎16 天前
本地搭建 Whisper 语音识别模型实现实时语音识别研究
人工智能·whisper·语音识别
营赢盈英16 天前
OpenAI Whisper API (InvalidRequestError)
python·ai·whisper·fastapi·openai api