From e032efc636e578b193646b4043ba495d5fbd75b9 Mon Sep 17 00:00:00 2001 From: Roy Shilkrot Date: Thu, 14 Nov 2024 08:39:02 -0500 Subject: [PATCH] Update package data paths in setup.py and remove redundant entries from pyproject.toml; add input validation in transcribe method --- pyproject.toml | 4 ---- setup.py | 2 +- src/whisper_wrapper.cpp | 6 ++++++ 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 6370f8d..b851591 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -37,10 +37,6 @@ test = [ [tool.setuptools] packages = ["simpler_whisper"] -include-package-data = true - -[tool.setuptools.package-data] -simpler_whisper = ["*.dll", "*.pyd", "*.so", "*.metal", "*.dylib"] [tool.pytest] testpaths = ["tests"] diff --git a/setup.py b/setup.py index bc9e190..b19562e 100644 --- a/setup.py +++ b/setup.py @@ -113,7 +113,7 @@ def build_extension(self, ext): "numpy", ], package_data={ - "simpler_whisper": ["*.dll", "*.pyd", "*.so", "*.metal", "*.bin", "*.dylib"], + "simpler_whisper": ["./*.dll", "./*.pyd", "./*.so", "./*.metal", "./*.bin", "./*.dylib"], }, include_package_data=True, ) diff --git a/src/whisper_wrapper.cpp b/src/whisper_wrapper.cpp index b493754..9c9f269 100644 --- a/src/whisper_wrapper.cpp +++ b/src/whisper_wrapper.cpp @@ -203,6 +203,12 @@ class AsyncWhisperModel */ size_t transcribe(py::array_t audio) { + // Check if input is empty + if (audio.is_none() || audio.size() == 0) + { + return 0; + } + return this->queueAudio(audio); }