Skip to main content

On-device speech transcription for macOS via Apple's SpeechAnalyzer

Project description

mac-speech-analyzer

🐍 Python package to run the macOS 26 SpeechAnalyzer API from Python to transcribe audio files.

The SpeechAnalyzer API generally provides faster and better results than other locally running transcription engines of comparable size.

Features

  • On-device transcription. Audio never leaves your Mac.
  • Supports many languages. Automatic model download on first use.
  • Progressive output. Observe segments as they're finalized, or wait for the full transcript.

Requirements

  • macOS >= 26.0
  • XCode command-line tools

Installation

uv add mac-speech-analyzer
# or
pip install mac-speech-analyzer

Usage

Basic usage

from macspeechanalyzer import transcribe

text = transcribe("/path/to/file", locale="en")

Progressive transcription

transcribe returns the full transcript once analysis completes, but you can also observe segments as they're finalized. Pass any callable as on_segment and it'll be invoked once per segment, in order, with the segment text:

from macspeechanalyzer import transcribe

# default: no progressive output
text = transcribe("/path/to/file", locale="en")

# echo each segment to stdout as it's transcribed
text = transcribe("/path/to/file", locale="en", on_segment=print)

# or use your own callback
def log(segment: str) -> None:
    print(f"... {segment} ...")

text = transcribe("/path/to/file", locale="en", on_segment=log)

Segments are non-overlapping and never revised, so appending them yields the same string as the return value.

Technical details

This package is made up of two parts: the Python wrapper provides the API, but the actual functionality is achieved by embedding a Swift project which exposes functions to C. With this kind of three language interplay, a clean separation of concerns is really important. Therefore, the implementation is divided into the following four layers:

  • Pure Python
  • Python → C compat
  • Swift → C compat
  • Pure Swift

The pure Swift and pure Python layers only deal with their respective languages & types, while the compat layers do all the ugly work of converting between native and C-compatible types

Roadmap

  • ✅ Basic one-shot transcription
  • Class-based interface
    • Context manager implementation
  • Transcription of live audio stream (microphone, ...)

Development

uv pip install -e .

to one-time-install the package as editable, from then on:

ninja

to rebuild the package

License

mac-speech-analyzer is released under the MIT License. See LICENSE for more details.

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

mac_speech_analyzer-0.1.2.tar.gz (19.8 kB view details)

Uploaded Source

Built Distribution

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

mac_speech_analyzer-0.1.2-py3-none-macosx_26_0_arm64.whl (19.7 kB view details)

Uploaded Python 3macOS 26.0+ ARM64

File details

Details for the file mac_speech_analyzer-0.1.2.tar.gz.

File metadata

  • Download URL: mac_speech_analyzer-0.1.2.tar.gz
  • Upload date:
  • Size: 19.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.29 {"installer":{"name":"uv","version":"0.11.29","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for mac_speech_analyzer-0.1.2.tar.gz
Algorithm Hash digest
SHA256 cea6e0e4bb51d4b624c3b25b5e02684ac7c0fd8df4d40294a8a168906376b6cd
MD5 85e757c686d1006658bcd39bc4a16fb1
BLAKE2b-256 da42b670d80d5fd171a819d4e127e2a5a9c2034f8449e6ee5936b3434742d821

See more details on using hashes here.

File details

Details for the file mac_speech_analyzer-0.1.2-py3-none-macosx_26_0_arm64.whl.

File metadata

  • Download URL: mac_speech_analyzer-0.1.2-py3-none-macosx_26_0_arm64.whl
  • Upload date:
  • Size: 19.7 kB
  • Tags: Python 3, macOS 26.0+ ARM64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.29 {"installer":{"name":"uv","version":"0.11.29","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for mac_speech_analyzer-0.1.2-py3-none-macosx_26_0_arm64.whl
Algorithm Hash digest
SHA256 ea341428cf1248031464fe06d92c3b58ff2e497e16aa391ada9bb2b83ae1e651
MD5 ce435b90902173fc585d374199d171db
BLAKE2b-256 5693098634ec1ce8a7c53f3e63a90c6fc40c935b9374be504d070985362868b9

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