Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@bbc/stt-align-node

Package Overview
Dependencies
Maintainers
17
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@bbc/stt-align-node - npm Package Compare versions

Comparing version 1.4.1 to 1.4.3

16

align/index.js

@@ -75,3 +75,3 @@ "use strict";

function interpolate(wordsList) {
function interpolate(wordsList, start, end) {
var words = interpolationOptimization(wordsList);

@@ -91,2 +91,7 @@

}
}
if (start && indiciesWithStart[0] !== 0) {
indiciesWithStart = [0].concat(_toConsumableArray(indiciesWithStart));
startTimes = [start].concat(_toConsumableArray(startTimes));
} // interpolate times for end

@@ -100,2 +105,7 @@

}
}
if (end && indiciesWithEnd[indiciesWithEnd.length - 1] !== indicies[indicies.length - 1]) {
indiciesWithEnd.push(indicies[indicies.length - 1]);
endTimes.push(end);
} // http://borischumichev.github.io/everpolate/#linear

@@ -120,3 +130,3 @@

function alignRefTextWithSTT(opCodes, sttWords, transcriptWords) {
function alignRefTextWithSTT(opCodes, sttWords, transcriptWords, start, end) {
// # create empty list to receive data

@@ -147,5 +157,5 @@ // transcriptData = [{} for _ in range(len(transcriptWords))]

return interpolate(transcriptData);
return interpolate(transcriptData, start, end);
}
module.exports = alignRefTextWithSTT;

55

index.js
"use strict";
var difflib = require('difflib');
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }
var normaliseWord = require('./normalise-word/index.js');
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); }
var countDiffs = require('./count-diffs/index.js');
function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); }
var getDiffsList = require('./diffs-list/index.js');
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } }
var alignRefTextWithSTT = require('./align/index.js');
var difflib = require("difflib");
var calculateWordDuration = require('./calculate-word-duration/index.js');
var normaliseWord = require("./normalise-word/index.js");
var diffsListToHtml = require('./diffs-list-to-html/index.js').diffsListToHtml;
var countDiffs = require("./count-diffs/index.js");
var getDiffsList = require("./diffs-list/index.js");
var alignRefTextWithSTT = require("./align/index.js");
var calculateWordDuration = require("./calculate-word-duration/index.js");
var diffsListToHtml = require("./diffs-list-to-html/index.js").diffsListToHtml;
/**
*
*
* @param {array} sttData - array of STT words

@@ -40,3 +48,3 @@ * @param {array} transcriptWords - array of base text accurate words

function removeNewLinesFromRefText(refText) {
return refText.trim().replace(/\n\n/g, ' ').replace(/\n/g, ' ');
return refText.trim().replace(/\n\n/g, " ").replace(/\n/g, " ");
}

@@ -46,7 +54,7 @@

var transcriptTextWithoutLineBreaks = removeNewLinesFromRefText(refText);
var transcriptTextArray = transcriptTextWithoutLineBreaks.split(' ');
var transcriptTextArray = transcriptTextWithoutLineBreaks.split(" ");
return transcriptTextArray;
}
/**
*
*
* @param {json} sttWords - stt transcript json

@@ -91,12 +99,33 @@ * @param {array} sttWords.words

function alignSTT(sttWords, transcriptText) {
function alignSTT(sttWords, transcriptText, start, end) {
var sttWordsList = sttWords.words;
var opCodes = diff(sttWordsList, transcriptText);
var transcriptWords = convertRefTextToList(transcriptText);
var alignedResults = alignRefTextWithSTT(opCodes, sttWordsList, transcriptWords);
var alignedResults = alignRefTextWithSTT(opCodes, sttWordsList, transcriptWords, start, end);
return alignedResults;
}
function alignSTTwithPadding(sttWords, transcriptText, start, end, padLeft, padRight) {
var PADLEFT = padLeft ? padLeft : "Nwxskfsxn HHLPdJNbX KRrdghXzJ";
var PADRIGHT = padRight ? padRight : "XxjzKsmwK pHcdxnFch LmLXFdCVr";
return alignSTT({
words: [].concat(_toConsumableArray(PADLEFT.split(" ").map(function (text) {
return {
start: start,
end: start,
text: text
};
})), _toConsumableArray(sttWords.words), _toConsumableArray(PADRIGHT.split(" ").map(function (text) {
return {
start: end,
end: end,
text: text
};
})))
}, "".concat(PADLEFT, " ").concat(transcriptText, " ").concat(PADRIGHT), start, end).slice(PADLEFT.split(" ").length, -PADRIGHT.split(" ").length);
}
module.exports = alignSTT;
module.exports.alignSTT = alignSTT;
module.exports.alignSTTwithPadding = alignSTTwithPadding;
module.exports.diffsList = diffsList;

@@ -103,0 +132,0 @@ module.exports.diffsCount = diffsCount;

{
"name": "@bbc/stt-align-node",
"version": "1.4.1",
"version": "1.4.3",
"description": "",
"main": "index.js",
"main": "lib/index.js",
"scripts": {

@@ -10,19 +10,21 @@ "start": "node lib/index.js",

"test:watch": "jest --watchAll",
"example": "node lib/example-usage.js",
"example": "node example-usage/example-usage-align-stt.js",
"build": "babel src -d build",
"build:lib": "webpack --config ./webpack.config.lib.js --mode production",
"build:demo": "webpack --mode production",
"publish:public": "npm run build && /bin/cp -rf package.json build/ && /bin/cp -rf README.md build/README.md && npm publish build --access public",
"publish:dry:run": "npm publish --dry-run",
"publish:dry:run": "npm run build && /bin/cp -rf package.json build/ && /bin/cp -rf README.md build/README.md && npm publish build --dry-run --access public",
"deploy:ghpages": "npm run build:demo && gh-pages -d demo"
},
"author": "",
"license": "ISC",
"license": "MIT",
"devDependencies": {
"@babel/cli": "^7.2.0",
"@babel/core": "^7.2.0",
"@babel/node": "^7.2.0",
"@babel/preset-env": "^7.5.5",
"@babel/cli": "^7.7.7",
"@babel/core": "^7.7.7",
"@babel/node": "^7.7.7",
"@babel/preset-env": "^7.7.7",
"jest": "^25.0.0",
"webpack": "^4.39.1",
"webpack-cli": "^3.3.6"
"gh-pages": "^2.2.0",
"webpack": "^4.41.5",
"webpack-cli": "^3.3.10"
},

@@ -33,5 +35,4 @@ "dependencies": {

"everpolate": "0.0.3",
"gh-pages": "^2.0.1",
"number-to-words": "^1.2.4"
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc