-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathexample-usage-with-padding.js
79 lines (71 loc) · 1.51 KB
/
example-usage-with-padding.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
// const alignSTT = require('@bbc/stt-align-node').alignSTT;
const alignSTT = require("../src/index.js").alignSTT;
const alignSTTwithPadding = require("../src/index.js").alignSTTwithPadding;
const transcriptText = "friend to hold";
const transcriptSttTest = {
words: [
{
start: 16.27,
end: 16.65,
text: "friend",
},
{
text: "2",
},
{
start: 16.74,
end: 17.2,
text: "held",
},
],
};
// this freezes:
// const result = alignSTT(transcriptSttTest, transcriptText, 16.19, 17.2);
// const start = 16.19;
// const end = 17.2;
// const PADLEFT = "Nwxskfsxn HHLPdJNbX KRrdghXzJ";
// const PADRIGHT = "XxjzKsmwK pHcdxnFch LmLXFdCVr";
// const result = alignSTT(
// {
// words: [
// ...PADLEFT.split(" ").map((text) => ({ start, end: start, text })),
// ...transcriptSttTest.words,
// ...PADRIGHT.split(" ").map((text) => ({ start: end, end, text })),
// ],
// },
// `${PADLEFT} ${transcriptText} ${PADRIGHT}`,
// start,
// end
// );
// console.log(JSON.stringify(result, null, 2));
// console.log(
// JSON.stringify(
// result.slice(PADLEFT.split(" ").length, -PADRIGHT.split(" ").length),
// null,
// 2
// )
// );
const result2 = alignSTTwithPadding(
transcriptSttTest,
transcriptText,
16.19,
17.2
);
console.log(JSON.stringify(result2, null, 2));
/* original timings
{
"start": 16.27,
"end": 16.65,
"text": "friend"
},
{
"start": 16.65,
"end": 16.74,
"text": "to"
},
{
"start": 16.74,
"end": 17.2,
"text": "hold"
},
*/