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

  • Online or Offline transcription
  • Automatic download of new languages

Requirements

  • macOS >= 26.0
  • XCode command-line tools

Installation

mac-speech-analyzer is currently not tracked on pypi yet.

uv add git+https://github.com/paraversal/mac-speech-analyzer
# or
pip install git+https://github.com/paraversal/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.1.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.1-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.1.tar.gz.

File metadata

  • Download URL: mac_speech_analyzer-0.1.1.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.1.tar.gz
Algorithm Hash digest
SHA256 0f98c5d56dae0d76e06926af41971b0adac6d15fe030252529f3a5eaaf991299
MD5 50a92fe0c52f7db45bd4b90dd9fc50eb
BLAKE2b-256 48eb721001089943102e1a28bdf2209650bf42c86d25e54957c4b7fd267dbd3b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: mac_speech_analyzer-0.1.1-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.1-py3-none-macosx_26_0_arm64.whl
Algorithm Hash digest
SHA256 a02f63e8523ba1ecd10d8cd755001d0249ec4d9e9cf3ff8e3e2ec95ca9cfd8ae
MD5 11b47b0570d59d55a2f339b14af22702
BLAKE2b-256 6537e0d98e07cc6e1dc4e2a1ca304e4b328c613ea783071deba79f47d6d3a4ba

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