Saturday 6 May 2023

Azure cognitive services are not working with PyInstaller build when launching from .app

Building a app in Python, Mac OS, PyInstaller to package app, with speech to text from Azure's Python speechsdk (https://learn.microsoft.com/en-us/python/api/overview/azure/cognitive-services?view=azure-python). I've spent the past few weeks attempting to get an app I can distribute, but am running into pyinstaller + Azure cognitive services errors.

I can successfully build an app when I use the COLLECT in the .spec file. However, this produces just a .app file with the terminal inside (rather than a full .app file with resources, frameworks etc...). This full app runs as normal. I think, it's important to get the full .app framework right, to get the application fully notarized. I've successfully signed, notarized and stapled the .app produced from COLLECT, but it fails to run when downloaded from another source e.g. google drive, dropbox etc...

However, when I build an application with BUNDLE, I get the full app structure, and everything runs - even the Azure cognitive services functions seem to build, however, when I run the app as a application (double click the .app file) no speech is transcribed.

  • But when I double click the Unix executable, everything runs as normal.

Others with similar pyinstaller problems (.app not working, unix executable works), it's normally to do with the filepath.

  • When a .app is run, it runs from /
  • When a unix executable is run, it runs from /Users/username/

It's possible this is causing the error, but displaying all of these filepaths inside the speechsdk, it seems like they are working as expected.

  • In the .spec file I add the Azure package in the datas, and have tried adding the dylib as a binary libMicrosoft.CognitiveServices.Speech.core.dylib

I've learnt most of the above by building a minimal example, but am stuck on what the right next steps are to getting this working with BUNDLE.



from Azure cognitive services are not working with PyInstaller build when launching from .app

No comments:

Post a Comment