音频转文字 openai whisper

下载 bili 视频

1
2
3
4
5
6
7
pip install you-get
# you-get https://www.bilibili.com/video/BV1234567890

pip install yt-dlp
# yt-dlp https://www.bilibili.com/video/BV1234567890

# yt-dlp "https://www.youtube.com/watch?v=GGGGGGGGGGGG" --proxy http://127.0.0.1:7890

视频转音频

1
2
3
4
5
6
scoop install ffmpeg
ffmpeg -i xxx.mp4
# checkout the audio video format
ffmpeg -i xxx.mp4 -acodec copy xxx.aac
ffmpeg -i xxx.mp4 -acodec copy xxx.mp3
ffmpeg -i xxx.mkv -acodec copy xxx.opus

音频转文字 📘

https://github.com/openai/whisper

  1. ** whisper **:

    1
    2
    3
    4
    pip install -U openai-whisper

    whisper audio.flac audio.mp3 audio.wav --model small --device cpu --language zh

  2. ** python **:
    使用 Python 运行 main.py 脚本。

    1
    2
    3
    4
    5
    6
    import whisper

    model = whisper.load_model("small", device="cpu")
    result = model.transcribe(f"123.mp3")

    print(result["text"]))