Skip to main content

SSML-H Tools

ssml-h-tools is the reference Python parser, validator, and builder for SSML-H 1.0. It also supports a bounded subset of standard W3C SSML 1.1.

The package is engine-neutral. It compiles markup into immutable synthesis plans and leaves model inference, voice catalogs, profile storage, audio assembly, and authorization to the integrating speech engine.

Install

pip install ssml-h-tools

Python 3.10 or newer is required.

Validate and compile

from ssml_h import validate_ssml

plan = validate_ssml(
    """<speak version="1.1" xmlns="http://www.w3.org/2001/10/synthesis">
      Hello.<break time="250ms"/>Welcome back.
    </speak>""",
    "ssml",
)

for unit in plan.units:
    print(unit.kind, unit.text, unit.duration_ms)

Language and voice resolution are supplied by the host application:

plan = validate_ssml(
    document,
    "ssml-h",
    default_language="en",
    resolve_language=my_language_resolver,
    validate_voice=my_voice_validator,
)

The parser rejects DTDs, entities, external references, unknown synthesis namespaces, unsupported elements, and documents exceeding bounded resource limits before model inference begins.

Build documents

from ssml_h import SSMLBuilder

document = SSMLBuilder.ssml_h(language="en-US")
document.define_voice(
    "Bob",
    gender="male",
    age="elderly",
    accent="american",
    seed=4242,
    sample="My name is Bob.",
    sample_language="en-US",
)

with document.voice("Bob") as bob:
    bob.text("Are we ready?")
with document.voice("Bob", direction="Calm and reassuring") as bob:
    bob.text("Everything is under control.")
document.break_(milliseconds=300)
with document.prosody(rate="slow") as slower:
    slower.text("Everything is prepared.")

xml = document.build()
plan = document.validate(allow_turn_direction=True)

XML is built with ElementTree; text and attributes are escaped rather than concatenated. scope="profile" must be requested explicitly when defining a persistent voice.

Per-turn natural-language direction is an optional processor capability. The parser rejects h:direction unless the host explicitly passes allow_turn_direction=True; compiled speech units then expose the normalized instruction as unit.direction. The builder emits the namespaced attribute through voice(..., direction="...") for named voices or sentence(direction="...") for the default voice, only in SSML-H documents.

Processor adapters

<phoneme> is disabled unless the host supplies a render_phoneme callback. This prevents the core package from claiming an alphabet that the active model cannot render. The callback receives (alphabet, ph, source_text, language) and returns the text representation expected by the engine.

The host remains responsible for:

  • mapping BCP 47 tags to model languages;
  • validating saved or built-in voice names;
  • advertising its actual capabilities;
  • creating and cleaning request-scoped voices;
  • atomically publishing persistent profiles; and
  • executing advertised per-turn directions without speaking or persisting the instruction; and
  • enforcing model, queue, duration, and output limits.

Development

python -m venv .venv
.venv/bin/python -m pip install -e ".[test]"
.venv/bin/python -m unittest discover -s tests -v
python -m build
python -m twine check dist/*

On Windows, use .venv\Scripts\python.exe.

Release

Releases are published from GitHub Releases through PyPI Trusted Publishing. No long-lived PyPI token is stored in GitHub. See the publishing guide.

License

The tools are licensed under the Apache License 2.0. The SSML-H specification is maintained separately in hangry-labs/ssml-h-spec.

Metadata

Release files for ssml-h-tools 0.3.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ssml-h-tools 0.3.1
File Size Uploaded
ssml_h_tools-0.3.1.tar.gz 23.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for ssml-h-tools 0.3.1
File Interpreter ABI Platform
ssml_h_tools-0.3.1-py3-none-any.whl Python 3 none any Details

Total release size: 42.6 kB

Release files / ssml_h_tools-0.3.1.tar.gz

Download URL ssml_h_tools-0.3.1.tar.gz
Size 23.8 kB
Tags Source
SHA-256 checksum
How to use checksums
df869dafc6abe176f12c53e05a2a838d92ad033ab4d572d73409b924781e8921
BLAKE2b-256 checksum
How to use checksums
f331d503b752ffe56a36ee54a24a6c2eb204aa13b136a206e615d91a089611d3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 10, 2026.

Transparency log

Release files / ssml_h_tools-0.3.1-py3-none-any.whl

Download URL ssml_h_tools-0.3.1-py3-none-any.whl
Size 18.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c080652629e6ef1898c564f61edd0982fdfeacbb88bef82a43bbaca45031946f
BLAKE2b-256 checksum
How to use checksums
8fd75e56b2a3f73f7df80ac28893f483e7d9be9fe85430a9b8bc55b1ccb1f4d0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 10, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.3.1 This release

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page