| | import os |
| | import presentation_assistant.env_set as env |
| | env.env_set() |
| | print(os.getcwd()) |
| |
|
| | import streamlit as st |
| | import PyPDF2 |
| | import subprocess |
| | from io import BytesIO |
| | from pptx import Presentation |
| |
|
| |
|
| | import presentation_assistant.presentation_assistant as pa |
| |
|
| | tab1, tab2, tab3 = st.tabs(['What is PA!?', 'Text2PPT', 'PPT2Script']) |
| |
|
| | with tab1: |
| | st.header('Introduction') |
| | st.title('PA!(Presentation Assistant):sparkles:') |
| | contents = """ |
| | ▶ Based on the content entered by the user, it :blue[automatically creates] PPT and |
| | provides a presentation :red[script] to improve presentation skills!""" |
| | st.markdown(contents) |
| | st.markdown('-------------------------') |
| | st.header('How to use') |
| | st.subheader('Text2PPT') |
| | contents = """ |
| | ▶ If the user provides a link or file, we will :blue[create a presentation material] for you! |
| | The user only needs to select the desired theme (template) type and number of pages!""" |
| | st.markdown(contents) |
| | st.subheader('PPT2Script') |
| | contents = """ |
| | ▶ If the user provides PPT or PDF presentation materials, we will automatically create a :blue[presentation script] for you!""" |
| | st.markdown(contents) |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| |
|
| |
|
| | with tab2: |
| | st.header('Text2PPT') |
| | st.subheader(':computer: PPT Auto Generator :computer:') |
| |
|
| | thema_select = st.selectbox( |
| | 'Please select the template you want.', |
| | ['default', 'yellow', 'gradation_green', 'blue', 'green', 'custom']) |
| | |
| | if thema_select == "custom": |
| | uploaded_template_file = st.file_uploader('Choose File!', type='pptx', key="<template_uploader>") |
| |
|
| | st.markdown('-------------------------') |
| |
|
| | page_choice = st.slider('Number of PPT pages', min_value=2, max_value=12, step=1, value=5) |
| |
|
| | st.markdown('-------------------------') |
| |
|
| | my_order = ['Text', 'Link', 'PDF'] |
| | status = st.radio('Please select the file type and enter the content! :smile: ', my_order) |
| |
|
| | |
| | if status == my_order[0]: |
| | input_text = st.text_area('Enter TEXT', height=5) |
| |
|
| | elif status == my_order[1]: |
| | input_text = st.text_area('Enter URL', height=5) |
| |
|
| | elif status == my_order[2]: |
| | input_text = st.file_uploader('Upload PDF', type=['pdf']) |
| |
|
| | input_text_check = st.button('Confirm', key="<Text2PPT_start>") |
| |
|
| | st.markdown('-------------------------') |
| |
|
| | if input_text_check == True: |
| | with st.spinner('Wait for it...'): |
| | pa.text2ppt(pa.generate_text2ppt_input_prompt(status, input_text, page_choice), thema_select) |
| | prs = Presentation("text2ppt_output.pptx") |
| | binary_output = BytesIO() |
| | prs.save(binary_output) |
| | st.success('Done!') |
| | st.download_button(label="Download PPT", |
| | data = binary_output.getvalue(), |
| | file_name="export_output.pptx", |
| | mime='application/octet-stream', key = "<Text2PPT_download>") |
| |
|
| | with tab3: |
| | st.header('PPT2Script') |
| | st.subheader(':computer: Script Auto Generator :computer:') |
| | st.markdown('-------------------------') |
| |
|
| | st.subheader(':bookmark: Presentation Script Generator') |
| |
|
| | file_order = ['PDF', 'PPT'] |
| | choose = st.radio('Please select the file format of the presentation material', file_order) |
| |
|
| | if choose == file_order[0]: |
| | uploaded_file = st.file_uploader('Choose File!', type='pdf', key="<PPT2Script_pdf_uploader>") |
| | elif choose == file_order[1]: |
| | uploaded_file = st.file_uploader('Choose File!', type='pptx', key="<PPT2Script_ppt_uploader>") |
| |
|
| | input_file_check = st.button('Confirm', key="<PPT2Script_start>") |
| | st.markdown('-------------------------') |
| |
|
| | if input_file_check == True: |
| | with st.spinner('Wait for it...'): |
| | with open(uploaded_file.name, mode='wb') as w: |
| | w.write(uploaded_file.getvalue()) |
| |
|
| | script = pa.ppt2script(uploaded_file.name, choose) |
| |
|
| | st.success('Done!') |
| | st.download_button('Download Script', |
| | data=script, file_name="script_output.txt", key="<PPT2Script_download>") |
| |
|