Skip to content

Instantly share code, notes, and snippets.

@jasdev
Created December 20, 2020 02:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jasdev/6b0b1510ba0dead45cdca13b2bac07c9 to your computer and use it in GitHub Desktop.
Save jasdev/6b0b1510ba0dead45cdca13b2bac07c9 to your computer and use it in GitHub Desktop.
transcriptionSegmentsToSubRipText scaffolding.
func transcriptionSegmentsToSubRipText(
_ segments: [SFTranscriptionSegment]
) -> String {
segments
.enumerated()
.map { sequnceNumber, segment in
[
"\(sequnceNumber + 1)", // Shifting the offset up by one, since
// `EnumeratedSequence.Iterator.Element.offset` starts at zero.
subRipTimingLine(start: segment.timestamp, duration: segment.duration),
segment.substring
]
.joined(separator: "\n")
}
.joined(separator: "\n\n")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment