Whisper README

The project's README from github.com/Const-me/Whisper. As one markdown file: README.md.

This project is a Windows port of the whisper.cpp implementation.
Which in turn is a C++ port of OpenAI's Whisper automatic speech recognition (ASR) model.

Identity Hijacking Warning

The website whisperdesktop.com is impersonating this project and should not be trusted.

It presents itself as an official resource. Whilst it currently links to GitHub for downloads, the site operator may substitute these links with malware at any time and without warning.

Quick Start Guide

Download WhisperDesktop.zip from the “Releases” section of this repository, unpack the ZIP, and run WhisperDesktop.exe.

On the first screen it will ask you to download a model.
I recommend ggml-medium.bin (1.42GB in size), because I’ve mostly tested the software with that model.
Load Model Screen

The next screen allows to transcribe an audio file.
Transcribe Screen

There’s another screen which allows to capture and transcribe or translate live audio from a microphone.
Capture Screen

Features

The only supported platform is 64-bit Windows.
Should work on Windows 8.1 or newer, but I have only tested on Windows 10.
The library requires a Direct3D 11.0 capable GPU, which in 2023 simply means “any hardware GPU”. The most recent GPU without D3D 11.0 support was Intel Sandy Bridge from 2011.

On the CPU side, the library requires AVX1 and F16C support.

Developer Guide

Build Instructions

  1. Clone this repository

  2. Open WhisperCpp.sln in Visual Studio 2022. I’m using the freeware community edition, version 17.4.4.

  3. Switch to Release configuration

  4. Build and run CompressShaders C# project, in the Tools subfolder of the solution. To run that project, right click in visual studio, “Set as startup project”, then in the main menu of VS “Debug / Start Without Debugging”. When completed successfully, you should see a console window with a line like that:
    Compressed 46 compute shaders, 123.5 kb -> 18.0 kb

  5. Build Whisper project to get the native DLL, or WhisperNet for the C# wrapper and nuget package, or the examples.

Other Notes

If you gonna consume the library in a software built with Visual C++ 2022 or newer, you probably redistribute Visual C++ runtime DLLs in the form of the .msm merge module, or vc_redist.x64.exe binary.
If you do that, right click on the Whisper project, Properties, C/C++, Code Generation, switch “Runtime Library” setting from Multi-threaded (/MT) to Multi-threaded DLL (/MD), and rebuild: the binary will become smaller.

The library includes RenderDoc GPU debugger integration.
When launched your program from RenderDoc, hold F12 key to capture the compute calls.
If you gonna debug HLSL shaders, use the debug build of the DLL, it includes debug build of the shaders and you’ll get better UX in the debugger.

The repository includes a lot of code which was only used for development: couple alternative model implementations, compatible FP64 versions of some compute shaders, debug tracing and the tool to compare the traces, etc.
That stuff is disabled by preprocessor macros or constexpr flags, I hope it’s fine to keep here.

Performance Notes

I have a limited selection of GPUs in this house.
Specifically, I have optimized for nVidia 1080Ti, Radeon Vega 8 inside Ryzen 7 5700G, and Radeon Vega 7 inside Ryzen 5 5600U.
Here’s the summary.

The nVidia delivers relative speed 5.8 for the large model, 10.6 for the medium model.
The AMD Ryzen 5 5600U APU delivers relative speed about 2.2 for the medium model. Not great, but still, much faster than realtime.

I have also tested on nVidia 1650: slower than 1080Ti but pretty good, much faster than realtime.
I have also tested on Intel HD Graphics 4000 inside Core i7-3612QM, the relative speed was 0.14 for medium model, 0.44 for small model. That’s much slower than realtime, but I was happy to find my software works even on the integrated mobile GPU launched in 2012.

I’m not sure the performance is ideal on discrete AMD GPUs, or integrated Intel GPUs, have not specifically optimized for them.
Ideally, they might need slightly different builds of a couple of the most expensive compute shaders, mulMatTiled.hlsl and mulMatByRowTiled.hlsl
And maybe other adjustments, like the useReshapedMatMul() value in Whisper/D3D/device.h header file.

