{"id":6178,"library":"pyobjc-framework-soundanalysis","title":"PyObjC SoundAnalysis Framework","description":"PyObjC-framework-soundanalysis provides Python wrappers for Apple's SoundAnalysis framework on macOS, enabling Python applications to perform advanced audio analysis tasks. It is part of the larger PyObjC project, currently at version 12.1, with a release cadence tied to macOS SDK updates and Python version support.","status":"active","version":"12.1","language":"en","source_language":"en","source_url":"https://github.com/ronaldoussoren/pyobjc","tags":["macos","audio","sound analysis","apple framework","objective-c","bridge"],"install":[{"cmd":"pip install pyobjc-framework-soundanalysis","lang":"bash","label":"Install specific framework"},{"cmd":"pip install pyobjc","lang":"bash","label":"Install all PyObjC frameworks (recommended)"}],"dependencies":[{"reason":"Core PyObjC bridge is required for all framework wrappers.","package":"pyobjc"}],"imports":[{"symbol":"SAAudioAnalyzer","correct":"from SoundAnalysis import SAAudioAnalyzer"},{"symbol":"SADetectSpeechRequest","correct":"from SoundAnalysis import SADetectSpeechRequest"}],"quickstart":{"code":"from SoundAnalysis import SADetectSpeechRequest\nfrom Foundation import NSError # Common for PyObjC error handling\nimport objc # Core PyObjC utilities\n\n# Create an instance of a SoundAnalysis request\n# SADetectSpeechRequest can be initialized without complex audio formats.\nerror = objc.nil # Placeholder for NSError object\nspeech_request = SADetectSpeechRequest.alloc().init()\n\nif speech_request:\n    print(f\"Successfully created SADetectSpeechRequest: {speech_request}\")\n    # In a real application, you would typically add this request to an SAAudioAnalyzer:\n    # from SoundAnalysis import SAAudioAnalyzer\n    # # ... (setup AVAudioFormat and SAAudioAnalyzer)\n    # analyzer.addAnalysisRequest_error_(speech_request, error)\nelse:\n    print(f\"Failed to create SADetectSpeechRequest. Error: {error}\")","lang":"python","description":"Demonstrates how to import and instantiate a basic class from the SoundAnalysis framework. This example creates a `SADetectSpeechRequest`, a common analysis request type."},"warnings":[{"fix":"Upgrade to Python 3.10 or later, or use an older PyObjC version (e.g., PyObjC 11.x for Python 3.9 support).","message":"PyObjC version 12.0 dropped support for Python 3.9. Ensure your Python version meets the `pyobjc` requirements (Python 3.10+ for 12.x).","severity":"breaking","affected_versions":">=12.0"},{"fix":"Change imports from `from AVFoundation import ...` to `from AVFAudio import ...` for `AVAudio*` related classes.","message":"Starting with PyObjC 12.0, the `AVFAudio` framework (containing core audio classes like `AVAudioFormat`) was split into its own top-level package and is no longer merged into `AVFoundation`. Imports must be updated.","severity":"breaking","affected_versions":">=12.0"},{"fix":"Review custom Python subclasses of Objective-C objects, especially their `__init__` or `init*` methods, to ensure correct reference counting and object lifecycle management.","message":"PyObjC 11.1 aligned its behavior for Objective-C `init` family methods with `clang`'s Automatic Reference Counting (ARC) rules. Methods in the 'init' family now correctly steal a reference to `self` and return a new reference, which can affect memory management if not previously accounted for.","severity":"breaking","affected_versions":">=11.1"},{"fix":"Ensure you are using PyObjC 10.3.1 or later if you have Python classes that implement both `__new__` and `__init__` and derive from `objc.lookUpClass('NSObject')` or similar PyObjC bridged classes.","message":"PyObjC 10.3 introduced a change that prevented `__init__` from being called when a user implemented `__new__`, leading to unexpected behavior. This was quickly fixed in 10.3.1, but highlights potential interactions with `__new__`.","severity":"gotcha","affected_versions":"10.3"}],"env_vars":null,"last_verified":"2026-04-14T00:00:00.000Z","next_check":"2026-07-13T00:00:00.000Z"}