From 04e47169557b0c65570d5916740a6b349694e806 Mon Sep 17 00:00:00 2001 From: radhikatoravi15 <76820164+radhikatoravi15@users.noreply.github.com> Date: Mon, 1 Nov 2021 19:48:02 -0400 Subject: [PATCH 1/7] Delete scrivener_user_interface.py --- source/scrivener_user_interface.py | 153 ----------------------------- 1 file changed, 153 deletions(-) delete mode 100644 source/scrivener_user_interface.py diff --git a/source/scrivener_user_interface.py b/source/scrivener_user_interface.py deleted file mode 100644 index c615534..0000000 --- a/source/scrivener_user_interface.py +++ /dev/null @@ -1,153 +0,0 @@ -""" -Copyright (c) 2021 Anshul Patel -This code is licensed under MIT license (see LICENSE.MD for details) - -@author: Scrivener -""" - -# Import Libraries -import streamlit as st -import re -import os -from main.transcribe import TranscribeVideo -from main.transcribe_yt import TranscribeYtVideo -import secrets -from glob import glob - -import shutil - -# Hide Footer in Streamlit -hide_menu_style = """ - - """ -st.markdown(hide_menu_style, unsafe_allow_html=True) - -# Add footer to UI -footer=""" -
-""" -st.markdown(footer,unsafe_allow_html=True) - -# Check if ML model files have been combined, if not combine them -# This needs to be done because the full file is greater than 100mb -# and GitHub does not allow files larger than 100mb to be pushed -if not os.path.exists('source/punct_model_full.pcl'): - print("Creating punct_model_full.pcl file for ML model...") - first_file = os.path.abspath('source/punct_model_part1.pcl') - second_file = os.path.abspath('source/punct_model_part2.pcl') - third_file = os.path.abspath('source/punct_model_part3.pcl') - new_file = os.path.abspath('source/punct_model_full.pcl') - - with open(new_file, "wb") as wfd: - for f in [first_file, second_file, third_file]: - with open(f, "rb") as fd: - shutil.copyfileobj(fd, wfd, 1024 * 1024 * 10) - - -# Download the uploaded video file -def save_file(file): - with open(os.path.join(os.getcwd(), file.name), 'wb') as f: - f.write(file.getbuffer()) - return - -# Display Image -st.image("media/logo/logo.gif") - -# Display Radio options -input_format = st.radio('Choose your input format', ['Youtube Link', 'Upload a Video']) - -# If user provides a Youtube Link -if input_format=='Youtube Link': - # Text input box - youtube_link = st.text_input('Enter Youtube Link') - # Check if its a valid youtube link - if re.findall('(www\.youtube\.com\/watch\?v=)',youtube_link): - st.video(youtube_link) - # Make a progress bar - progress_bar = st.progress(0) - # Decorative material - progress_lines = secrets.choice(['Hired Shakespeare to summarize your video', 'Taking advice from Charles Dickens to help you', - 'Shakespeare is completing the assignment', 'Do not worry, Mark Twain is on it', - 'Robert Frost is taking the right road to summarize your video']) - progress_bar.progress(10) - - # Wait till we run the summarization - with st.spinner(progress_lines+' . . .'): - progress_bar.progress(25) - # Call TranscribeYtVideo class - transcribe_video = TranscribeYtVideo(youtube_link) - progress_bar.progress(40) - # Get summary - summary = transcribe_video.transcribe_yt_video() - progress_bar.progress(80) - # Complete progress bar to 100 - progress_bar.progress(100) - # Display Summary - st.header('Summary') - st.write(summary) - - - # If user inputs an invalid Youtube link - elif youtube_link!='': - st.error('Please enter a valid Youtube Link!') - -# If user uploads a local video -elif input_format=='Upload a Video': - # Browse button for uploading .mp4 files - file = st.file_uploader('Upload a video',type=['mp4'],accept_multiple_files=False) - if file is not None: - st.video(file) - # Make a progress bar - progress_bar = st.progress(0) - progress_bar.progress(10) - # Decorative material - progress_lines = secrets.choice(['Hired Shakespeare to summarize your video', 'Taking advice from Charles Dickens to help you', - 'Shakespeare is completing the assignment', 'Do not worry, Mark Twain is on it', - 'Robert Frost is taking the right road to summarize your video']) - # Wait till we run the summarization - with st.spinner(progress_lines+' . . .'): - progress_bar.progress(25) - # Download the uploaded video file - save_file(file) - progress_bar.progress(40) - # Call TranscribeVideo class - transcribe_video = TranscribeVideo() - progress_bar.progress(60) - # Get summary - summary = transcribe_video.transcribe_video(os.path.join(os.getcwd(), file.name)) - # Complete progress bar to 100 - progress_bar.progress(100) - # Display Summary - st.header('Summary') - st.write(summary) - else: - for name in glob('*.mp4'): - os.remove(name) From b5876921288ec49b2c104814f85f2c7969cb7c39 Mon Sep 17 00:00:00 2001 From: radhikatoravi15 <76820164+radhikatoravi15@users.noreply.github.com> Date: Mon, 1 Nov 2021 19:48:34 -0400 Subject: [PATCH 2/7] Add files via upload --- source/scrivener_user_interface.py | 165 +++++++++++++++++++++++++++++ 1 file changed, 165 insertions(+) create mode 100644 source/scrivener_user_interface.py diff --git a/source/scrivener_user_interface.py b/source/scrivener_user_interface.py new file mode 100644 index 0000000..fe621fd --- /dev/null +++ b/source/scrivener_user_interface.py @@ -0,0 +1,165 @@ +""" +Copyright (c) 2021 Anshul Patel +This code is licensed under MIT license (see LICENSE.MD for details) + +@author: Scrivener +""" + +# Import Libraries +import streamlit as st +import re +import os +from main.transcribe import TranscribeVideo +from main.transcribe_yt import TranscribeYtVideo +import secrets +from glob import glob +from monkeylearn import MonkeyLearn + +import shutil + +# Hide Footer in Streamlit +hide_menu_style = """ + + """ +st.markdown(hide_menu_style, unsafe_allow_html=True) + +# Add footer to UI +footer=""" + +""" +st.markdown(footer,unsafe_allow_html=True) + +# Check if ML model files have been combined, if not combine them +# This needs to be done because the full file is greater than 100mb +# and GitHub does not allow files larger than 100mb to be pushed +if not os.path.exists('source/punct_model_full.pcl'): + print("Creating punct_model_full.pcl file for ML model...") + first_file = os.path.abspath('source/punct_model_part1.pcl') + second_file = os.path.abspath('source/punct_model_part2.pcl') + third_file = os.path.abspath('source/punct_model_part3.pcl') + new_file = os.path.abspath('source/punct_model_full.pcl') + + with open(new_file, "wb") as wfd: + for f in [first_file, second_file, third_file]: + with open(f, "rb") as fd: + shutil.copyfileobj(fd, wfd, 1024 * 1024 * 10) + + +# Download the uploaded video file +def save_file(file): + with open(os.path.join(os.getcwd(), file.name), 'wb') as f: + f.write(file.getbuffer()) + return + +# Display Image +st.image("media/logo/logo.gif") + +# Display Radio options +input_format = st.radio('Choose your input format', ['Youtube Link', 'Upload a Video']) + +# If user provides a Youtube Link +if input_format=='Youtube Link': + # Text input box + youtube_link = st.text_input('Enter Youtube Link') + # Check if its a valid youtube link + if re.findall('(www\.youtube\.com\/watch\?v=)',youtube_link): + st.video(youtube_link) + # Make a progress bar + progress_bar = st.progress(0) + # Decorative material + progress_lines = secrets.choice(['Hired Shakespeare to summarize your video', 'Taking advice from Charles Dickens to help you', + 'Shakespeare is completing the assignment', 'Do not worry, Mark Twain is on it', + 'Robert Frost is taking the right road to summarize your video']) + progress_bar.progress(10) + + # Wait till we run the summarization + with st.spinner(progress_lines+' . . .'): + progress_bar.progress(25) + # Call TranscribeYtVideo class + transcribe_video = TranscribeYtVideo(youtube_link) + progress_bar.progress(40) + # Get summary + summary = transcribe_video.transcribe_yt_video() + progress_bar.progress(80) + # Complete progress bar to 100 + progress_bar.progress(100) + # Display Summary + st.header('Summary') + st.write(summary) + + + # If user inputs an invalid Youtube link + elif youtube_link!='': + st.error('Please enter a valid Youtube Link!') + +# If user uploads a local video +elif input_format=='Upload a Video': + # Browse button for uploading .mp4 files + file = st.file_uploader('Upload a video',type=['mp4'],accept_multiple_files=False) + if file is not None: + st.video(file) + # Make a progress bar + progress_bar = st.progress(0) + progress_bar.progress(10) + # Decorative material + progress_lines = secrets.choice(['Hired Shakespeare to summarize your video', 'Taking advice from Charles Dickens to help you', + 'Shakespeare is completing the assignment', 'Do not worry, Mark Twain is on it', + 'Robert Frost is taking the right road to summarize your video']) + # Wait till we run the summarization + with st.spinner(progress_lines+' . . .'): + progress_bar.progress(25) + # Download the uploaded video file + save_file(file) + progress_bar.progress(40) + # Call TranscribeVideo class + transcribe_video = TranscribeVideo() + progress_bar.progress(60) + # Get summary + summary = transcribe_video.transcribe_video(os.path.join(os.getcwd(), file.name)) + # Complete progress bar to 100 + progress_bar.progress(100) + # Display Summary + st.header('Summary') + st.write(summary) + st.header('Sentiment Analysis') #sentiment analysis using monkey learn API + ml = MonkeyLearn('dbb453f3bfb987985b08641946f39ff81a76d92e') + model_id = 'cl_pi3C7JiL' + result = ml.classifiers.classify(model_id, summary) + for entry in result.body: + for classification in entry['classifications']: + tag_name = classification.get('tag_name') + if tag_name is not None: + st.write(tag_name) + + + else: + for name in glob('*.mp4'): + os.remove(name) From b5cffc463e84cc8c250dbaa943b2053d977b3502 Mon Sep 17 00:00:00 2001 From: jrvargas