ttml-to-json

Convert TTML to JSON

APACHE-2.0 License

Downloads
65
Stars
5
Committers
2

ttml-to-json

Convert TTML to JSON

Installation

Install this tool using pip:

pip install ttml-to-json

Usage

To output JSON for a TTML file:

ttml-to-json subtitles.ttml

This will output to standard output. Use -o filename to send it to a specified file.

Use -s or --single to output single "line" keys instead of a "lines" array.

You can also use:

python -m ttml_to_json ...

Output

Regular output:

[
    {
        "start": "00:00:00.000",
        "end": "00:00:04.560",
        "lines": ["my career in side projects and open"]
    }
]

-s or --single output:

[
    {
        "start": "00:00:00.000",
        "end": "00:00:04.560",
        "line": "my career in side projects and open"
    }
]

Development

To contribute to this tool, first checkout the code. Then create a new virtual environment:

cd ttml-to-json
python -m venv venv
source venv/bin/activate

Now install the dependencies and test dependencies:

pip install -e '.[test]'

To run the tests:

pytest