As a step in comparing the output from YouTube’s Autocaptioning, we need to transform their .sbv
file into something we can use in our comparison tests (a .trans
file). We needed to strip the hours out of the timecode, drop the end time, and bring everything to a single line.
Update: It turns out we needed a continuous text file. So these have been updated accordingly.
We needed to convert:
0:00:01.699,0:00:06.450
okay guys were going to get through this first
lecture for some reason there was a major0:00:06.450,0:00:08.130
scheduling of0:00:08.130,0:00:12.590
screw up so they have our their schedule classes
in our to overflow room so we're going to
to:
00:01.699 okay guys were going to get through this first lecture for some reason there was a major
00:06.450 scheduling of
00:08.130 screw up so they have our their schedule classes in our to overflow room so we're going to
I used the grep features of BBEdit’s search and replace, though I’d guess this can be done directly in grep on the command line.
- To remove the end time, search
,...........
and replace with,
strips off the end time. - To remove the line breaks between segments, search
rr
(two new lines) and replace withr
(single new line). - To put the timecode and text on one line, search
,r
(comma and new line) and replace with - This is the step that’s different if you want a
.trans
file or continuous text. For a.trans
file you just need to strip the leading^0:
. To strip the leading hour from the timecode, searchr^0:
(line break to beginning of line and 0:) and replace withxxxx
(wherexxxx
can be anything, it’s just used as a temporary placeholder, and it might need to be different if the text appears in the transcript). - To remove the line breaks in a multi-line segment, search
r
and replace with - To remove
xxxx
placeholder an put every segment on its own line, searchxxxx
and replace withr
. - Edit the first line to remove the
0:
by hand.
The continuous text version will look like:
okay guys were going to get through this first lecture for some reason there was a major scheduling of screw up so they have our their schedule classes in our to overflow room so we're going to