Skip to main content

Expose macOS say as an HTTP server that provides text-to-speech audio generation.

Project description

macos-say-server

Expose macOS say as an HTTP server that provides text-to-speech audio generation.

Features

  • GET /health for liveness checks.
  • GET /voices to list the voices available from say -v '?'.
  • GET /cache/stats to inspect current cache usage and limits.
  • GET /speak?text=...&voice=... to return AIFF audio directly.
  • POST /speak with JSON { "text": "...", "voice": "..." } to return AIFF audio.
  • Disk-backed AIFF cache keyed by text + voice, with lazy TTL cleanup.

Run

uv sync
uv run macos-say-server

The server binds to 127.0.0.1:2576 by default.

Use startup arguments to override bind settings:

uv run macos-say-server --host 127.0.0.1 --port 2576

You can also run the package module directly:

uv run python -m macos_say_server --host 127.0.0.1 --port 2576

Build

uv build

Cache

The service stores generated audio under .cache/audio by default.

  • Cache key: hash of text + voice
  • Expiration: CACHE_TTL_SECONDS, default 86400 seconds
  • Cleanup: lazy cleanup during requests, at most once per CACHE_CLEANUP_INTERVAL_SECONDS, default 300 seconds
  • On cache hit, the file timestamp is refreshed, so TTL is sliding rather than fixed from first generation
  • Capacity control: optional LRU-style pruning using file modification time
  • File count limit: CACHE_MAX_FILES, default 0 meaning unlimited
  • Total size limit: CACHE_MAX_BYTES, default 0 meaning unlimited

When a cache limit is configured, the oldest entries are removed first. Because cache hits refresh the file timestamp, frequently used items stay warm and cold items are evicted first.

GET /cache/stats returns:

  • cache_dir and whether it currently exists
  • total_files and total_bytes
  • expired_files under the current TTL view
  • configured ttl_seconds, cleanup interval, and capacity limits
  • oldest and newest cache entry timestamps

Startup arguments:

uv run macos-say-server \
	--cache-dir .cache/audio \
	--cache-ttl-seconds 86400 \
	--cache-cleanup-interval-seconds 300 \
	--cache-max-files 0 \
	--cache-max-bytes 0

Examples

curl http://127.0.0.1:2576/health
curl http://127.0.0.1:2576/voices
curl http://127.0.0.1:2576/cache/stats
curl -G http://127.0.0.1:2576/speak --data-urlencode "text=hello from macos say server" --output speech.aiff
curl -i -G http://127.0.0.1:2576/speak --data-urlencode "text=hello from macos say server" --output speech.aiff
curl -X POST http://127.0.0.1:2576/speak \
	-H "content-type: application/json" \
	-d '{"text":"hello from json","voice":"Samantha"}' \
	--output speech.aiff

If you inspect response headers, X-Cache: MISS means the file was newly synthesized, and X-Cache: HIT means it was served from cache.

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

macos_say_server-0.1.0.tar.gz (123.9 kB view details)

Uploaded Source

Built Distribution

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

macos_say_server-0.1.0-py3-none-any.whl (7.2 kB view details)

Uploaded Python 3

File details

Details for the file macos_say_server-0.1.0.tar.gz.

File metadata

  • Download URL: macos_say_server-0.1.0.tar.gz
  • Upload date:
  • Size: 123.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","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 macos_say_server-0.1.0.tar.gz
Algorithm Hash digest
SHA256 fed8792c01ba45457a1d9a01de4e42ae4fcb599433bdd80a5bc5605f0dd5f1fc
MD5 fe3bcbbe47f92ac42e150b4ab9477964
BLAKE2b-256 b0544ce4961fee8e07df5d74a169061cae7a17731f09ad7c31622e190fb710b8

See more details on using hashes here.

File details

Details for the file macos_say_server-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: macos_say_server-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 7.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","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 macos_say_server-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 88061233eb91f2502e853716d073dd8f283b1f5a9f6041511f3eae9fae95b0a7
MD5 d318a3c895b5ee98585fd3571032679c
BLAKE2b-256 abecd293f913dfac01f875f5d7546fd5ea498f7ce5c0001f12b1e762bf17c987

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