0.1.4 • Published 4 years ago

temi-transcript-model v0.1.4

Weekly downloads
-
License
ISC
Repository
github
Last release
4 years ago

temi-transcript-model

JSON schema and JavaScript model classes for dealing with time-aligned transcripts of speech.

Usage

Install in your project

$ npm i temi-transcript-model

Then

const { Transcript } = require('transcript-model');

// Define some transcript JSON
const json = {
  speakers: [{ name: 'John' }, { name: 'Mary' }],
  monologues: [
    {
      speaker: 0,
      elements: [
        { type: 'text', value: 'Hello', ts: 0.05, end_ts: 0.64 },
        { type: 'text', value: 'Mary!', ts: 0.7, end_ts: 1.1 }
      ]
    },
    {
      speaker: 1,
      elements: [
        { type: 'text', value: 'Hi', ts: 1.53, end_ts: 1.88 },
        { type: 'text', value: 'John.', ts: 1.92, end_ts: 2.33 }
      ]
    },
  ],
};

// Instantiate a Transcript object
const transcript = Transcript.fromJson(json);

// Do something with it
console.log(
  transcript.monologues
    .map(
      (monologue) => `${transcript.speakers.get(monologue.speaker).name}: ${monologue.elements
        .map((element) => element.text)
        .join(' ')}`
    )
    .join('\n')
);

// Serialise as JSON
console.log(transcript.toJson());

Author

0.1.4

4 years ago

0.1.3

4 years ago

0.1.2

4 years ago

0.1.1

4 years ago

0.1.0

4 years ago