PyObjC SoundAnalysis Framework

12.1 · active · verified Tue Apr 14

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.

Warnings

Install

Imports

Quickstart

Demonstrates how to import and instantiate a basic class from the SoundAnalysis framework. This example creates a `SADetectSpeechRequest`, a common analysis request type.

from SoundAnalysis import SADetectSpeechRequest
from Foundation import NSError # Common for PyObjC error handling
import objc # Core PyObjC utilities

# Create an instance of a SoundAnalysis request
# SADetectSpeechRequest can be initialized without complex audio formats.
error = objc.nil # Placeholder for NSError object
speech_request = SADetectSpeechRequest.alloc().init()

if speech_request:
    print(f"Successfully created SADetectSpeechRequest: {speech_request}")
    # In a real application, you would typically add this request to an SAAudioAnalyzer:
    # from SoundAnalysis import SAAudioAnalyzer
    # # ... (setup AVAudioFormat and SAAudioAnalyzer)
    # analyzer.addAnalysisRequest_error_(speech_request, error)
else:
    print(f"Failed to create SADetectSpeechRequest. Error: {error}")

view raw JSON →