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

祝大家开心!

相关推荐
星野云联AIoT技术洞察9 小时前
2025年语音识别(ASR)与语音合成(TTS)技术趋势分析对比
whisper·语音识别·模型部署·tts·asr·嵌入式ai·naturalspeech3
共绩算力5 天前
OpenAI Whisper 语音识别模型:技术与应用全面分析
人工智能·whisper·语音识别·共绩算力
人工智能技术派7 天前
Whisper推理源码解读
人工智能·语言模型·whisper·语音识别
luoyayun36111 天前
PySide6调用OpenAI的Whisper模型进行语音ASR转写
whisper·pyside6·asr
学习是生活的调味剂11 天前
PEFT实战LoRA微调OpenAI Whisper 中文语音识别
人工智能·whisper·语音识别
qq74223498416 天前
语音识别:PyAudio、SoundDevice、Vosk、openai-whisper、Argos-Translate、FunASR(Python)
python·whisper·语音识别
AI_Gump17 天前
WhisperLiveKit上手及主观评测
人工智能·whisper
biubiubiu070617 天前
faster-whisper + FastAPI安装
whisper
cwll200917 天前
使用ffmpeg8.0的whisper模块语音识别
人工智能·whisper·语音识别
小小ken17 天前
whisper-large-v3部署详细步骤,包括cpu和gpu方式,跟着做一次成功
ffmpeg·whisper·语音识别