public static Transcript parse(String str) {
        if (StringUtils.isBlank(str)) {
            return null;
        }
        str = str.replaceAll("\r\n", "\n");

        Transcript transcript = new Transcript();
        List<String> lines = Arrays.asList(str.split("\n"));
        Iterator<String> iter = lines.iterator();
        String speaker = "";
        String prevSpeaker = "";
        StringBuilder body;
        String line;
        String segmentBody = "";
        long startTimecode = -1L;
        long spanStartTimecode = -1L;
        long spanEndTimecode = -1L;
        long endTimecode = -1L;
        long duration = 0L;
        Set<String> speakers = new HashSet<>();

        while (iter.hasNext()) {
            body = new StringBuilder();
            line = iter.next();

            if (line.isEmpty()) {
                continue;
            }

            spanEndTimecode = endTimecode;
            if (line.contains("-->")) {
                String[] timecodes = line.split("-->");
                if (timecodes.length < 2) {
                    continue;
                }
                startTimecode = parseTimecode(timecodes[0].trim());
                endTimecode = parseTimecode(timecodes[1].trim());
                if (startTimecode == -1 || endTimecode == -1) {
                    continue;
                }

                if (spanStartTimecode == -1) {
                    spanStartTimecode = startTimecode;
                }
                duration += endTimecode - startTimecode;
                do {
                    line = iter.next();
                    if (StringUtil.isBlank(line)) {
                        break;
                    }
                    body.append(line.strip());
                    body.append(" ");
                } while (iter.hasNext());
            }

            if (body.indexOf(": ") != -1) {
                String[] parts = body.toString().trim().split(":");
                if (parts.length < 2) {
                    continue;
                }
                prevSpeaker = speaker;
                speaker = parts[0];
                speakers.add(speaker);
                body = new StringBuilder(parts[1].strip());
                if (StringUtils.isNotEmpty(prevSpeaker) && !StringUtils.equals(speaker, prevSpeaker)) {
                    if (StringUtils.isNotEmpty(segmentBody)) {
                        transcript.addSegment(new TranscriptSegment(spanStartTimecode,
                                spanEndTimecode, segmentBody, prevSpeaker));
                        duration = 0L;
                        spanStartTimecode = startTimecode;
                        segmentBody = body.toString();
                        continue;
                    }
                }
            } else {
                if (StringUtils.isNotEmpty(prevSpeaker) && StringUtils.isEmpty(speaker)) {
                    speaker = prevSpeaker;
                }
            }

            segmentBody += " " + body;
            segmentBody = StringUtils.trim(segmentBody);
            if (duration >= TranscriptParser.MIN_SPAN && endTimecode > spanStartTimecode) {
                transcript.addSegment(new TranscriptSegment(spanStartTimecode, endTimecode, segmentBody, speaker));
                duration = 0L;
                spanStartTimecode = -1L;
                segmentBody = "";
            }
        }

        if (!StringUtil.isBlank(segmentBody) && endTimecode > spanStartTimecode) {
            segmentBody = StringUtils.trim(segmentBody);
            transcript.addSegment(new TranscriptSegment(spanStartTimecode, endTimecode, segmentBody, speaker));
        }
        if (transcript.getSegmentCount() > 0) {
            transcript.setSpeakers(speakers);
            return transcript;
        } else {
            return null;
        }
    }
@Test
    public void testParseSrt() {
        Transcript result = SrtTranscriptParser.parse(srtStr);

        assertEquals(result.getSegmentAtTime(0L).getWords(), "Promoting your podcast in a new");
        assertEquals(result.getSegmentAtTime(0L).getSpeaker(), "John Doe");
        assertEquals(result.getSegmentAtTime(0L).getStartTime(), 0L);
        assertEquals(result.getSegmentAtTime(0L).getEndTime(), 50730L);
        assertEquals(result.getSegmentAtTime(90740).getStartTime(), 90740);
        assertEquals("way. The latest from PogNews. We bring your favorite podcast.",
                result.getSegmentAtTime(90740).getWords());
    }