From 5343a28a08a16a7fb95297c14c780a0833734be8 Mon Sep 17 00:00:00 2001 From: Developer Date: Wed, 8 Apr 2026 14:07:04 -0700 Subject: [PATCH] Bundle sounddevice PortAudio library in sidecar builds On macOS, sounddevice ships its own PortAudio dylib in the _sounddevice_data directory. PyInstaller wasn't collecting it, causing "Error querying device -1" when the sidecar tried to open an audio stream. Added data collection for _sounddevice_data in both cloud and headless PyInstaller specs. Co-Authored-By: Claude Opus 4.6 (1M context) --- local-transcription-cloud.spec | 17 +++++++++++++++++ local-transcription-headless.spec | 16 ++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/local-transcription-cloud.spec b/local-transcription-cloud.spec index 391d60f..f898c71 100644 --- a/local-transcription-cloud.spec +++ b/local-transcription-cloud.spec @@ -19,9 +19,26 @@ datas = [ ('config/default_config.yaml', 'config'), ] +# Collect sounddevice's bundled PortAudio library (_sounddevice_data) +try: + import sounddevice + sd_path = os.path.dirname(sounddevice.__file__) + sd_data = os.path.join(sd_path, '_sounddevice_data') + if os.path.exists(sd_data): + datas.append((sd_data, '_sounddevice_data')) + print(f" + Collected sounddevice PortAudio data from {sd_data}") + # Also collect the package itself + sd_datas = collect_data_files('sounddevice') + if sd_datas: + datas += sd_datas + print(f" + Collected {len(sd_datas)} sounddevice data files") +except ImportError: + print(" - Warning: sounddevice not found") + # Hidden imports -- only lightweight deps needed for Deepgram streaming hiddenimports = [ 'sounddevice', + '_sounddevice_data', 'numpy', # FastAPI and dependencies 'fastapi', diff --git a/local-transcription-headless.spec b/local-transcription-headless.spec index ddbff43..00e0014 100644 --- a/local-transcription-headless.spec +++ b/local-transcription-headless.spec @@ -38,6 +38,21 @@ datas = [ (vad_assets_path, 'faster_whisper/assets'), ] + pvporcupine_data_files +# Collect sounddevice's bundled PortAudio library (_sounddevice_data) +try: + import sounddevice + sd_path = os.path.dirname(sounddevice.__file__) + sd_data = os.path.join(sd_path, '_sounddevice_data') + if os.path.exists(sd_data): + datas.append((sd_data, '_sounddevice_data')) + print(f" + Collected sounddevice PortAudio data from {sd_data}") + sd_datas = collect_data_files('sounddevice') + if sd_datas: + datas += sd_datas + print(f" + Collected {len(sd_datas)} sounddevice data files") +except ImportError: + print(" - Warning: sounddevice not found") + # Hidden imports -- NO PySide6/Qt needed for headless backend hiddenimports = [ # Transcription engine @@ -46,6 +61,7 @@ hiddenimports = [ 'faster_whisper.vad', 'ctranslate2', 'sounddevice', + '_sounddevice_data', 'scipy', 'scipy.signal', 'numpy',