Created
December 20, 2020 02:37
-
-
Save jasdev/6b0b1510ba0dead45cdca13b2bac07c9 to your computer and use it in GitHub Desktop.
transcriptionSegmentsToSubRipText scaffolding.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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