Add whisper.cpp

This commit is contained in:
Christoph Reiter
2023-03-14 23:50:27 +01:00
parent 3b92c362b9
commit 61aa96c31b
2 changed files with 87 additions and 0 deletions

View File

@@ -0,0 +1,11 @@
--- whisper.cpp-1.2.1/CMakeLists.txt.orig 2023-02-28 21:29:12.000000000 +0100
+++ whisper.cpp-1.2.1/CMakeLists.txt 2023-03-15 00:49:33.350559200 +0100
@@ -230,7 +230,7 @@
install(TARGETS ${TARGET}
LIBRARY DESTINATION lib
- ARCHIVE DESTINATION lib/static
+ ARCHIVE DESTINATION lib
RUNTIME DESTINATION bin
PUBLIC_HEADER DESTINATION include
)

View File

@@ -0,0 +1,76 @@
# Maintainer: Christoph Reiter <reiter.christoph@gmail.com>
_realname=whisper.cpp
pkgbase=mingw-w64-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}")
pkgver=1.2.1
pkgrel=1
pkgdesc="Port of OpenAI's Whisper model in C/C++ (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clang32')
url='https://github.com/ggerganov/whisper.cpp'
license=('spdx:MIT')
depends=(
"${MINGW_PACKAGE_PREFIX}-openblas"
"${MINGW_PACKAGE_PREFIX}-SDL2"
"${MINGW_PACKAGE_PREFIX}-gcc-libs"
)
makedepends=(
"${MINGW_PACKAGE_PREFIX}-cmake"
"${MINGW_PACKAGE_PREFIX}-ninja"
"${MINGW_PACKAGE_PREFIX}-cc"
"${MINGW_PACKAGE_PREFIX}-pkgconf"
)
source=("https://github.com/ggerganov/whisper.cpp/archive/refs/tags/v${pkgver}.tar.gz"
"0001-fix-importlib-location.patch")
sha256sums=('69d47fc2ba982c42bd5bade4b7c827d5b3ed74b9c59323991c45a9f0f24eb6ed'
'e2c780b44809e940a4919dae65f49a8e2792af632ec3bf12bc0cdbdea4ba2e00')
prepare() {
cd "${srcdir}"/${_realname}-${pkgver}
patch -p1 -i "${srcdir}/0001-fix-importlib-location.patch"
}
build() {
cd "${srcdir}/${_realname}-${pkgver}"
mkdir -p "${srcdir}/build-${MSYSTEM}" && cd "${srcdir}/build-${MSYSTEM}"
declare -a extra_config
if check_option "debug" "n"; then
extra_config+=("-DCMAKE_BUILD_TYPE=Release")
else
extra_config+=("-DCMAKE_BUILD_TYPE=Debug")
fi
CFLAGS+=" $(pkgconf.exe --cflags openblas)"
MSYS2_ARG_CONV_EXCL="-DCMAKE_INSTALL_PREFIX=" \
"${MINGW_PREFIX}"/bin/cmake.exe \
-GNinja \
-DCMAKE_INSTALL_PREFIX="${MINGW_PREFIX}" \
-DWHISPER_SUPPORT_SDL2=ON \
-DWHISPER_SUPPORT_OPENBLAS=ON \
-DWHISPER_BUILD_EXAMPLES=ON \
-DBUILD_SHARED_LIBS=ON \
"${extra_config[@]}" \
../${_realname}-${pkgver}
"${MINGW_PREFIX}"/bin/cmake.exe --build .
}
package() {
cd "${srcdir}/build-${MSYSTEM}"
DESTDIR="${pkgdir}" "${MINGW_PREFIX}"/bin/cmake.exe --install .
# Install the examples by prefixing them with whisper.cpp
# except main.exe, which gets installed as plain whisper.cpp.exe
for i in bin/*.exe; do
install -Dm755 "${i}" \
"${pkgdir}${MINGW_PREFIX}/bin/${_realname}-${i//bin\//}"
done
mv "${pkgdir}${MINGW_PREFIX}/bin/${_realname}-main.exe" \
"${pkgdir}${MINGW_PREFIX}/bin/${_realname}.exe"
install -Dm644 "${srcdir}/${_realname}-${pkgver}/LICENSE" "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/LICENSE"
}