vtt-to-text

Converts vtt captions to plain text

Usage no npm install needed!

<script type="module">
  import vttToText from 'https://cdn.skypack.dev/vtt-to-text';
</script>

README

vtt-to-text

A module to convert vtt (WebVTT) to plain text.

Installation

npm i -S vtt-to-text
# or use yarn
yarn add vtt-to-text

Example

Input:

captions:  WEBVTT
Kind: captions
Language: en

00:00:00.160 --> 00:00:03.270 align:start position:0%
 
all<00:00:00.240><c> right</c><00:00:00.640><c> last</c><00:00:01.599><c> apple</c><00:00:02.159><c> story</c><00:00:02.560><c> of</c><00:00:02.639><c> the</c><00:00:02.800><c> day</c>

00:00:03.270 --> 00:00:03.280 align:start position:0%
all right last apple story of the day

Output:

all right last apple story of the day

Usage

const {vttToPlainText} = require("vtt-to-text")

const captionVtt1 = `
captions:  WEBVTT
Kind: captions
Language: en

00:00:00.160 --> 00:00:03.270 align:start position:0%
all<00:00:00.240><c> right</c><00:00:00.640><c> last</c><00:00:01.599><c> apple</c><00:00:02.159><c> story</c><00:00:02.560><c> of</c><00:00:02.639><c> the</c><00:00:02.800><c> day</c>
`

let a = vttToPlainText(captionVtt1);
console.log(a);