def get_frame_durations(sentences, timestamps):
    """Given a list of sentences and timestamps of all words, return timestamps of each sentence

    Args:
        sentences (list): List of sentences
        timestamps (list): [
            [<word_string>, <start_time_float>, <end_time_float>],
            ...
        ]

    Returns:
        list: List of tuples ( <sentence> , <end_time_millisecond> )
    """
    i = 0
    durations = []
    previous = None

    for j, sentence in enumerate(sentences):
        words = sentence.split()
        word_timestamps = []
        for word in words:
            if word in timestamps[i][0]:
                word_timestamps.append(
                    (word, timestamps[i][1], timestamps[i][2]))
                i += 1

        if j == 0:
            duration = int(word_timestamps[-1][2] * 1000)
        else:
            duration = int((word_timestamps[-1][2] - previous)*1000)
        previous = word_timestamps[-1][2]
        durations.append((sentence, duration))

    return durations