Starting with macOS Tahoe, the SpeechAnalyzer API will be introduced. To make it easier to use, I’ve set up an environment to wrap it into a dylib.
-
File Transcription Call sw_transcribeFile(const char *filePath, const char *locale, TranscriptionCallback callback, void *userData) to transcribe an audio file asynchronously.
- Inputs:
- filePath: C-string path to the audio file
- locale: C-string locale identifier (defaults to current locale if NULL)
- callback: C function of type void (*)(const char *textOrError, void *userData)
- userData: opaque pointer passed back in each callback
- Behavior:
- Launches a background task to read and process the file
- On success, sends the full transcript to your callback
- On failure, sends an "Error: …" string instead
- Return: 0 if the task was started, -1 if no file path was provided
- Inputs:
-
Data Transcription Call sw_transcribeData(const uint8_t *bytes, size_t size, const char *locale, TranscriptionCallback callback, void *userData) to transcribe in‐memory audio data.
- Inputs:
- bytes: pointer to the raw audio data buffer
- size: number of bytes in the audio buffer
- locale: C‐string locale identifier (defaults to current locale if NULL)
- callback: C function of type void (*)(const char *textOrError, void *userData)
- userData: opaque pointer passed back in each callback
- Behavior:
- Copies the buffer into a temporary file on disk
- Reuses the existing file‐based transcription path (transcribeFile)
- On success, sends the full transcript to your callback
- On failure, sends an "Error: …" string instead
- Cleans up the temporary file when done
- Return: 0 if the task was started, -1 if the buffer pointer is NULL or size is zero
- Inputs:
-
Live Microphone Transcription Call sw_startMicrophoneTranscription(const char *locale, TranscriptionCallback callback, void *userData) to begin streaming live speech from the default mic.
- Inputs: same as above, except no file path
- Behavior:
- Verifies or installs the offline model for the given locale
- Captures, converts, and analyzes mic audio in real time
- Streams each partial transcript back via your callback as it arrives
- Stops and finalizes automatically when the audio engine is stopped
- Return: always 0 (task is fire-and-forget)
- macOS 26.0 or later
- Xcode 26.0 or later
Now .build/arm64-apple-macosx/release/libSpeechAnalyzerWrapper.dylib and .build/SpeechAnalyzerWrapper/SpeechAnalyzerWrapper.h will be generated.