Spaces:
Runtime error
Runtime error
File size: 5,070 Bytes
32d94cc 4960cb4 0259f08 3866c77 de2125a 0259f08 a5582cc 0259f08 c5836b4 32a03d4 328548c c5836b4 cca4833 c5836b4 cca4833 b94d0bd c5836b4 32a03d4 0259f08 32a03d4 0259f08 a5582cc b94d0bd 0259f08 b94d0bd 0259f08 21fe8fd 0259f08 21fe8fd 0259f08 de2125a 0259f08 32a03d4 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 |
import os
import presentation_assistant.env_set as env
env.env_set()
import streamlit as st
import PyPDF2
import openai
import subprocess
from io import BytesIO
from pptx import Presentation
import presentation_assistant.presentation_assistant as pa
tab1, tab2, tab3 = st.tabs(['PA!λ?', 'Text2PPT', 'PPT2Script'])
with tab1:
st.header('μκ°')
st.title('PA!(Presentation Assistant):sparkles:')
contents = """
: μ¬μ©μκ° μ
λ ₯ν λ΄μ©μ κΈ°λ°μΌλ‘ PPTλ₯Ό :blue[μλ μ μ]νκ³ ,
νλ μ ν
μ΄μ
:red[μ€ν¬λ¦½νΈλ₯Ό μ 곡]νμ¬ νλ μ ν
μ΄μ
μλμ ν₯μμν΅λλ€!"""
st.markdown(contents)
st.markdown('-------------------------')
st.header('μ¬μ©λ²')
st.subheader('Text2PPT')
contents = """
: μ¬μ©μμκ² λ§ν¬λ νμΌμ μ λ¬λ°μΌλ©΄ κ·Έ λ΄μ©μΌλ‘ :blue[λ°ν μλ£λ₯Ό μ μ]ν΄ λ립λλ€!
μ¬μ©μλ μνλ ν
λ§(ν
νλ¦Ώ) μ’
λ₯μ νμ΄μ§ μλ§ μ ννμΈμ!"""
st.markdown(contents)
st.subheader('PPT2Script')
contents = """
: ppt λλ pdf λ°ν μλ£λ₯Ό μ¬μ©μλ‘λΆν° μ 곡λ°μΌλ©΄ μλμΌλ‘ :blue[λ°ν λλ³Έ]μ λ§λ€μ΄λ립λλ€!"""
st.markdown(contents)
# ν
μ€νΈ
test_ppt_theme = "--reference-doc="+"blue"+".pptx"
subprocess.run(["./pandoc-2.14.2/bin/pandoc", "text2ppt_test.md", "-t", "pptx", test_ppt_theme, "-o", "output.pptx"], capture_output=True)
print(os.listdir(os.getcwd()))
prs = Presentation("output.pptx")
binary_output = BytesIO()
prs.save(binary_output)
st.download_button(label="Download PPT",
data = binary_output.getvalue(),
file_name="export_output.pptx",
mime='application/octet-stream', key = "<Text2PPT_test_download>")
with tab2:
st.header('Text2PPT')
gpt_token = st.text_input('μ± gptν ν°μ μ
λ ₯ν΄ μ£ΌμΈμ.', key="<Text2PPT_token>")
st.markdown('-------------------------')
st.subheader(':computer:λ¬Έμ ppt μλ μμ±κΈ°:computer:')
thema_select = st.selectbox(
'μνλ ν
νλ¦Ώμ μ ννμΈμ',
['default', '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('ppt νμ΄μ§ μ₯μ', min_value=2, max_value=10, step=1, value=5)
st.markdown('-------------------------')
my_order = ['ν
μ€νΈ', 'λ§ν¬', 'PDF']
status = st.radio('νμΌ μ’
λ₯λ₯Ό μ ννκ³ λ΄μ©μ μ
λ ₯νμΈμ! :smile: ', my_order)
# 첫λ²μ§Έ λ°©λ²
if status == my_order[0]:
input_text = st.text_area('textλ₯Ό μ
λ ₯νμΈμ', height=5)
elif status == my_order[1]:
input_text = st.text_area('urlλ₯Ό μ
λ ₯νμΈμ', height=5)
elif status == my_order[2]:
input_text = st.file_uploader('νμΌμ μ
λ‘λ νμΈμ', type=['pdf'])
input_text_check = st.button('νμΈ', key="<Text2PPT_start>") # μ΄ λ²νΌ λλ₯΄λ©΄ μ
λ ₯ν
μ€νΈκ° λμ΄κ°κ² ν΄μΌν¨
st.markdown('-------------------------')
if input_text_check == True:
with st.spinner('Wait for it...'):
pa.text2ppt(gpt_token, 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')
gpt_token = st.text_input('μ±gptν ν°μ μ
λ ₯ν΄μ£ΌμΈμ.', key="<PPT2Script_token>")
st.markdown('-------------------------')
st.subheader(':bookmark_tabs:λ°ν λλ³Έ μμ±κΈ°')
file_order = ['PDF', 'PPT']
choose = st.radio('λ°ν μλ£μ νμΌ νμμ μ νν΄ μ£ΌμΈμ', 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('νμΈ', 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(gpt_token, uploaded_file.name, choose)
st.success('Done!')
st.download_button('Download Script',
data=script, file_name="script_output.txt", key="<PPT2Script_download>")
|