Giter Site home page Giter Site logo

bbc / stt-align-node Goto Github PK

View Code? Open in Web Editor NEW
12.0 17.0 5.0 1.63 MB

node version of stt-align https://github.com/bbc/stt-align by Chris Baume - R&D.

Home Page: https://bbc.github.io/stt-align-node

License: MIT License

JavaScript 100.00%
newslabs labs news-labs stt alignement re-alignement

stt-align-node's Introduction

Stt-align-node

See The alignment problem in the docs for more background of the problem this module set out to address.

Originally developed as a node version of python's stt-align by Chris Baume - BBC R&D.

Setup - development

git clone [email protected]:bbc/stt-align-node.git
cd stt-align-node
npm install

Setup - in production

npm install @bbc/stt-align-node

Usage

Other then to realign STT results with accurate text, this modules can also be used to perform related oprations in the same domain, such as benchmarking STT.

Function Description type
alignSTT Realign STT json with accurate text. by transposing words from accurate text to timecodes of STT. json
diffsList return a diff json of STT vs accurate text json
diffsListAsHtml return a diff of STT vs accurate text as HTML html
diffsCount return a diff of STT vs accurate text as HTML json
calculateWordDuration return a diff of STT vs accurate text as HTML Number

See See README in example-usage folder as well as code examples for more.


System Architecture

Node version of stt-align by Chris Baume - R&D.

In pseudo code overview of alignSTT:

  • input, output as described in the example usage.

    • Accurate base text transcription, string.
    • Array of word objects transcription from STT service.
  • Align words

    • normalize words, by removing capitalization and punctuation and converting numbers to letters

    • generate array list of words from base text, and array list of words from stt transcript.

      • get opcodes using difflib comparing two arrays
      • for equal matches, add matched STT word objects segment to results array base text index position.
      • Then iterate to result array to replace STT word objects text with words from base text
    • interpolate missing words

      • calculates missing timecodes
      • first optimization
        • using neighboring words to do a first pass at setting missing start and end time when present
      • Then Missing word timings are interpolated using interpolation library 'everpolate.

Development env

  • node 10
  • npm 6.1.0

Build

npm run build

bundles the code with react, into a ./build folder.

build demo

npm run build:demo

Demo is in docs folder

Publish demo to github pages

npm run deploy:ghpages

Tests

npm run test:watch
  • add more tests

Deployment

Deploy to npm

npm run publish:public

stt-align-node's People

Contributors

dependabot[bot] avatar laurian avatar niklasr avatar pietrop avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

stt-align-node's Issues

README and examples issues

A good list of things to sort out in the README and rest of the repo by @gridinoc

  • 1. const alignJSONText = require('./index.js'); -> no index.js, if you require src/index.js still dies as there is no function exported by default
  • 2. "See /lib/example-usage for an example that you can run with npm run example." there is no /lib
  • 3. babel-loader and gh-pages should be devDependencies
  • 4. the demo is useless, I get a page asking for files I don't have
  • 5. package.json: "main": "lib/index.js", well, no /lib again

Leaving it as a note for when I get a chance to do a PR

first and last words don't have timings issue - edge case

possible fix via @Laurian

basically I pad the word array to be sure the 1st and last word has timing, otherwise it will extrapolate timing on words that lack timing and are on the edge, getting by that timings outside the paragraph boundaries (even negative timings on 1st paragraph)

words = [
      {
        text: 'STARTSTART',
        start: words[0].start - (0.08475 + 0.05379 * 'STARTSTART'.length),
        end: words[0].start,
      },
      ...words,
      {
        text: 'ENDEND',
        start: words[words.length - 1].end,
        end: words[words.length - 1].end + 0.08475 + 0.05379 * 'ENDEND'.length,
      },
    ];

    const resultAligned = alignSTT(
      {
        words,
      },
      `STARTSTART ${text} ENDEND`
    );

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.