ggerganov / whisper.cpp

Port of OpenAI's Whisper model in C/C++
MIT License
34.04k stars 3.45k forks source link

Project build for examples/stream for Windows (CUDA 12.1) #2053

Open LeoSpace-bit opened 4 months ago

LeoSpace-bit commented 4 months ago

Through CMake I managed to build main.exe and project for MS VS 2022, attempts to build project for Stream were not successful.

Please help me either with setting CMakeLists.txt or with setting paths in MS VS 2022 project to connect header files, "common-sdl.h", "common.h", "whisper.h"

Zapotecatl commented 3 months ago

This is how I did the settings in Visual Studio 2019 (no CUDA, I hope helps for someone).

---Donwload and install CMake--- https://cmake.org/download/

---Donwload SDL---- https://github.com/libsdl-org/SDL/releases/tag/release-2.28.5 Source code (zip) Unzip

---SDL2---

cd C:\Users\Jorge\Downloads\SDL-release-2.28.5\SDL-release-2.28.5
cmake -B build
cmake --build build --config Release --target install -j 14 --

---Whispercpp---

cd D:\Whisper\
git clone https://github.com/ggerganov/whisper.cpp.git
cd D:\Whisper\whisper.cpp
cmake -B build
cmake .. -DWHISPER_BUILD_EXAMPLES=1 -DWHISPER_SDL2=1 -DSDL2_DIR="C:/C:/Program Files (x86)/SDL2" -DCMAKE_PREFIX_PATH="C:/Program Files (x86)/SDL2/cmake"
cmake .. --build build --config Release 

Download ggml-base.en.bin in models folder https://huggingface.co/ggerganov/whisper.cpp/tree/main

------------In Visual Studio-------------

Let's say you want to replicate the stream example.

Create a console application, for example: SpeechRecognizer

In properties select: All the configurations Release x64

Now add these files into you project: common.h common-sdl.h ggml.h whisper.h stream.cpp

C/C++>>Additional include directories: C:\Program Files (x86)\SDL2\include\SDL2

Configuration Properties>>C/C++>>Preporocessor>>Preprocessor Definitions: _CRT_SECURE_NO_WARNINGS

Create a Lib folder in your project, for example: D:\Whisper\SpeechRecognizer\Lib

In Lib folder add these libs: common.lib (D:\Whisper\whisper.cpp\build\examples\Release) common-sdl.lib (D:\Whisper\whisper.cpp\build\examples\Release) SDL2.lib (C:\Users\Jorge\Downloads\SDL-release-2.28.5\SDL-release-2.28.5\build\Release) whisper.lib (D:\Whisper\whisper.cpp\build\Release)

Linker>>General>>AdditionalLibrary Directories: D:\Whisper\SpeechRecognizer\Lib

Linker>>Input>>Additional Dependencies: common.lib;common-sdl.lib;whisper.lib;SDL2.lib

In stream.cpp before the main function add:

#undef main

Build your project.

Add the dlls in the folder where is your exe: SDL2.dll and whisper.dll

In your command line write something like this:

stream -m D:\\Whisper\\whisper.cpp\\models\\ggml-base.en.bin -t 8 --step 500 --length 5000