Include pvporcupine resource files in PyInstaller build

PyInstaller wasn't bundling pvporcupine's resource files (keyword_files
and lib directories), causing a FileNotFoundError at runtime when
pvporcupine tried to access its resources directory.

Changes:
- Added code to detect and include pvporcupine resources and lib folders
- Falls back gracefully if pvporcupine is not installed
- Resources are bundled even though we don't use wake word features
  (pvporcupine initializes and checks for these on import)

This fixes the runtime error:
FileNotFoundError: [WinError 3] The system cannot find the path
specified: '...\pvporcupine\resources/keyword_files\windows'

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-12-28 19:57:13 -08:00
parent a3f61ea177
commit 4d6dd6d35d

View File

@@ -18,12 +18,26 @@ import faster_whisper
faster_whisper_path = os.path.dirname(faster_whisper.__file__)
vad_assets_path = os.path.join(faster_whisper_path, 'assets')
# Find pvporcupine resources folder (needed even though we don't use wake words)
try:
import pvporcupine
pvporcupine_path = os.path.dirname(pvporcupine.__file__)
pvporcupine_resources = os.path.join(pvporcupine_path, 'resources')
pvporcupine_lib = os.path.join(pvporcupine_path, 'lib')
pvporcupine_data_files = []
if os.path.exists(pvporcupine_resources):
pvporcupine_data_files.append((pvporcupine_resources, 'pvporcupine/resources'))
if os.path.exists(pvporcupine_lib):
pvporcupine_data_files.append((pvporcupine_lib, 'pvporcupine/lib'))
except ImportError:
pvporcupine_data_files = []
# Base configuration
binaries = []
datas = [
('config/default_config.yaml', 'config'),
(vad_assets_path, 'faster_whisper/assets'), # Include VAD model
]
] + pvporcupine_data_files # Include pvporcupine resources
hiddenimports = [
'PySide6.QtCore',
'PySide6.QtWidgets',