-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathconverter.html
631 lines (504 loc) · 27.2 KB
/
converter.html
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
---
layout: default
---
<!doctype html>
<!-- Single web page implementation of a VTT Transcript Converter -->
<html>
<head>
<title>Teams and Zoom Transcript Converter for NVivo</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- ****************************************** Stylesheet *********************************************** -->
<style>
footer, #wordsDeleted {
font-style: italic;
}
#interactions {
line-height: 2.5;
}
#unitTestResult {
color:red;
}
</style>
<!-- ****************************************** Javascript Implementation of Conversion **************************************** -->
<script src="https://unpkg.com/pizzip@3.1.1/dist/pizzip.js"></script>
<script src="https://unpkg.com/pizzip@3.1.1/dist/pizzip-utils.js"></script>
<script type="text/javascript">
/* See unit tests below for examples of different formats.
This depends heavily on Regex: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions
Use https://regex101.com/ to test regexes, and the Chrome debugger to capture intermediate values in the unit tests.
*/
var AllWordsDeleted={};
function convertVttToNvivo( input, source ) {
// Converts the input (string, vtt format) to NVivo transcript txt format
// If source is 'OneDrive', converts as OneDrive, otherwise Teams or Zoom.
// Remove unwanted crud.
const afterInitialCleaning=(input
.replace(/(\r\n|\n\r|\r)/g, '\n') // Change line endings to be internal format
.replace( /[a-f0-9]+-[a-f0-9]+-[a-f0-9]+-[a-f0-9]*-.*?\n/g,"") // Weird MS Streams and OneDrive ID lines go.
.replace(/.[-0-9]* --> [0-9]*:[0-9]*:[0-9]*.[0-9]*/g," ") // All but the start of each timestamp line goes.
.replace(/NOTE .*?\n/g,"") // Removes notes.
.replace(/WEBVTT/,"") // Nulls out intro line.
);
// Now convert to tab separated. Depends on source selected by user:
const tabSeparated =(source==='Teams') ?
// Source is Old Teams or Zoom:
(afterInitialCleaning
// Teams: Single line follows each timestamp. Text in <v> tags with speaker in opening tag.
.replace(/(?<time>\d\d?:\d\d?:-?\d\d?)\s*?\n<v (?<speaker>.*?)>(?<text>.*?)<\/v>\n/g, "$<time>\t$<speaker>\t$<text>" )
// Zoom: Each entry is three lines: number, timestamp, then speaker: text
.replace(/\d*?\n(?<time>\d\d:\d\d:\d\d)\s*?\n(?<speaker>.*?): (?<text>.*?)\n/g, "$<time>\t$<speaker>\t$<text>" )
// Occasionally Zoom doesn't put in a speaker. Put in as blank, and rely on NVivo 'fill down' or the concatenation below.
.replace(/\d*?\n(?<time>\d\d:\d\d:\d\d)\s*?\n(?<text>.*?)\n/g, "$<time>\t\t$<text>" )
) :
// Source is New Teams or OneDrive:
(afterInitialCleaning
// OneDrive: 1-2 lines follow each timestamp. No speaker. Occasionally just empty line.
// Empty line appears here as a single timestamp line with two crs after. Kill it.
.replace(/\n\d\d:\d\d:\d\d\s*\n\s*\n/g, "\n")
// Now take the timestamp and the first line.
// (Note - there's a javascript regex bug somewhere in matching null values for the text field here - so we removed null lines in the previous step)
.replace(/\n(?<time>\d\d:\d\d:\d\d)\s*\n(?<text>(?!\d\d:\d\d:\d\d\t?).*)/g, "$<time>\t\t$<text>" )
// Compose the pairs of lines. Any non-timestamp line is the second of the pair:
.replace(/(?<line1>\d\d:\d\d:\d\d\t\t.*)\n(?<line2>(?!\d\d:\d\d:\d\d\t?)\S.*)/g, "$<line1> $<line2>" )
);
// Take out initial blank lines, and replace with column headings:
return tabSeparated.replace(/^\n*/, "Timespan\tSpeaker\tContent\n")
}
function fixNvivoTranscript( asTabSeparated, timeshift, deleteShort ){
/* Fixes the NVivo transcript,
Adds timeshift (integer) seconds to each timestamp
If deleteShort, then removes short phrases.
*/
AllWordsDeleted={};
var latestTimestamp=timeshift; // Earliest timestamp will be that.
var currentTimestampIncrement=0;
// And then work on the tab-separated lines, adding headings, concatenating multiple lines, removing short lines, adjusting timestamps.
return (asTabSeparated
/* Now look for short interjections (12 chars or less) and remove them, even where there are several in sequence: */
.replace(/(?<time>(?:-?\d\d?:)?\d\d?:\d\d)\t(?<speaker>.*?)\t(?<text>([\S ]{0,12})(---[\S ]{0,12})*?)\n/g, (s) => {
if (deleteShort) {
wordsDeleted( s );
return "";
}
return s;
})
/* Now it gets complicated. We have:
00:00:00 Fred I'm sorry if cat meows
00:00:06 Fred Uh.
And we want:
00:00:00 Fred I'm sorry if cat meows---Uh.
So we do a search that looks for the duplicated name using \k<groupName>.
We also do the same if the second speaker name is blank (Zoom special, or just no speakers).
To handle more than 2 in a row, we repeat it. We could do that until no more matches are found, but actually we probably want timestamps
every minute or so, so do it three times to get up to 8 items concatenated. */
.replace(/(?<time>\d\d?:\d\d?:-?\d\d?)\t(?<speaker>.*?)\t(?<text>.*?)\n\d\d?:\d\d?:-?\d\d?\t(\k<speaker>|)\t/g,
"$<time>\t$<speaker>\t$<text>---")
.replace(/(?<time>\d\d?:\d\d?:-?\d\d?)\t(?<speaker>.*?)\t(?<text>.*?)\n\d\d?:\d\d?:-?\d\d?\t(\k<speaker>|)\t/g,
"$<time>\t$<speaker>\t$<text>---")
.replace(/(?<time>\d\d?:\d\d?:-?\d\d?)\t(?<speaker>.*?)\t(?<text>.*?)\n\d\d?:\d\d?:-?\d\d?\t(\k<speaker>|)\t/g,
"$<time>\t$<speaker>\t$<text>---")
// And shift all the timestamps, checking for monotonicly increasing timestamps. If we don't find them, we use the previous timestamp,
// and add .1, .2 etc., until the timestamp does increase.
.replace(/(?:\d\d?:)?\d\d?:-?\d\d?\t/g, (e) => { //todo add \n
let seconds = parseHMS(e);
seconds += timeshift;
seconds=Math.max(seconds,latestTimestamp);
currentTimestampIncrement=(seconds<=latestTimestamp) ? currentTimestampIncrement+1 : 0;
latestTimestamp=seconds;
let timestamp = seconds < 0 ? "--:--:--" : // Mark negative timestamps for removal.
// ~~ forces integer arithmetic. PadStart zero-pads the string:
(~~(seconds / 3600)).toString().padStart(2,'0') + ':' +
(~~((seconds % 3600) / 60)).toString().padStart(2,'0') + ':' +
(seconds % 60).toString().padStart(2,'0')
+ (currentTimestampIncrement > 0 ? '.'+currentTimestampIncrement.toString() : '');
return timestamp + '\t';
})
// Remove items with negative timestamps:
.replace(/--:--:--\t.*\n/g,"")
);
}
function wordsDeleted(s) {
// Remembers the words from line s that will be removed.
// Split the text element of the line into words, ignoring anything that's not alphanumeric. Filter out null strings.
for (const i of s.split('\t')[2].split(/\W+/).filter( s => s)) {
AllWordsDeleted[i.toLowerCase()] = true;
}
}
function parseHMS( hmsString ) {
// Parses a signed hour:minute:seconds string. E.g. -1:1:1 or -224, returning seconds.
let hms=hmsString.split(':');
let firstNumber=Math.abs(parseInt(hms[0]));
let sign = hms[0].startsWith('-') ? -1: 1;
return sign * (
(hms.length == 3) ? firstNumber * 3600 + parseInt(hms[1]) * 60 + parseInt(hms[2]):
(hms.length == 2) ? firstNumber * 60 + parseInt(hms[1]) :
firstNumber);
}
function transcriptFromVtt( input, source, timeshift, deleteShort ) {
// Does the full conversion of a VTT file, including timeshift and deleting short entries.
const asTabSeparated = convertVttToNvivo( input, source );
//console.log(asTabSeparated);
return fixNvivoTranscript( asTabSeparated, timeshift, deleteShort )
}
// ****************************************** Parsing DOCX files ****************************************
// First 3 paras are "Transcript\n 13 March 2024\nXXX started transcription\n
// So we ignore all short paragraphs.
function transcriptLineFromDocxPara(para) {
// Answers the NVivo transcript line from the given <w:p> document element.
// Else empty string if it is too short for a transcript line.
const textsXml = Array.from(para.querySelectorAll("t, br"));
// Gives w:br, w:t (Speaker), w:t (Timestamp), w:br
// Followed by content w:t and w:br elements.
// Want Timestamp\tSpeaker\tContent---Content Content...
return (textsXml.length < 5) ? "" : // Ignore short lines
textsXml[2].textContent + "\t" // Timestamp
+ textsXml[1].textContent + "\t" // Speaker
+ textsXml.slice(4).map( // Content
node => node.tagName.includes("br")
? "---" : node.textContent + " ")
.join('')
.trimEnd() // Don't want last space.
+ "\n";
}
function transcriptFromDocx(content) {
// Answers the NVivo transcript from the given Docx content as a binary string.
// A Docx file is a zipped archive containing several files, but the one that matters
// is 'word/document.xml', an xml file which contains paragraphs <w:p>,
// each containing text <w:t> and line end <w:br> elements.
// There was code to strip out an initial byte order mark(BOM). A BOM is a special marker
// at the beginning of a file that indicates the byte order of the text data in the file.
// .charCodeAt(0) === 65279 , but these files don't need that.
const zip = new PizZip(content);
const xml = new DOMParser().parseFromString(
zip.files["word/document.xml"].asText(),
"text/xml");
return "Timespan\tSpeaker\tContent\n"
+ Array.from(xml.getElementsByTagName("w:p"))
.map(transcriptLineFromDocxPara)
.join("");
}
// ****************************************** Javascript User Interface ****************************************
var ChosenFileBlob;
function onFileChosen(event){
// Called when the user chooses a file
var input = event.target;
ChosenFileBlob = input.files[0];
var inputFile = input.files[0].name;
document.getElementById("fileName").value = inputFile;
document.getElementById("timeshift").value="0";
refreshDisplay();
};
function provideResults( processedFileContents, downloadFilename ) {
// Called after conversion, to update the display and download the NVivo transcript
// Download filename should have extension .txt
document.getElementById("wordsDeleted").innerHTML = Object.keys(AllWordsDeleted).join(' '); // Safe, since all non-alphanum filtered out in WordsDeleted().
// Creates an invisible element that, on click, downloads the result as that file.
var element = document.createElement('a');
element.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(processedFileContents));
element.setAttribute('download', downloadFilename);
element.style.display = 'none';
document.body.appendChild(element);
// And clicks it:
element.click();
document.body.removeChild(element);
}
function onConvertAndDownloadClicked() {
// Called when the user clicks Convert and Download. Creates the processed file.
const filename = document.getElementById("fileName").value;
const timeshift = parseHMS(document.getElementById("timeshift").value);
const deleteShort = document.getElementById("deleteShort").checked;
const source = document.getElementById("source").value;
const reader = new FileReader();
var processedFileContents;
if (filename.match(/.docx$/i)) {
reader.onload = function() {
// reader.result is a base 64-encoded data URL
PizZipUtils.getBinaryContent(reader.result, (error, content) => {
if (error) alert( error );
const nvivoTranscript = transcriptFromDocx(content);
const processedTranscript = fixNvivoTranscript( nvivoTranscript, timeshift, deleteShort );
provideResults( processedTranscript, filename.replace(/.docx$/i, ".txt"))
});
}
reader.readAsDataURL(ChosenFileBlob);
} else {
reader.onload = function() {
processedFileContents = transcriptFromVtt( reader.result, source, timeshift, deleteShort );
provideResults( processedFileContents, filename.replace(/.vtt$/i, ".txt"))
};
reader.readAsText(ChosenFileBlob);
}
}
function refreshDisplay() {
// Disables the Convert and Download button if there's no input file or the timeshift is invalid.
document.getElementById("doConvert").disabled = !
(document.getElementById("timeshift").value.match( /^-?(\d+|\d+:\d+|\d+:\d+:\d+)$/ ) && // Empty, or 1, -1, 1:1:1, -1:1:1
document.getElementById("fileName").value.length != 0);
}
</script>
</head>
<!-- ****************************************** HTML body *********************************************** -->
<body >
<!-- Converter symbol in SVG -->
<h3><center>Transcript Converter</center></h3>
<div>
<p>This service converts a WebVtt or Word Docx transcript from Microsoft Teams or Zoom into NVivo's transcript input format. See <a href="index.html">our main page</a> for full instructions how to go from an automatically-transcribed Teams or Zoom call to coding the audio in NVivo in a couple of minutes. </p>
<div id="interactions" <p style="border-width:3px; border-style:solid; border-color:#FF0000; padding: 1em;border-radius: 25px;">
<form name="data">
<input type="file" id="myFile" size="50" accept=".vtt,.docx" onchange="onFileChosen(event)">
<input type="hidden" id="fileName" /><br/>
<label for="source">Select transcript source (if VTT):</label>
<select name="source" id="source">
<option value="Teams">Teams Meeting or Zoom</option>
<option value="OneDrive">Teams Solo or OneDrive</option>
</select><br/>
<label for="timeshift">Time shift:</label>
<input type="text" id="timeshift" name="timeshift" value=0 onChange="refreshDisplay()"><br/>
<label for="deleteShort">Filter out short phrases:</label>
<input type="checkbox" id="deleteShort" name="deleteShort" value=false><br/>
<input type="button" id="doConvert" onclick="onConvertAndDownloadClicked();" disabled value="Convert and Download"/>
</form>
</div>
<!-- Dummy textarea to hold the input file contents -->
<div id="inputDiv" style="display: none;">
<p>Input</p>
<textarea id="inputData" name="inputData" >
</textarea>
</div>
<p id='wordsDeletedIntro'>Words filtered: <span id="wordsDeleted"/></p>
<p id="unitTestResult" ></p>
<h3> Instructions </h3>
<p>Choose a file from your computer using Choose file. This should be either a text based file with a .vtt extension as downloaded from Teams or Zoom, or a Microsoft Word DOCX file from Microsoft Teams/Streams</p>
<p>See <a href="index.html">the main page</a> for full instructions.</p>
<p>You may want to enter a time shift value to add to each timestamp (e.g. -10, 1:2:1, or -0:3:4 ), and to filter out phrases of less than 10 characters.
Then click Convert and Download to create the converted .txt file</p>
</div>
<p> If you find a bug in the converter, or want to suggest an improvement, please report it in the <a href="https://github.com/SecurityEssentials/Teams2NVivo/issues">project issue tracker here</a>,
citing the browser used, the operating system, the issue, and (always, please) a sample of a VTT/DOCX file that causes the problem—edited if necessary to preserve privacy. </p>
<!-- Footer with copyright etc. -->
<footer id="footer">
<p>Copyright ©2024 Charles Weir <br/>
Portions Copyright ©2020 Tim Ellis</p>
<p>Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:</p>
<p>The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.</p>
<p>The software is provided "as is", without warranty of any kind, express or
implied, including but not limited to the warranties of merchantability,
fitness for a particular purpose and noninfringement. In no event shall the
authors or copyright holders be liable for any claim, damages or other
liability, whether in an action of contract, tort or otherwise, arising from,
out of or in connection with the software or the use or other dealings in the
software.
</p>
</div>
</div>
</footer>
</body>
<!-- ************************************ Unit Tests ****************************** -->
<script type="text/javascript">
// This script runs unit tests on page load, and displays an error message if they fail.
var testInput=`WEBVTT
NOTE Confidence: 0.648119294
53118acb-c442-4300-a3e9-4f29e5413f84
00:00:02.160 --> 00:00:06.560
Non-speaker captions from Microsoft Stream
NOTE New format from Microsoft teams as at 12/12/2022
b05cbc69-3364-4c0c-a05b-70f360077a3c/7-0
00:00:06.560 --> 00:00:07.967
Times don't matter for testing.
NOTE Transcripts with speaker from Microsoft Teams
00:00:08.000 --> 00:00:06.110
<v Joe>Captions from Teams. Before start.</v>
00:01:01.000 --> 00:00:06.110
<v Fred>I'm sorry if cats meows happened throughout this. </v>
NOTE New format timestamp from Teams:
0:1:6.820 --> 0:0:7.390
<v Fred>The cats are rather worried at the moment.</v>
NOTE Check weird negative handled (and omitted):
0:1:-6.-820 --> 0:0:7.390
<v Test>This should be handled OK</v>
00:02:08.070 --> 00:00:08.620
<v Joe>That sounds interesting.</v>
NOTE Zoom transcripts (occasionally omit the speaker)
2
00:03:09.540 --> 00:00:12.990
Andrew Knight: Captions from Zoom. Okay.
3
00:03:15.540 --> 00:00:18.990
More captions.
NOTE Testing only 8 items concatenated. Use pre-converted data:
00:04:16\tFred\tParticularly interesting
00:04:17\tFred\tParticularly interesting
00:04:18\t\tParticularly interesting
00:04:19\t\tParticularly interesting
00:04:20\tFred\tParticularly interesting
00:04:21\tFred\tParticularly interesting
00:04:22\tFred\tParticularly interesting
00:04:23\tFred\tParticularly interesting
00:04:24\tFred\tParticularly interesting
NOTE Testing removing short interjections:
00:05:30.000 --> 00:01:06.110
<v Joe>I'm saying something.</v>
00:05:31.000 --> 00:00:06.110
<v Fred>Yes?</v>
00:05:32.820 --> 00:00:07.390
<v Joe>Err</v>
00:05:33.070 --> 00:00:08.620
<v Joe>Yes, It's very interesting.</v>
NOTE Sometimes we get timestamps out of sequence. Check here for triple duplicates as well.
00:06:01\tSpeaker 1\tRepeating timestamp
00:06:01\tSpeaker 2\tRepeating timestamp
00:06:01\tSpeaker 3\tRepeating timestamp
00:06:00\tSpeaker 4\tDecreasing timestamp
`;
// Conversion with timeshift and remove short phrases. Time shifted back one minute:
var expectedOutput=`Timespan\tSpeaker\tContent
00:00:01\tFred\tI'm sorry if cats meows happened throughout this. ---The cats are rather worried at the moment.
00:00:01.1\tTest\tThis should be handled OK
00:01:08\tJoe\tThat sounds interesting.
00:02:09\tAndrew Knight\tCaptions from Zoom. Okay.---More captions.
00:03:16\tFred\tParticularly interesting---Particularly interesting---Particularly interesting---Particularly interesting---Particularly interesting---Particularly interesting---Particularly interesting---Particularly interesting
00:03:24\tFred\tParticularly interesting
00:04:30\tJoe\tI'm saying something.---Yes, It's very interesting.
00:05:01\tSpeaker 1\tRepeating timestamp
00:05:01.1\tSpeaker 2\tRepeating timestamp
00:05:01.2\tSpeaker 3\tRepeating timestamp
00:05:01.3\tSpeaker 4\tDecreasing timestamp
`
// Basic conversion Teams/Zoom.
var expectedNonDeleteShortOutput=`Timespan\tSpeaker\tContent
00:00:02\t\tNon-speaker captions from Microsoft Stream---Times don't matter for testing.
00:00:08\tJoe\tCaptions from Teams. Before start.
00:01:01\tFred\tI'm sorry if cats meows happened throughout this. ---The cats are rather worried at the moment.
00:01:01.1\tTest\tThis should be handled OK
00:02:08\tJoe\tThat sounds interesting.
00:03:09\tAndrew Knight\tCaptions from Zoom. Okay.---More captions.
00:04:16\tFred\tParticularly interesting---Particularly interesting---Particularly interesting---Particularly interesting---Particularly interesting---Particularly interesting---Particularly interesting---Particularly interesting
00:04:24\tFred\tParticularly interesting
00:05:30\tJoe I'm saying something.
00:05:31\tFred Yes?
00:05:32\tJoe\tErr---Yes, It's very interesting.
00:06:01\tSpeaker 1\tRepeating timestamp
00:06:01.1\tSpeaker 2\tRepeating timestamp
00:06:01.2\tSpeaker 3\tRepeating timestamp
00:06:01.3\tSpeaker 4\tDecreasing timestamp
`
var testOneDriveInput=`WEBVTT
0a8e2f7c-5ccd-48e4-b7fa-1ea4c0496138-0
00:00:08.710 --> 00:00:09.280
Recording.
64db795b-6b69-420c-b0ce-e07606ba2843-0
00:00:12.860 --> 00:00:13.490
Okay.
NOTE check for a surprising bug involving financial amounts:
61a57f17-2107-42eb-a4a8-b17135e1314f-0
00:00:15.160 --> 00:00:16.060
£1,000,000.
992c692c-e132-45e9-80da-a2287df16dd4-0
00:00:17.840 --> 00:00:21.587
OK, so has been as we talked of
£750 per year. This project
992c692c-e132-45e9-80da-a2287df16dd4-1
00:00:21.587 --> 00:00:25.395
is about friendship, and I'd
like you just to think about one
992c692c-e132-45e9-80da-a2287df16dd4-2
00:00:25.395 --> 00:00:29.450
of your friends and can you tell
me about how you became friends?
b1d0c317-bd02-4981-8f69-710b324f822b-0
00:00:31.140 --> 00:00:35.224
About 6 and just moved over from
Germany and we just happened to
NOTE Sometimes we just get an empty line. Should ignore.
b1d0c317-bd02-4981-8f69-710b324f822b-1
00:00:34.224 --> 00:00:38.680
b1d0c317-bd02-4981-8f69-710b324f822b-1
00:00:35.224 --> 00:00:38.680
meet and the first thing he said
to me I know English.
f8b0955b-4f85-4516-ad07-03a7ddb01364-0
00:00:41.060 --> 00:00:43.850
And we have just been friends
with my best friend.`;
var expectedOneDriveOutput=`Timespan\tSpeaker\tContent
00:00:08\t\tRecording.---Okay.---£1,000,000.---OK, so has been as we talked of £750 per year. This project---is about friendship, and I'd like you just to think about one---of your friends and can you tell me about how you became friends?---About 6 and just moved over from Germany and we just happened to---meet and the first thing he said to me I know English.
00:00:41\t\tAnd we have just been friends with my best friend.`;
var parseTests=[
['0', 0],
['-2', -2],
['1:30', 90],
['-1:30', -90],
['0:0:0', 0],
['1:1:1', 3661],
['-1:1:1', -3661],
['01:01:01', 3661],
['0:2:0', 120],
['-0:4:0', -240]
];
// ----------------------------------------------------------------------------------------
// Code to run the tests and display meaningful error messages.
for (test of parseTests) {
if (parseHMS( test[0] ) != test[1]) {
document.getElementById("unitTestResult").innerHTML = "Unit test failed: Parsed " + test[0] + ", expected " + test[1] + ", got " + parseHMS( test[0] )
}
}
function escapeText( text ) {
// Show special characters like tabs and CRs in the output:
return text.replace(/[^\S ]/g,(e) => { return encodeURIComponent(e); });
}
function findError(actual, expected) {
// Answers an error message with the location of the error and problem.
actuals = actual.split("\n");
expecteds = expected.split("\n")
for (var i = 0; (actuals[i] === expecteds[i]); i++) {
if (i>=Math.min(actuals.length, expecteds.length)-1)
return "non matching lines at end: expected " + expecteds.length.toString() + " lines, got " + actuals.length.toString();
}
return "output line " + (i+1).toString() + ': expected "' + escapeText(expecteds[i]) + '", got "' + escapeText(actuals[i]) + '"';
}
// Input file Converter Offset DelShort? ExpectedOutput WordsDld TestDescription
var tests= [[testInput, 'Teams', 0, false, expectedNonDeleteShortOutput, '', "Basic conversion Teams/Zoom"],
[testInput, 'Teams', -60, true, expectedOutput, 'yes err',"Conversion with timeshift and remove short phrases"],
[testOneDriveInput, 'OneDrive', 0, false, expectedOneDriveOutput, '', "OneDrive conversion"]
];
for (test of tests) {
foundOutput = transcriptFromVtt(test[0], test[1], test[2], test[3]);
foundWordsDeleted=Object.keys(AllWordsDeleted).join(' ');
if (foundOutput !== test[4]) {
document.getElementById("unitTestResult").innerHTML = "Self test [" + test[6] + "] failed: " + findError( foundOutput, test[4] );
break;
}
else if (foundWordsDeleted !== test[5]) {
document.getElementById("unitTestResult").innerHTML = "Self test [" + test[6] + "] wrong words deleted. Expected " + test[5] +
', got ' + foundWordsDeleted;
break;
}
}
// And a test for Word timeshift and short line deletion.
const unprocessed=`Timespan\tSpeaker\tContent
0:19\tFred\tGrunt---Grunt---Grunt
0:31\tJim\tAnd I should say, you know, this is. ---One-of-a-kind of wave of really interesting books that are gonna be published in the coming years.
`;
const expectedResult=`Timespan\tSpeaker\tContent
00:00:41\tJim\tAnd I should say, you know, this is. ---One-of-a-kind of wave of really interesting books that are gonna be published in the coming years.
`;
const result=fixNvivoTranscript( unprocessed, 10, true );
if (result !== expectedResult) {
document.getElementById("unitTestResult").innerHTML = "Self test word timeshift failed.";
}
</script>
<!-- ************************************ Google Analytics ****************************** -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-762RZQ4E4B"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-762RZQ4E4B');
</script>