Skip to main content

Python interface to macOS AI capabilities

Project description

macbook-ai

PyPI Python License: MIT

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

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

macbook_ai-0.1.4.tar.gz (4.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

macbook_ai-0.1.4-py3-none-any.whl (5.9 kB view details)

Uploaded Python 3

File details

Details for the file macbook_ai-0.1.4.tar.gz.

File metadata

  • Download URL: macbook_ai-0.1.4.tar.gz
  • Upload date:
  • Size: 4.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.8 {"installer":{"name":"uv","version":"0.11.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for macbook_ai-0.1.4.tar.gz
Algorithm Hash digest
SHA256 cde0ca39475c0b9985de25491ffd26ecb55c662ea461de155c9f03c08be432b7
MD5 0b5cb00c47aa7a5ba14d5b8dd2438237
BLAKE2b-256 dff13edf94ba88cb379f85ae4489c45da5d2af8834e9f4fe9a747c94db775c9e

See more details on using hashes here.

File details

Details for the file macbook_ai-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: macbook_ai-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 5.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.8 {"installer":{"name":"uv","version":"0.11.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for macbook_ai-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 bca781cd71756ff0cfdd1389e516c421d3040a3f3ae3506e2c2b5a8b3739e6f5
MD5 658b7a8e4a08c861d6289a9652cc79e9
BLAKE2b-256 50734d0816213423134ffa7c3ad3178c65e489fc6e12b6dec4e6372d6ad1c222

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page