I don’t know how to measure that, but I have a feeling the bottleneck is memory, not compute.
Someone on Hacker News has tested on 3060Ti, the version with GDDR6 memory. Compared to 1080Ti, that GPU has 1.3x FP32 FLOPS, but 0.92x VRAM bandwidth. The app was about 10% slower on the 3060Ti.

Further Optimisations

I have only spent a few days optimizing performance of these shaders.
It might be possible to do much better, here’s a few ideas.

Missing Features

Automatic language detection is not implemented.

In the current version there’s high latency for realtime audio capture.
Specifically, depending on voice detection the figure is about 5-10 seconds.
At least in my tests, the model wasn’t happy when I supplied too short pieces of the audio.
I have increased the latency and called it a day, but ideally this needs a better fix for optimal UX.

Final Words

From my perspective, this is an unpaid hobby project, which I completed over the 2022-23 winter holydays.
The code probably has bugs.
The software is provided “as is”, without warranty of any kind.

Thanks to Georgi Gerganov for whisper.cpp implementation, and the models in GGML binary format.
I don’t program Python, and I don’t know anything about the ML ecosystem.
I wouldn’t even start this project without a good C++ reference implementation, to test my version against.

That whisper.cpp project has an example which uses the same GGML implementation to run another OpenAI’s model, GPT-2.
It shouldn’t be hard to support that ML model with the compute shaders and relevant infrastructure already implemented in this project.

If you find this useful, I’ll be very grateful if you consider a donation to “Come Back Alive” foundation.

Whisper (Const-me/Whisper)

Searching Database…

10.7K ·GitHub
这是什么?这是 OpenAI Whisper 语音识别模型的 Windows 移植版,用 DirectCompute 而不是 CUDA 在 GPU 上做推理,转写速度远快于官方 PyTorch 实现。
这是桌面应用,还是能接进我自己代码的库?两者都是:它既提供 WhisperDesktop.exe 图形界面应用,用来转写文件或实时音频;也提供原生 C++ DLL,带 COM 风格 API 和发布在 nuget 上的地道 C# 封装。
怎么让它跑起来?从 Releases 部分下载 WhisperDesktop.zip,解压后运行 WhisperDesktop.exe;首次启动会提示你下载模型(推荐 ggml-medium.bin,1.42GB)。
它需要什么硬件?任何支持 Direct3D 11.0 的 GPU(基本上 2011 年以后生产的都行),以及支持 AVX1 和 F16C 的 CPU;除基本系统组件外没有其他运行时依赖。
它还有什么做不到的?自动语言检测尚未实现,实时麦克风采集有明显延迟(约 5-10 秒),取决于语音检测。
它在 Mac 或 Linux 上也能跑吗?不能,它只支持 64 位 Windows(8.1 或更新,主要在 Windows 10 上测试过);没有跨平台构建。
为什么它比 PyTorch 的 Whisper 快这么多?它用不绑定厂商的 DirectCompute 着色器取代了 CUDA/PyTorch:在作者的 GeForce 1080Ti 上,medium 模型转写一段 3 分 24 秒的音频只用 19 秒,而 PyTorch+CUDA 要 45 秒;整个引擎只是一个 431KB 的 DLL,而不是 9.63GB 的机器学习运行时依赖。
我该从哪个 Whisper 模型入手?作者推荐 ggml-medium.bin(1.42GB),因为这是他随该应用测试最充分的模型。
whisperdesktop.com 是这个项目的官方网站吗?不是,README 明确警告 whisperdesktop.com 在冒充该项目,随时可能传播恶意软件,尽管它目前链接回本仓库的 GitHub 发布页。
可以用脚本或自动化来操作它吗?可以,1.10 版加入了对系统预装 Windows PowerShell 5.1 的脚本支持,此外还有 COM API 和 C# nuget 封装可用于自定义集成。
Creator
Const-me
Size
4.3 MB
Stars
10.7K
Age
3y
Commits · 90 Days