Python interface to macOS AI capabilities
Project description
macbook-ai
Python interface to macOS AI capabilities — speech recognition, text-to-speech, and Apple Foundation Models.
All processing is on-device. No API keys, no network calls.
Requirements
- macOS 10.15 or later
- Python 3.10 or later
Installation
# speech-to-text only
pip install "macbook-ai[stt]"
# all extras
pip install "macbook-ai[all]"
With uv:
uv add "macbook-ai[stt]"
Speech-to-Text
Powered by the macOS SFSpeechRecognizer framework.
1. Grant permission
The first time you use recognition, macOS will prompt for access. You can trigger it explicitly:
from macbook_ai.stt import SpeechRecognizer
status = SpeechRecognizer.request_authorization()
# 'authorized' | 'denied' | 'restricted' | 'not_determined'
If running from Terminal, you may need to enable it manually: System Settings > Privacy & Security > Speech Recognition > Terminal
2. Transcribe a file
from macbook_ai.stt import SpeechRecognizer
recognizer = SpeechRecognizer() # defaults to en-US
text = recognizer.recognize_file("recording.m4a")
print(text)
Async
import asyncio
from macbook_ai.stt import SpeechRecognizer
async def main():
recognizer = SpeechRecognizer()
text = await recognizer.recognize_file_async("recording.m4a")
print(text)
asyncio.run(main())
Locales
recognizer = SpeechRecognizer(locale="fr-FR")
recognizer = SpeechRecognizer(locale="es-ES")
recognizer = SpeechRecognizer(locale="ja-JP")
Supported audio formats
Any format supported by AVFoundation: WAV, M4A, MP3, AIFF, CAF, FLAC, and more.
Error handling
from macbook_ai.stt import SpeechRecognizer
from macbook_ai._exceptions import AuthorizationError, RecognitionError
recognizer = SpeechRecognizer()
try:
text = recognizer.recognize_file("recording.m4a")
except AuthorizationError:
print("Grant Speech Recognition access in System Settings first.")
except RecognitionError as e:
print(f"Recognition failed: {e}")
except TimeoutError:
print("Recognition timed out — try a shorter clip or increase timeout.")
Roadmap
| Module | Capability | Status |
|---|---|---|
macbook-ai.stt |
Speech-to-text via SFSpeechRecognizer |
Available |
macbook-ai.tts |
Text-to-speech via AVSpeechSynthesizer |
Coming soon |
macbook-ai.foundation |
On-device LLM via Apple Foundation Models (macOS 26+) | Coming soon |
Development
Running Tests
uv run pytest tests/ -v
Publishing to PyPI
This project uses GitHub Actions for automatic publishing with auto-versioning.
Just commit and push to main - the version will be automatically incremented:
git add .
git commit -m "Add new feature"
git push origin main
The pipeline will automatically:
- Run tests on Python 3.10, 3.11, and 3.12
- Auto-increment the patch version (e.g., 0.1.6 → 0.1.7)
- Build the package
- Publish to PyPI if all tests pass
- Commit the version bump back to the repo
Manual version bumps: If you need to bump major or minor versions, edit pyproject.toml manually:
- Major:
0.1.6→1.0.0(breaking changes) - Minor:
0.1.6→0.2.0(new features) - Patch: automatic on every push
See PUBLISHING.md for detailed setup instructions and troubleshooting.
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file macbook_ai-0.1.7.tar.gz.
File metadata
- Download URL: macbook_ai-0.1.7.tar.gz
- Upload date:
- Size: 28.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6add68e86e52775d6cdc00945d9a87a291debf025bc23bdfa52ebd650db3bf3d
|
|
| MD5 |
a0b41fef555340ac302cc686abafc5c1
|
|
| BLAKE2b-256 |
3bf2636c9c8a6d308f774ceaf472c8e343ab15ec6d47819ae0058c92f1831338
|
Provenance
The following attestation bundles were made for macbook_ai-0.1.7.tar.gz:
Publisher:
publish.yml on sagrd/macbook-ai
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
macbook_ai-0.1.7.tar.gz -
Subject digest:
6add68e86e52775d6cdc00945d9a87a291debf025bc23bdfa52ebd650db3bf3d - Sigstore transparency entry: 1824765305
- Sigstore integration time:
-
Permalink:
sagrd/macbook-ai@dc0a797ab166ab5e7a4df9c6f1091ed0b8f3e197 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/sagrd
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@dc0a797ab166ab5e7a4df9c6f1091ed0b8f3e197 -
Trigger Event:
push
-
Statement type:
File details
Details for the file macbook_ai-0.1.7-py3-none-any.whl.
File metadata
- Download URL: macbook_ai-0.1.7-py3-none-any.whl
- Upload date:
- Size: 10.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6a8956ffbd7c462ad2c89dd09d2f6df53df184849b95b25c52c354b817b1c362
|
|
| MD5 |
f99cf45d442cd1b2853c29eca7472489
|
|
| BLAKE2b-256 |
7fa138869229b4845c43b61ba66dbe7886ceb3c6ed018148a217307481fb58cb
|
Provenance
The following attestation bundles were made for macbook_ai-0.1.7-py3-none-any.whl:
Publisher:
publish.yml on sagrd/macbook-ai
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
macbook_ai-0.1.7-py3-none-any.whl -
Subject digest:
6a8956ffbd7c462ad2c89dd09d2f6df53df184849b95b25c52c354b817b1c362 - Sigstore transparency entry: 1824765444
- Sigstore integration time:
-
Permalink:
sagrd/macbook-ai@dc0a797ab166ab5e7a4df9c6f1091ed0b8f3e197 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/sagrd
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@dc0a797ab166ab5e7a4df9c6f1091ed0b8f3e197 -
Trigger Event:
push
-
Statement type: