Skip to main content

Export validated JSON to standard formats.

Project description

Dorsal

Export validated JSON to standard formats.

PyPI version codecov License

Dorsal Adapters translates validated JSON records into various industry-standard formats.

Installation

Dorsal Adapters is available on pypi as dorsalhub-adapters:

pip install dorsalhub-adapters

Usage

Adapters are strictly typed, pure Python classes with four exposed methods:

  • export(record) / export_file(record, fp): Converts a JSON record into a standard format e.g. audio-transcription -> .srt
  • parse(content) / parse_file(fp): Best effort conversion from a standard format to JSON Record, e.g. .srt -> audio-transcription

In both cases, the JSON is Open Validation Schemas-compliant.

Example: Two-Way Audio Conversion

In this example, a valid open/audio-transcription record is converted to SubRip Text (.srt) format.

from dorsal_adapters.registry import get_adapter

# 1. The record we want to convert.
dorsal_record = {
    "track_id": 1,
    "language": "eng",
    "segments": [
        {
            "start_time": 0.5,
            "end_time": 4.75,
            "text": "Welcome back! Today, my guest is the renowned chef, Jean-Pierre."
        }
    ]
}

# 2. Retrieve the adapter for the schema and target format
adapter = get_adapter("audio-transcription", "srt")

# 3. Export to the target format (.srt)
srt_string = adapter.export(dorsal_record)
print(srt_string)

# 4. Parse the formatted string back into a Dorsal record
parsed_record = adapter.parse(srt_string)

Tip: You can check what formats are supported for a given schema using list_formats:

from dorsal_adapters.registry import list_formats

print(list_formats("audio-transcription"))

Supported Formats

Dorsal Adapters supports two-way conversion (exporting and parsing) between schema-validated JSON records and the following formats:

Audio Transcription (via open/audio-transcription)

  • srt: SubRip Subtitle format
  • vtt: WebVTT format - W3C standard web subtitle format
  • md: Markdown format - A markdown-formatted audio transcription optimized for RAG
  • txt: Plain Text format
  • tsv: Tab-Separated Values format

Contributing

We welcome contributions! If you have written a translation script for an Open Validation Schema that maps to a widely used industry standard, please open a PR.

See CONTRIBUTING.md for our development setup using uv and our strict typing guidelines.

License

Dorsal Adapters is open source and provided under the Apache 2.0 license.

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

dorsalhub_adapters-0.1.0.tar.gz (1.3 MB view details)

Uploaded Source

Built Distribution

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

dorsalhub_adapters-0.1.0-py3-none-any.whl (18.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: dorsalhub_adapters-0.1.0.tar.gz
  • Upload date:
  • Size: 1.3 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.4 {"installer":{"name":"uv","version":"0.10.4","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":null}

File hashes

Hashes for dorsalhub_adapters-0.1.0.tar.gz
Algorithm Hash digest
SHA256 d795b58ad1c4f6f8d681a070700e5e7a3c8a70828faed090a2abe90438925d0e
MD5 056ce3d46b440c598821622acefeed5e
BLAKE2b-256 eb6ed14e55400ae86835c4dc9fb0e70bdbea7f8431ae04e5e29bf3049d773c81

See more details on using hashes here.

File details

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

File metadata

  • Download URL: dorsalhub_adapters-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 18.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.4 {"installer":{"name":"uv","version":"0.10.4","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":null}

File hashes

Hashes for dorsalhub_adapters-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 02d51e30f742986928376415e6661d50b315e873a5f9ea48887da2bf62bffe23
MD5 a737f427025adf4a6e42bb42916c364e
BLAKE2b-256 c8fda8ed9fd36d002da2687494e1b689347f0c15234bc70366d2a1489c48781c

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