Example #1
0
def transcript():
    link_again = summ.the_link
    the_props = float(request.form['proportion'])
    print("Downloading Video")
    tuple = dl_youtube.video_download(link_again, 22)
    vtt = tuple[1]
    video = tuple[0]
    print("Loading Transcript")
    file = punctuate_transcript(vtt)
    print("Summarizing Lecture")
    with open(file[:-4] + "_sum.txt", "w+") as lex_rank_summary_file:
        lex_rank_summary_file.write(
            sumy_lex_rank.lex_rank_summarizer(file, the_props))
    print("Finding TimeStamps")
    times = video_indices.video_indices(vtt, file[:-4] + "_sum.txt")
    print('Rendering Video')
    final = edit_video.edit_summarized_video(video, times)
    return render_template("transcript.html", final_video=final)
import dl_youtube
import puncuator
import model_utilities

def lsa_summarizer(file):
    parser = PlaintextParser.from_file(file, Tokenizer("english"))
    summarizer = LsaSummarizer()

    text = open(file, 'r').read()
    chosen_sentences = summarizer(parser.document, model_utilities.summary_length(text))

    summary = ""
    for sentence_tuple in chosen_sentences:
        line = ""
        for i in range(len(sentence_tuple.words)):
            if i == len(sentence_tuple.words) - 1:
                line += sentence_tuple.words[i] + "."
            else:
                line += sentence_tuple.words[i] + " "
        summary += line + " "

    return summary


url = "https://www.youtube.com/watch?v=1qy9xVEOI40"
vtt = dl_youtube.video_download(url, 22)[1]
file = puncuator.punctuate_transcript(vtt)

with open("lsa_summary.txt", "w+") as lsa_summary_file:
    lsa_summary_file.write(lsa_summarizer(file))