Skip to main content

A Python wrapper for the Standard Transcription JSON (STJ) format.

Project description

STJLib

PyPI Build Status Documentation Status

A Python library for the Standard Transcription JSON (STJ) format.

Overview

STJLib provides data classes and utilities for working with STJ files, which are used to represent transcribed audio and video data in a structured, machine-readable JSON format.

For more information about the STJ format, please refer to the STJ Specification.

Documentation

Full documentation is available at stjlib.readthedocs.io. This includes:

  • Detailed API reference
  • Usage examples
  • Advanced usage guides
  • Contributing guidelines

Features

  • Full support for STJ format version 0.6.1
  • Comprehensive validation system with severity levels (ERROR, WARNING, INFO)
  • Time value precision handling with IEEE 754 round-to-nearest-even
  • Strict language code validation (ISO 639-1/639-3)
  • Support for zero-duration segments
  • Word timing modes (complete, partial, none)
  • Enhanced speaker and style validation
  • Extensions field validation with reserved namespace protection

Quick Start

Installation

pip install stjlib

Basic Usage

from stjlib import StandardTranscriptionJSON

# Load and validate an existing STJ file
stj = StandardTranscriptionJSON.from_file('path/to/file.stjson', validate=True)

# Or create a new STJ document
stj = StandardTranscriptionJSON(version="0.6.1")

# Add transcriber information
stj.metadata.transcriber = {
    "name": "TestTranscriber",
    "version": "1.0"
}

# Add a simple segment
segment = {
    "start": 0.0,
    "end": 2.0,
    "text": "Hello world"
}
stj.transcript.segments.append(segment)

# Save to file
stj.save('output.stjson')

# Access metadata and transcript data
print(stj.metadata)
print(stj.transcript)

For more examples and detailed usage instructions, please refer to our documentation.

File Format Support

STJLib supports the Standard Transcription JSON (STJ) format with the following file extensions:

  • Primary (Recommended): .stjson
  • Alternative: .stj
  • Alternative: .stj.json (systems supporting double extensions)

MIME Type: application/vnd.stj+json

Validation Features

  • Severity levels: ERROR, WARNING, INFO
  • Detailed location information in error messages
  • Time value precision validation
  • Language code validation (ISO 639-1/639-3)
  • Segment ordering and overlap validation
  • Speaker and style validation
  • URI format validation
  • Extensions validation with namespace protection

Development

Setting Up Development Environment

# Clone the repository
git clone https://github.com/yaniv-golan/stjlib.git
cd stjlib

# Install development dependencies
pip install -e .
pip install -r requirements-dev.txt

Running Tests

pytest

Releasing

Releases are automated via GitHub Actions and PyPI Trusted Publishing. See docs/internal/release-process.md for the exact steps (update changelog/version, tag vX.Y.Z, and push—CI handles the rest).

Building Documentation Locally

cd docs
make html

The documentation will be available in docs/build/html.

Contributing

We welcome contributions to stjlib! Please see our Contributing Guide for more details on how to get started.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Contact

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

stjlib-0.6.0.tar.gz (49.9 kB view details)

Uploaded Source

Built Distribution

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

stjlib-0.6.0-py3-none-any.whl (40.9 kB view details)

Uploaded Python 3

File details

Details for the file stjlib-0.6.0.tar.gz.

File metadata

  • Download URL: stjlib-0.6.0.tar.gz
  • Upload date:
  • Size: 49.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for stjlib-0.6.0.tar.gz
Algorithm Hash digest
SHA256 ade07ab573c82a4ab12199221041bd9378110d6552df12c55e4ca39d2c3f5f91
MD5 7ac2e6a554696816f0c6a6ecc9697fc8
BLAKE2b-256 5c612a5ce95de7799e158bb662985fa1028fcf470903c847a3f6f3d1b446c598

See more details on using hashes here.

Provenance

The following attestation bundles were made for stjlib-0.6.0.tar.gz:

Publisher: release.yml on yaniv-golan/stjlib

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file stjlib-0.6.0-py3-none-any.whl.

File metadata

  • Download URL: stjlib-0.6.0-py3-none-any.whl
  • Upload date:
  • Size: 40.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for stjlib-0.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 10c050b6072f4dfde7f7362d1ed59c5f0facac7cc6be7fd53fe9ed33113c114f
MD5 49b44f13292a574e2473ab6730dfbb50
BLAKE2b-256 cf2c34ed4a156d7b4c1764c78b77c03ff6435af14a13679d2c5ef3a55ba4f2ba

See more details on using hashes here.

Provenance

The following attestation bundles were made for stjlib-0.6.0-py3-none-any.whl:

Publisher: release.yml on yaniv-golan/stjlib

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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