Download the PHP package mokhosh/laravel-caption without Composer
On this page you can find all versions of the php package mokhosh/laravel-caption. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download mokhosh/laravel-caption
More information about mokhosh/laravel-caption
Files in mokhosh/laravel-caption
Package laravel-caption
Short Description Work with SRT files and YouTube XML subtitles in Laravel
License MIT
Homepage https://github.com/mokhosh/laravel-caption
Informations about the package laravel-caption
Work with SRT files and YouTube XML subtitles in Laravel
You can parse xml timecodes into line by line representation of the caption, and then generate srt files based on the parsed caption.
Installation
You can install the package via composer:
Concepts
Caption
has a Collection
of Line
s, to which you can add()
a new Line
.
You can also get all lines()
of a Caption
.
Each line is a readonly value object consisting of a float start
, a float duration
, and a text
.
You can also use TimecodeConverter
's floatToTimecode()
to convert floating seconds/miliseconds values to formatted timecode.
Usage
Let's say you need to read subtitles in any custom format and generate SRT subtitles based on its contents.
Here's how we convert an OpenAI transcription Json to an STR file:
Or you can use the facade to load a json file containing an OpenAI response:
You can simply convert a YouTube xml timecode file to a srt subtitle file like so:
If you need to chunk your xml into smaller srt files, do this:
If you need more control you can do this:
And for chunking:
Testing
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Credits
- Mo Khosh
- All Contributors
License
The MIT License (MIT). Please see License File for more information.
All versions of laravel-caption with dependencies
ext-simplexml Version *
spatie/laravel-package-tools Version ^1.14.0
illuminate/contracts Version ^10.0|^11.0