File tree 1 file changed +7
-9
lines changed
packages/export-adapters/subtitles-generator
1 file changed +7
-9
lines changed Original file line number Diff line number Diff line change @@ -21,27 +21,25 @@ function segmentedTextToList(text) {
21
21
return result ;
22
22
}
23
23
24
- function countWords ( text ) {
24
+ function countEndWordPosition ( text ) {
25
25
return text
26
26
. trim ( )
27
27
. replace ( / \n / g, '' )
28
28
. replace ( / \n / g, ' ' )
29
- . split ( ' ' ) . length ;
30
- }
31
-
32
- function countList ( list ) {
33
- return list . length - 1 ;
29
+ . split ( ' ' ) . length - 1 ;
34
30
}
35
31
36
32
function addTimecodesToLines ( wordsList , lines ) {
37
33
let startWordCounter = 0 ;
38
34
let endWordCounter = 0 ;
39
35
const results = lines . map ( ( line ) => {
40
- endWordCounter += countWords ( line ) ;
36
+ endWordCounter += countEndWordPosition ( line ) ;
41
37
const jsonLine = { text : line . trim ( ) } ;
38
+
42
39
jsonLine . start = wordsList [ startWordCounter ] . start ;
43
- jsonLine . end = wordsList [ endWordCounter - 1 ] . end ;
44
- startWordCounter = endWordCounter ;
40
+ jsonLine . end = wordsList [ endWordCounter ] . end ;
41
+
42
+ startWordCounter = endWordCounter + 1 ;
45
43
46
44
return jsonLine ;
47
45
} ) ;
You can’t perform that action at this time.
0 commit comments