OpenAI Whisper 把mp3语音转文字

github地址: https://github.com/openai/whisper

环境准备:

pip install -U openai-whisper

on Ubuntu or Debian

sudo apt update && sudo apt install ffmpeg

on Arch Linux

sudo pacman -S ffmpeg

on MacOS using Homebrew (https://brew.sh/)

brew install ffmpeg

on Windows using Chocolatey (https://chocolatey.org/)

choco install ffmpeg

on Windows using Scoop (https://scoop.sh/)

scoop install ffmpeg

如果有GPU推荐额外安装(加速)根据自己 CUDA 版本换

pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu121
whisper D:\video\test.mp4 --model medium --language Chinese --output_format txt

Python方式

复制代码
import whisper
from pathlib import Path


def video_to_txt(video_path, txt_path=None, model_name="medium"):
    # 加载模型
    model = whisper.load_model(model_name)

    # 自动识别视频音频
    result = model.transcribe(
        video_path,
        language="zh",  # 中文
        fp16=False      # CPU必须False
    )

    text = result["text"]

    if txt_path is None:
        txt_path = Path(video_path).with_suffix(".txt")

    with open(txt_path, "w", encoding="utf-8") as f:
        f.write(text)

    print("完成 →", txt_path)


if __name__ == "__main__":
    video_to_txt("test.mp4")

视频音质差建议

ffmpeg -i test.mp4 -ar 16000 -ac 1 test.wav

whisper test.wav --model medium --language zh --output_format txt

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