diff --git a/.coveragerc b/.coveragerc index 8c7c88d1..ca85a2d3 100644 --- a/.coveragerc +++ b/.coveragerc @@ -1,6 +1,8 @@ [run] omit = - buzz/whisper_cpp.py + buzz/whisper_cpp/* + buzz/whisper_cpp_vulkan/* + buzz/whisper_cpp_coreml/* *_test.py demucs/* diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ad67049c..b4b32c96 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -258,9 +258,9 @@ jobs: - name: Build wheels uses: pypa/cibuildwheel@v2.22.0 env: - CIBW_ARCHS_WINDOWS: "auto" + CIBW_ARCHS_WINDOWS: "auto64" CIBW_ARCHS_MACOS: "universal2" - CIBW_ARCHS_LINUX: "auto" + CIBW_ARCHS_LINUX: "auto64" - uses: actions/upload-artifact@v4 with: diff --git a/.gitignore b/.gitignore index 25464fb3..eeae8d42 100644 --- a/.gitignore +++ b/.gitignore @@ -13,19 +13,14 @@ coverage.xml venv/ # whisper_cpp -libwhisper.* -libwhisper-vulkan.* -libwhisper-coreml.* whisper_cpp whisper_cpp.exe -whisper.dll -ggml.dll -ggml-gase.dll -ggml-cpu.dll -ggml-vulkan.dll -buzz/whisper_cpp.py -buzz/whisper_cpp_coreml.py -buzz/whisper_cpp_vulkan.py +*.dll +*.dylib +*.so +buzz/whisper_cpp/* +buzz/whisper_cpp_vulkan/* +buzz/whisper_cpp_coreml/* # Internationalization - compiled binaries *.mo diff --git a/Buzz.spec b/Buzz.spec index 0f53c829..ae8ecbbc 100644 --- a/Buzz.spec +++ b/Buzz.spec @@ -44,25 +44,26 @@ else: options = [] binaries = [ - ( - "buzz/whisper.dll" if platform.system() == "Windows" else "buzz/libwhisper.*", - ".", - ), (shutil.which("ffmpeg"), "."), (shutil.which("ffprobe"), "."), ] -# Include libwhisper-coreml.dylib on Apple Silicon -if platform.system() == "Darwin" and platform.machine() == "arm64": - binaries.append(("buzz/libwhisper-coreml.dylib", ".")) +if platform.system() != "Windows": + binaries.append(("buzz/whisper_cpp/*.so", "buzz/whisper_cpp")) + binaries.append(("buzz/whisper_cpp_vulkan/*.so", "buzz/whisper_cpp_vulkan")) + binaries.append(("buzz/whisper_cpp/*.dylib", "buzz/whisper_cpp")) + binaries.append(("buzz/whisper_cpp_vulkan/*.dylib", "buzz/whisper_cpp_vulkan")) + +if platform.system() == "Darwin" and platform.machine() == "arm64": + binaries.append(("buzz/whisper_cpp_coreml/*.dylib", "buzz/whisper_cpp_coreml")) -# Include dll_backup folder and its contents on Windows if platform.system() == "Windows": datas += [("dll_backup", "dll_backup")] datas += collect_data_files("msvc-runtime") binaries.append(("dll_backup/SDL2.dll", "dll_backup")) - binaries.append(("dll_backup/whisper.dll", "dll_backup")) + binaries.append(("buzz/whisper_cpp/*.dll", "buzz/whisper_cpp")) + binaries.append(("buzz/whisper_cpp_vulkan/*.dll", "buzz/whisper_cpp_vulkan")) a = Analysis( ["main.py"], diff --git a/Makefile b/Makefile index 74f9027c..b39ab2af 100644 --- a/Makefile +++ b/Makefile @@ -13,34 +13,35 @@ bundle_mac: dist/Buzz.app codesign_all_mac zip_mac notarize_zip staple_app_mac d bundle_mac_unsigned: dist/Buzz.app zip_mac dmg_mac_unsigned UNAME_S := $(shell uname -s) -UNAME_M := $(shell uname -m) LIBWHISPER := ifeq ($(OS), Windows_NT) LIBWHISPER=whisper.dll + LIBEXT=.dll else ifeq ($(UNAME_S), Darwin) LIBWHISPER=libwhisper.dylib + LIBEXT=.dylib else LIBWHISPER=libwhisper.so + LIBEXT=.so endif endif clean: ifeq ($(OS), Windows_NT) - -del /f buzz\$(LIBWHISPER) 2> nul - -del /f buzz\whisper_cpp.py 2> nul + -rmdir /s /q buzz\whisper_cpp 2> nul + -rmdir /s /q buzz\whisper_cpp_vulkan 2> nul -rmdir /s /q whisper.cpp\build 2> nul -rmdir /s /q dist 2> nul - -rm -f buzz/$(LIBWHISPER) - -rm -f buzz/whisper_cpp.py - -rm -rf whisper.cpp/build || true - -rm -rf dist/* || true + rm -rf buzz/whisper_cpp || true + rm -fr buzz/whisper_cpp_vulkan || true + rm -rf whisper.cpp/build || true + rm -rf dist/* || true else - rm -f buzz/$(LIBWHISPER) - rm -f buzz/whisper_cpp.py - rm -f buzz/libwhisper-coreml.dylib || true - rm -f buzz/whisper_cpp_coreml.py || true + rm -rf buzz/whisper_cpp || true + rm -fr buzz/whisper_cpp_vulkan || true + rm -fr buzz/whisper_cpp_coreml || true rm -rf whisper.cpp/build || true rm -rf dist/* || true endif @@ -60,80 +61,75 @@ version: poetry version ${version} echo "VERSION = \"${version}\"" > buzz/__version__.py -CMAKE_FLAGS= -ifeq ($(UNAME_S),Darwin) - AVX1_M := $(shell sysctl machdep.cpu.features) - ifeq (,$(findstring AVX1.0,$(AVX1_M))) - CMAKE_FLAGS += -DWHISPER_NO_AVX=ON - endif - ifeq (,$(findstring FMA,$(AVX1_M))) - CMAKE_FLAGS += -DWHISPER_NO_FMA=ON - endif - AVX2_M := $(shell sysctl machdep.cpu.leaf7_features) - ifeq (,$(findstring AVX2,$(AVX2_M))) - CMAKE_FLAGS += -DWHISPER_NO_AVX2=ON - endif - CMAKE_FLAGS += -DCMAKE_OSX_ARCHITECTURES="x86_64;arm64" -else - ifeq ($(OS), Windows_NT) - #CMAKE_FLAGS += -DBUILD_SHARED_LIBS=ON -DCMAKE_BUILD_TYPE=Release - CMAKE_FLAGS += -DCMAKE_BUILD_TYPE=Release - endif -endif - buzz/$(LIBWHISPER): -#TODO - Remove this and build from source?? -#TODO - Alternatively get from 1.7.5 release of whisper ifeq ($(OS), Windows_NT) - cmake -S whisper.cpp -B whisper.cpp/build/ $(CMAKE_FLAGS) -DGGML_VULKAN=1 + # Build Whisper for CPU + cmake -S whisper.cpp -B whisper.cpp/build/ -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=ON -DCMAKE_INSTALL_RPATH='$$ORIGIN' -DCMAKE_BUILD_WITH_INSTALL_RPATH=ON cmake --build whisper.cpp/build -j --config Release --verbose - #cp dll_backup/whisper.dll buzz || copy dll_backup\whisper.dll buzz\whisper.dll - cp dll_backup/SDL2.dll buzz || copy dll_backup\SDL2.dll buzz\SDL2.dll - cp whisper.cpp/build/bin/Release/whisper.dll buzz || copy whisper.cpp\build\bin\Release\whisper.dll buzz\whisper.dll - cp whisper.cpp/build/bin/Release/ggml.dll buzz || copy whisper.cpp\build\bin\Release\ggml.dll buzz\ggml.dll - cp whisper.cpp/build/bin/Release/ggml-gase.dll buzz || copy whisper.cpp\build\bin\Release\ggml-gase.dll buzz\ggml-gase.dll - cp whisper.cpp/build/bin/Release/ggml-cpu.dll buzz || copy whisper.cpp\build\bin\Release\ggml-cpu.dll buzz\ggml-cpu.dll - cp whisper.cpp/build/bin/Release/ggml-vulkan.dll buzz || copy whisper.cpp\build\bin\Release\ggml-vulkan.dll buzz\ggml-vulkan.dll -else - # Build Whisper for CPU - cmake -S whisper.cpp -B whisper.cpp/build/ $(CMAKE_FLAGS) - cmake --build whisper.cpp/build -j --config Release --verbose - cp whisper.cpp/build/src/$(LIBWHISPER) buzz || true + cp dll_backup/SDL2.dll buzz/whisper_cpp || copy dll_backup\SDL2.dll buzz\whisper_cpp\SDL2.dll + cp whisper.cpp/build/bin/Release/whisper.dll buzz/whisper_cpp || copy whisper.cpp\build\bin\Release\whisper.dll buzz\whisper_cpp\whisper.dll + cp whisper.cpp/build/bin/Release/ggml.dll buzz/whisper_cpp || copy whisper.cpp\build\bin\Release\ggml.dll buzz\whisper_cpp\ggml.dll + cp whisper.cpp/build/bin/Release/ggml-base.dll buzz/whisper_cpp || copy whisper.cpp\build\bin\Release\ggml-base.dll buzz\whisper_cpp\ggml-gase.dll + cp whisper.cpp/build/bin/Release/ggml-cpu.dll buzz/whisper_cpp || copy whisper.cpp\build\bin\Release\ggml-cpu.dll buzz\whisper_cpp\ggml-cpu.dll # Build Whisper for Vulkan - cmake -S whisper.cpp -B whisper.cpp/build/ $(CMAKE_FLAGS) -DGGML_VULKAN=1 + cmake -S whisper.cpp -B whisper.cpp/build/ -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=ON -DCMAKE_INSTALL_RPATH='$$ORIGIN' -DCMAKE_BUILD_WITH_INSTALL_RPATH=ON -DGGML_VULKAN=1 cmake --build whisper.cpp/build -j --config Release --verbose - cp whisper.cpp/build/src/$(LIBWHISPER) buzz/$(subst libwhisper,libwhisper-vulkan,$(LIBWHISPER)) || true - # TODO Check where whisper lib is located on WINDOWS - #TODO - Remove if issues during CI builds - #cp whisper.cpp/build/bin/Debug/$(LIBWHISPER) buzz || true - #cp whisper.cpp/build/src/$(LIBWHISPER) buzz || true + cp dll_backup/SDL2.dll buzz/whisper_cpp || copy dll_backup\SDL2.dll buzz\whisper_cpp\SDL2.dll + cp whisper.cpp/build/bin/Release/whisper.dll buzz/whisper_cpp_vulkan || copy whisper.cpp\build\bin\Release\whisper.dll buzz\whisper_cpp_vulkan\whisper.dll + cp whisper.cpp/build/bin/Release/ggml.dll buzz/whisper_cpp_vulkan || copy whisper.cpp\build\bin\Release\ggml.dll buzz\whisper_cpp_vulkan\ggml.dll + cp whisper.cpp/build/bin/Release/ggml-base.dll buzz/whisper_cpp_vulkan || copy whisper.cpp\build\bin\Release\ggml-base.dll buzz\whisper_cpp_vulkan\ggml-gase.dll + cp whisper.cpp/build/bin/Release/ggml-cpu.dll buzz/whisper_cpp_vulkan || copy whisper.cpp\build\bin\Release\ggml-cpu.dll buzz\whisper_cpp_vulkan\ggml-cpu.dll + cp whisper.cpp/build/bin/Release/ggml-vulkan.dll buzz/whisper_cpp_vulkan || copy whisper.cpp\build\bin\Release\ggml-vulkan.dll buzz\whisper_cpp_vulkan\ggml-vulkan.dll +else + # Build Whisper for CPU + rm -rf whisper.cpp/build || true + mkdir -p buzz/whisper_cpp + cmake -S whisper.cpp -B whisper.cpp/build/ -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=ON -DCMAKE_INSTALL_RPATH='$$ORIGIN' -DCMAKE_BUILD_WITH_INSTALL_RPATH=ON + cmake --build whisper.cpp/build -j --config Release --verbose + cp whisper.cpp/build/src/libwhisper$(LIBEXT) buzz/whisper_cpp || true + cp whisper.cpp/build/ggml/src/libggml$(LIBEXT) buzz/whisper_cpp || true + cp whisper.cpp/build/ggml/src/libggml-base$(LIBEXT) buzz/whisper_cpp || true + cp whisper.cpp/build/ggml/src/libggml-cpu$(LIBEXT) buzz/whisper_cpp || true + + # Build Whisper for Vulkan + rm -rf whisper.cpp/build || true + mkdir -p buzz/whisper_cpp_vulkan + cmake -S whisper.cpp -B whisper.cpp/build/ -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=ON -DCMAKE_INSTALL_RPATH='$$ORIGIN' -DCMAKE_BUILD_WITH_INSTALL_RPATH=ON -DGGML_VULKAN=1 + cmake --build whisper.cpp/build -j --config Release --verbose + cp whisper.cpp/build/src/libwhisper$(LIBEXT) buzz/whisper_cpp_vulkan/libwhisper-vulkan$(LIBEXT) || true + cp whisper.cpp/build/ggml/src/libggml$(LIBEXT) buzz/whisper_cpp_vulkan || true + cp whisper.cpp/build/ggml/src/libggml-base$(LIBEXT) buzz/whisper_cpp_vulkan || true + cp whisper.cpp/build/ggml/src/libggml-cpu$(LIBEXT) buzz/whisper_cpp_vulkan || true + cp whisper.cpp/build/ggml/src/ggml-vulkan/libggml-vulkan$(LIBEXT) buzz/whisper_cpp_vulkan || true endif # Build CoreML support on ARM Macs ifeq ($(shell uname -m), arm64) ifeq ($(shell uname -s), Darwin) - # TODO - Vulkan support on MACS?? Maybe only for X64? - rm -rf whisper.cpp/build || true - cmake -S whisper.cpp -B whisper.cpp/build/ $(CMAKE_FLAGS) -DWHISPER_COREML=1 + cmake -S whisper.cpp -B whisper.cpp/build/ -DCMAKE_OSX_ARCHITECTURES="arm64" -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=ON -DCMAKE_INSTALL_RPATH='$$ORIGIN' -DCMAKE_BUILD_WITH_INSTALL_RPATH=ON -DWHISPER_COREML=1 cmake --build whisper.cpp/build -j --config Release --verbose - #TODO - Remove if issues during CI builds - #cp whisper.cpp/build/bin/Debug/$(LIBWHISPER) buzz/libwhisper-coreml.dylib || true - cp whisper.cpp/build/bin/Release/$(LIBWHISPER) buzz/libwhisper-coreml.dylib || true - cp whisper.cpp/build/src/$(LIBWHISPER) buzz/libwhisper-coreml.dylib || true + cp whisper.cpp/build/src/libwhisper$(LIBEXT) buzz/whisper_cpp_coreml/libwhisper-vulkan$(LIBEXT) || true + cp whisper.cpp/build/ggml/src/libggml$(LIBEXT) buzz/whisper_cpp_coreml || true + cp whisper.cpp/build/ggml/src/libggml-base$(LIBEXT) buzz/whisper_cpp_coreml || true + cp whisper.cpp/build/ggml/src/libggml-cpu$(LIBEXT) buzz/whisper_cpp_coreml || true + cp whisper.cpp/build/ggml/src/ggml-vulkan/libggml-vulkan$(LIBEXT) buzz/whisper_cpp_coreml || true + + # TODO Check where macs build the dylibs + #cp whisper.cpp/build/bin/Release/$(LIBWHISPER) buzz/whisper_cpp_coreml/libwhisper-coreml.dylib || true + #cp whisper.cpp/build/src/$(LIBWHISPER) buzz/whisper_cpp_coreml/libwhisper-coreml.dylib || true endif endif buzz/whisper_cpp.py: buzz/$(LIBWHISPER) translation_mo - cd buzz && ctypesgen ../whisper.cpp/include/whisper.h -I../whisper.cpp/ggml/include -lwhisper -o whisper_cpp.py + cd buzz && ctypesgen ../whisper.cpp/include/whisper.h -I../whisper.cpp/ggml/include -lwhisper -o ./whisper_cpp/whisper_cpp.py - #TODO - Do not build Vulkan support on Intel MACS, or ignore if it fails??? - cd buzz && ctypesgen ../whisper.cpp/include/whisper.h -I../whisper.cpp/ggml/include -lwhisper-vulkan -o whisper_cpp_vulkan.py + cd buzz && ctypesgen ../whisper.cpp/include/whisper.h -I../whisper.cpp/ggml/include -lwhisper-vulkan -o ./whisper_cpp_vulkan/whisper_cpp_vulkan.py ifeq ($(shell uname -m), arm64) ifeq ($(shell uname -s), Darwin) - cd buzz && ctypesgen ../whisper.cpp/include/whisper.h -I../whisper.cpp/ggml/include -lwhisper-coreml -o whisper_cpp_coreml.py + cd buzz && ctypesgen ../whisper.cpp/include/whisper.h -I../whisper.cpp/ggml/include -lwhisper-coreml -o ./whisper_cpp_coreml/whisper_cpp_coreml.py endif endif @@ -265,7 +261,7 @@ ifeq ($(OS), Windows_NT) done else for dir in buzz/locale/*/ ; do \ - python msgfmt.py -o $$dir/LC_MESSAGES/buzz.mo $$dir/LC_MESSAGES/buzz.po; \ + python3 msgfmt.py -o $$dir/LC_MESSAGES/buzz.mo $$dir/LC_MESSAGES/buzz.po; \ done endif diff --git a/buzz/transcriber/whisper_cpp.py b/buzz/transcriber/whisper_cpp.py index 1a619bb9..6a7b9eb6 100644 --- a/buzz/transcriber/whisper_cpp.py +++ b/buzz/transcriber/whisper_cpp.py @@ -10,18 +10,15 @@ from buzz import whisper_audio from buzz.model_loader import LOADED_WHISPER_CPP_BINARY from buzz.transcriber.transcriber import Segment, Task, TranscriptionOptions -if LOADED_WHISPER_CPP_BINARY: - from buzz import whisper_cpp - IS_COREML_SUPPORTED = False if platform.system() == "Darwin" and platform.machine() == "arm64": try: - from buzz import whisper_cpp_coreml # noqa: F401 + from buzz.whisper_cpp_coreml import whisper_cpp_coreml # noqa: F401 IS_COREML_SUPPORTED = True except ImportError: - pass + IS_COREML_SUPPORTED = False IS_VULKAN_SUPPORTED = False @@ -32,10 +29,13 @@ try: vulkan.vkDestroyInstance(instance, None) IS_VULKAN_SUPPORTED = True - from buzz import whisper_cpp_vulkan + from buzz.whisper_cpp_vulkan import whisper_cpp_vulkan except (ImportError, Exception): - pass + IS_VULKAN_SUPPORTED = False + +if not IS_VULKAN_SUPPORTED and not IS_COREML_SUPPORTED and LOADED_WHISPER_CPP_BINARY: + from buzz.whisper_cpp import whisper_cpp as whisper_cpp_cpu def append_segment(result, txt: bytes, start: int, end: int): if txt == b'': @@ -148,7 +148,7 @@ class WhisperCpp: print_realtime=False, print_progress=False, ): - params = self.instance.full_default_params(whisper_cpp.WHISPER_SAMPLING_GREEDY) + params = self.instance.full_default_params(0) # WHISPER_SAMPLING_GREEDY params.n_threads = int(os.getenv("BUZZ_WHISPERCPP_N_THREADS", (os.cpu_count() or 8)//2)) params.print_realtime = print_realtime params.print_progress = print_progress @@ -202,38 +202,39 @@ class WhisperCppInterface: class WhisperCppCpu(WhisperCppInterface): def full_default_params(self, sampling: int): - return whisper_cpp.whisper_full_default_params(sampling) + return whisper_cpp_cpu.whisper_full_default_params(sampling) def get_string(self, string: str): - return whisper_cpp.String(string.encode()) + return whisper_cpp_cpu.String(string.encode()) def get_encoder_begin_callback(self, callback): - return whisper_cpp.whisper_encoder_begin_callback(callback) + return whisper_cpp_cpu.whisper_encoder_begin_callback(callback) def get_new_segment_callback(self, callback): - return whisper_cpp.whisper_new_segment_callback(callback) + return whisper_cpp_cpu.whisper_new_segment_callback(callback) def init_from_file(self, model: str): - return whisper_cpp.whisper_init_from_file(model.encode()) + return whisper_cpp_cpu.whisper_init_from_file(model.encode()) def full(self, ctx, params, audio, length): - return whisper_cpp.whisper_full(ctx, params, audio, length) + return whisper_cpp_cpu.whisper_full(ctx, params, audio, length) def full_n_segments(self, ctx): - return whisper_cpp.whisper_full_n_segments(ctx) + return whisper_cpp_cpu.whisper_full_n_segments(ctx) def full_get_segment_text(self, ctx, i): - return whisper_cpp.whisper_full_get_segment_text(ctx, i) + return whisper_cpp_cpu.whisper_full_get_segment_text(ctx, i) def full_get_segment_t0(self, ctx, i): - return whisper_cpp.whisper_full_get_segment_t0(ctx, i) + return whisper_cpp_cpu.whisper_full_get_segment_t0(ctx, i) def full_get_segment_t1(self, ctx, i): - return whisper_cpp.whisper_full_get_segment_t1(ctx, i) + return whisper_cpp_cpu.whisper_full_get_segment_t1(ctx, i) def free(self, ctx): - if ctx and whisper_cpp is not None: - return whisper_cpp.whisper_free(ctx) + if ctx and whisper_cpp_cpu is not None: + return whisper_cpp_cpu.whisper_free(ctx) + return None class WhisperCppCoreML(WhisperCppInterface): @@ -268,8 +269,9 @@ class WhisperCppCoreML(WhisperCppInterface): return whisper_cpp_coreml.whisper_full_get_segment_t1(ctx, i) def free(self, ctx): - return whisper_cpp_coreml.whisper_free(ctx) - + if ctx and whisper_cpp_coreml is not None: + return whisper_cpp_coreml.whisper_free(ctx) + return None class WhisperCppVulkan(WhisperCppInterface): def full_default_params(self, sampling: int): @@ -303,4 +305,6 @@ class WhisperCppVulkan(WhisperCppInterface): return whisper_cpp_vulkan.whisper_full_get_segment_t1(ctx, i) def free(self, ctx): - return whisper_cpp_vulkan.whisper_free(ctx) \ No newline at end of file + if ctx and whisper_cpp_vulkan is not None: + return whisper_cpp_vulkan.whisper_free(ctx) + return None \ No newline at end of file diff --git a/dll_backup/Readme.md b/dll_backup/Readme.md deleted file mode 100644 index ecb57e32..00000000 --- a/dll_backup/Readme.md +++ /dev/null @@ -1,6 +0,0 @@ -DLLs extracted from whisper.cpp release v1.6.2 -https://github.com/ggerganov/whisper.cpp/actions/runs/9251036100 -https://github.com/ggerganov/whisper.cpp/commit/c7b6988678779901d02ceba1a8212d2c9908956e - -whisper.cpp submodule commit version should match the commit where the -whisper.dll are extracted from to ensure compatibility. diff --git a/dll_backup/whisper.dll b/dll_backup/whisper.dll deleted file mode 100644 index 633079d5..00000000 Binary files a/dll_backup/whisper.dll and /dev/null differ diff --git a/dll_backup/win32/whisper.dll b/dll_backup/win32/whisper.dll deleted file mode 100644 index 67b8871a..00000000 Binary files a/dll_backup/win32/whisper.dll and /dev/null differ diff --git a/pyproject.toml b/pyproject.toml index ab7d45c9..55ab1763 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -20,12 +20,10 @@ packages = [ { include = "buzz" }, ] include = [ - { path = "buzz/libwhisper.*", format = ["sdist", "wheel"] }, - { path = "buzz/libwhisper-coreml.*", format = ["sdist", "wheel"] }, - { path = "buzz/*.dll", format = ["sdist", "wheel"] }, - { path = "buzz/whisper_cpp.py", format = ["sdist", "wheel"] }, + { path = "buzz/whisper_cpp/*", format = ["sdist", "wheel"] }, + { path = "buzz/whisper_cpp_vulkan/*", format = ["sdist", "wheel"] }, + { path = "buzz/whisper_cpp_coreml/*", format = ["sdist", "wheel"] }, { path = "buzz/locale/*/LC_MESSAGES/buzz.mo", format = ["sdist", "wheel"] }, - { path = "buzz/dll_backup/*", format = ["sdist", "wheel"] }, ] [[tool.poetry.source]] diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml index dcffe1f7..7f7c82c0 100644 --- a/snap/snapcraft.yaml +++ b/snap/snapcraft.yaml @@ -1,5 +1,5 @@ # Development notes: -# - To build the snap run `snapcraft clean` and `snapcraft` +# - To build the snap run `snapcraft clean` and `snapcraft --verbose` # - To install local snap `snap install ./buzz_*.snap --dangerous` name: buzz base: core22 @@ -83,7 +83,12 @@ parts: plugin: python source: . build-packages: + - wget - portaudio19-dev + - qt6-declarative-dev + - qt6-multimedia-dev + - libvulkan-dev + - cmake stage-packages: # Audio - ffmpeg @@ -100,8 +105,6 @@ parts: - libgstreamer1.0-0 - libgstreamer-plugins-base1.0-0 - libgstreamer-plugins-good1.0-0 - - qt6-declarative-dev - - qt6-multimedia-dev # Display - libxkbcommon-x11-0 - libxcb-icccm4 @@ -114,27 +117,40 @@ parts: - libxcb-cursor0 # GPU - libglu1-mesa + - libvulkan1 + - mesa-vulkan-drivers + python-packages: + - ctypesgen + - setuptools + - cmake + - polib override-build: | - craftctl default - pip install poetry - make translation_mo - pip install . - pip uninstall -y ctranslate2 - pip install https://github.com/raivisdejus/CTranslate2-no-execstack/releases/download/v4.2.1/ctranslate2-4.2.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl - python3 build.py - mkdir $CRAFT_PART_INSTALL/buzz - cp $CRAFT_PART_BUILD/buzz/whisper_cpp.py $CRAFT_PART_INSTALL/buzz/ - cp $CRAFT_PART_BUILD/buzz/libwhisper.so $CRAFT_PART_INSTALL/buzz/ - after: [ desktop-qt5 ] + # https://vulkan.lunarg.com/doc/view/latest/linux/getting_started_ubuntu.html + wget -qO- https://packages.lunarg.com/lunarg-signing-key-pub.asc | tee /etc/apt/trusted.gpg.d/lunarg.asc + wget -qO /etc/apt/sources.list.d/lunarg-vulkan-jammy.list http://packages.lunarg.com/vulkan/lunarg-vulkan-jammy.list + apt update + apt install -y vulkan-sdk - desktop-file: + craftctl default + + # Create desktop file + mkdir -p $CRAFT_PART_INSTALL/usr/share/applications + cp $CRAFT_PART_BUILD/buzz.desktop $CRAFT_PART_INSTALL/usr/share/applications/ + after: [ desktop-qt5 ] + graphics-core22: + after: [ buzz ] + source: https://github.com/canonical/gpu-snap.git plugin: dump - source: . - organize: - buzz.desktop: usr/share/applications/buzz.desktop + override-prime: | + craftctl default + ${CRAFT_PART_SRC}/bin/graphics-core22-cleanup mesa-core22 nvidia-core22 + prime: + - bin/graphics-core22-wrapper apps: buzz: + command-chain: + - bin/graphics-core22-wrapper command: bin/desktop-launch python3 -m buzz desktop: usr/share/applications/buzz.desktop environment: @@ -182,7 +198,19 @@ plugs: interface: content target: $SNAP/share/sounds default-provider: gtk-common-themes + graphics-core22: + interface: content + target: $SNAP/graphics + default-provider: mesa-core22 layout: /usr/lib/$SNAPCRAFT_ARCH_TRIPLET/alsa-lib: bind: $SNAP/usr/lib/$SNAPCRAFT_ARCH_TRIPLET/alsa-lib + /usr/share/libdrm: + bind: $SNAP/graphics/libdrm + /usr/share/drirc.d: + symlink: $SNAP/graphics/drirc.d + /usr/share/X11/XErrorDB: + symlink: $SNAP/graphics/X11/XErrorDB + /usr/share/X11/locale: + symlink: $SNAP/graphics/X11/locale