Java小强个人技术博客站点    手机版
当前位置: 首页 >> 开源 >> OpenAi语音转文字开源项目Whisper Ubuntu安装

OpenAi语音转文字开源项目Whisper Ubuntu安装

500 开源 | 2026-1-8

Whisper 是 OpenAI 研发的自动语音识别(ASR)系统,它具备强大的多语言识别能力,能处理多种不同口音和背景噪音下的语音内容,将其准确地转换为文本。其支持的语言众多,包括但不限于英语、中文、法语、德语等,广泛应用于会议记录、音频字幕制作、语音内容整理等场景。

Whisper 可以在多种操作系统上运行,如 Windows、macOS 和 Linux。


whisper官网地址

https://github.com/openai/whisper   


这了选用的Ubuntu24.04版本,不要选择太高版本,因为自带的Python不适用,官方介绍

We used Python 3.9.9 and PyTorch 1.10.1 to train and test our models, 
but the codebase is expected to be compatible with Python 3.8-3.11 
and recent PyTorch versions. The codebase also depends on a few Python packages, 
most notably OpenAI's tiktoken for their fast tokenizer implementation.

虽然如此,Ubuntu24上再带的Python 3.12.3依然是可以用的


安装基础环境

sudo apt install -y python3 python3-pip ffmpeg git
python3 --version


安装 Python 的虚拟环境管理工具

sudo apt install python3-venv -y


调用 Python 内置的 venv 模块,得到一个完全独立的 Python 空间

python3 -m venv whisper_env

执行后,会在用户目录下生成一个whisper_env目录


激活它

source whisper_env/bin/activate

如需退出

deactivate


升级 pip(可选但推荐),耐心等待

pip install --upgrade pip


安装 whisper,需要更多耐心等待

pip install openai-whisper


测试 Whisper 需要更多耐心等待x2,因为需要下载模型文件

whisper 1767594398074.mp3 --model medium --language Chinese

--language Chinese 可提升中文识别准确率(非必需,但推荐)


模型所在文件夹

/home/你的用户名/.cache/whisper/        # Linux
/Users/你的用户名/.cache/whisper/       # macOS(如果使用标准 Python 环境)


执行后控制台打印

/home/cui/whisper_env/lib/python3.12/site-packages/whisper/transcribe.py:132: UserWarning: FP16 is not supported on CPU; using FP32 instead
  warnings.warn("FP16 is not supported on CPU; using FP32 instead")
[00:00.000 --> 00:03.400] 据黑龙江省疾病预防控制中心消息
[00:03.400 --> 00:08.560] 小寒节气标志着我国大部分地区进入一年中最寒冷时段
[00:08.560 --> 00:11.960] 寒潮频繁 气温骤降 空气干燥
[00:11.960 --> 00:16.240] 是呼吸道传染病 心脑血管疾病的高发期
[00:16.240 --> 00:18.040] 为保障公众健康
[00:18.040 --> 00:21.520] 黑龙江省疾控中心特发布健康提示
[00:21.520 --> 00:25.160] 指导公众科学防寒保暖 健康过冬
Traceback (most recent call last):
  File "/home/cui/whisper_env/lib/python3.12/site-packages/whisper/transcribe.py", line 616, in cli
    writer(result, audio_path, **writer_args)
  File "/home/cui/whisper_env/lib/python3.12/site-packages/whisper/utils.py", line 314, in write_all
    writer(result, file, options, **kwargs)
  File "/home/cui/whisper_env/lib/python3.12/site-packages/whisper/utils.py", line 100, in __call__
    with open(output_path, "w", encoding="utf-8") as f:
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
PermissionError: [Errno 13] Permission denied: './1767594398074.txt'
Skipping 1767594398074.mp3 due to PermissionError: [Errno 13] Permission denied: './1767594398074.txt'


提示中

UserWarning: FP16 is not supported on CPU; using FP32 instead

warnings.warn("FP16 is not supported on CPU; using FP32 instead")

FP16(Float16)是一种半精度浮点数格式,常用于 GPU(尤其是 NVIDIA 的 Tensor Core)上加速推理并节省显存。

你的系统正在使用 CPU 运行 Whisper,而大多数 CPU 不支持 FP16 计算(或效率极低),因此 Whisper 自动回退到 FP32(标准单精度浮点)。

这意味着,当前使用 CPU 进行工作


下面报错,是因为我使用的普通用户,无法在指定目录生成txt文件,无需理会。


推荐您阅读更多有关于“ linux ubuntu OpenAi 语音 文字 Whisper ”的文章

上一篇:OpenAi语音转文字开源项目Whisper JNI调用 下一篇:OpenAi语音转文字开源项目Whisper Win10应用

猜你喜欢

发表评论: