Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -16,9 +16,8 @@ from io import BytesIO
|
|
| 16 |
# text2ppt ν둬ννΈ μμ± ν¨μ
|
| 17 |
def generate_text2ppt_input_prompt(input_type, input_value, input_pages):
|
| 18 |
header = """
|
| 19 |
-
λκ°
|
| 20 |
-
+++ μλ λ΄μ© λλ λ§ν¬λ₯Ό μμ½ν΄μ
|
| 21 |
-
|
| 22 |
+++
|
| 23 |
""" % input_pages
|
| 24 |
|
|
@@ -56,7 +55,6 @@ def generate_text2ppt_input_prompt(input_type, input_value, input_pages):
|
|
| 56 |
- PPTμ λ΄μ©μ νλΆνκ² λ§ν¬λ€μ΄μΌλ‘ μμ±ν΄μ€.
|
| 57 |
- μ¬λΌμ΄λ λ³λ‘ μ€λͺ
νμ§λ§κ³ , μ½λλ§ μμ±ν΄μ€.
|
| 58 |
- μμμ λ΄μ©μ μ¬μ©ν΄μ μμ±νμ§λ§κ³ , νμλ§ μ°Έκ³ ν΄.
|
| 59 |
-
|
| 60 |
~~~
|
| 61 |
<!-- Slide 0. μ¬λΌμ΄λ μ£Όμ -->
|
| 62 |
# μ¬λΌμ΄λ μ λͺ©
|
|
@@ -90,17 +88,19 @@ def text2ppt(token_key, input_prompt, input_theme):
|
|
| 90 |
messages.append({"role": "assistant", "content": reply})
|
| 91 |
|
| 92 |
md_text = reply[4:] if reply[:3] == "---" else reply
|
| 93 |
-
|
| 94 |
md_text_list = md_text.split('\n')
|
| 95 |
|
| 96 |
-
# writedata.py
|
| 97 |
f = open("text2ppt_input.md", 'w')
|
| 98 |
for i in range(0, len(md_text_list)):
|
| 99 |
data = md_text_list[i] + "\n"
|
| 100 |
f.write(data)
|
| 101 |
f.close()
|
| 102 |
|
| 103 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 104 |
|
| 105 |
|
| 106 |
def ppt2script(token_key, input_file, input_type):
|
|
@@ -135,12 +135,10 @@ def ppt2script(token_key, input_file, input_type):
|
|
| 135 |
header = """
|
| 136 |
λλλ PPT λ°νμ λμμ μ£Όλ μ‘°λ ₯μμΌ.
|
| 137 |
~~~μλ κ·μΉμ μ§ν€κ³ , --- μλ PPT λ΄μ©μ λν΄ λ°ν μ€ν¬λ¦½νΈλ₯Ό νκΈλ‘ μμ±ν΄.
|
| 138 |
-
|
| 139 |
~~~
|
| 140 |
- [PAGE_NUM 1] μΌ λ, μ¬κΈ°μ 1μ νμ΄μ§ λ²νΈμΈλ°, νμ΄μ§ λ²νΈλ§λ€ λ°ν μ€ν¬λ¦½νΈλ₯Ό μμ±ν΄.
|
| 141 |
- λ§ν¬λ€μ΄ μΈμ΄λ₯Ό μ°μ§μκ³ , ν
μ€νΈλ‘λ§ μμ±ν΄.
|
| 142 |
- PPT λ΄μ©μ μΆκ°μ μΈ μ€λͺ
μ΄λ μ¬λ‘λ₯Ό λ§λΆμ¬μ€.
|
| 143 |
-
|
| 144 |
---
|
| 145 |
"""
|
| 146 |
|
|
@@ -174,7 +172,6 @@ with tab1:
|
|
| 174 |
st.title('PA!(Presentation Assistant):sparkles:')
|
| 175 |
contents = """
|
| 176 |
: μ¬μ©μκ° μ
λ ₯ν λ΄μ©μ κΈ°λ°μΌλ‘ PPTλ₯Ό :blue[μλ μ μ]νκ³ ,
|
| 177 |
-
|
| 178 |
νλ μ ν
μ΄μ
:red[μ€ν¬λ¦½νΈλ₯Ό μ 곡]νμ¬ νλ μ ν
μ΄μ
μλμ ν₯μμν΅λλ€!"""
|
| 179 |
st.markdown(contents)
|
| 180 |
st.markdown('-------------------------')
|
|
@@ -182,7 +179,6 @@ with tab1:
|
|
| 182 |
st.subheader('Text2PPT')
|
| 183 |
contents = """
|
| 184 |
: μ¬μ©μμκ² λ§ν¬λ νμΌμ μ λ¬λ°μΌλ©΄ κ·Έ λ΄μ©μΌλ‘ :blue[λ°ν μλ£λ₯Ό μ μ]ν΄ λ립λλ€!
|
| 185 |
-
|
| 186 |
μ¬μ©μλ μνλ ν
λ§(ν
νλ¦Ώ) μ’
λ₯μ νμ΄μ§ μλ§ μ ννμΈμ!"""
|
| 187 |
st.markdown(contents)
|
| 188 |
st.subheader('PPT2Script')
|
|
@@ -191,7 +187,9 @@ with tab1:
|
|
| 191 |
st.markdown(contents)
|
| 192 |
|
| 193 |
# ν
μ€νΈ
|
| 194 |
-
|
|
|
|
|
|
|
| 195 |
print(os.listdir(os.getcwd()))
|
| 196 |
prs = Presentation("output.pptx")
|
| 197 |
binary_output = BytesIO()
|
|
@@ -201,6 +199,7 @@ with tab1:
|
|
| 201 |
file_name="export_output.pptx",
|
| 202 |
mime='application/octet-stream', key = "<Text2PPT_test_download>")
|
| 203 |
|
|
|
|
| 204 |
with tab2:
|
| 205 |
st.header('Text2PPT')
|
| 206 |
gpt_token = st.text_input('μ± gptν ν°μ μ
λ ₯ν΄ μ£ΌμΈμ.', key="<Text2PPT_token>")
|
|
@@ -209,8 +208,11 @@ with tab2:
|
|
| 209 |
st.subheader(':computer:λ¬Έμ ppt μλ μμ±κΈ°:computer:')
|
| 210 |
|
| 211 |
thema_select = st.selectbox(
|
| 212 |
-
'μνλ
|
| 213 |
-
['default', '
|
|
|
|
|
|
|
|
|
|
| 214 |
|
| 215 |
st.markdown('-------------------------')
|
| 216 |
|
|
@@ -275,4 +277,4 @@ with tab3:
|
|
| 275 |
st.success('Done!')
|
| 276 |
st.download_button('Download Script',
|
| 277 |
data=script, file_name="script_output.txt", key="<PPT2Script_download>")
|
| 278 |
-
|
|
|
|
| 16 |
# text2ppt ν둬ννΈ μμ± ν¨μ
|
| 17 |
def generate_text2ppt_input_prompt(input_type, input_value, input_pages):
|
| 18 |
header = """
|
| 19 |
+
λκ° markdown λ¬Έλ²μΌλ‘ PPTλ₯Ό μ μνλ λμμ΄λλΌκ³ κ°μ νκ³ , %sμ₯μ PPTλ₯Ό μμ±ν΄.
|
| 20 |
+
+++ μλ λ΄μ© λλ λ§ν¬λ₯Ό μμ½ν΄μ markdown μΈμ΄λ‘ μμ±νλλ°, === μλ κ·μΉκ³Ό μ§ν€κ³ , ~~~ μλ μ¬λΌμ΄λ μμλ₯Ό μ°Έκ³ ν΄.
|
|
|
|
| 21 |
+++
|
| 22 |
""" % input_pages
|
| 23 |
|
|
|
|
| 55 |
- PPTμ λ΄μ©μ νλΆνκ² λ§ν¬λ€μ΄μΌλ‘ μμ±ν΄μ€.
|
| 56 |
- μ¬λΌμ΄λ λ³λ‘ μ€λͺ
νμ§λ§κ³ , μ½λλ§ μμ±ν΄μ€.
|
| 57 |
- μμμ λ΄μ©μ μ¬μ©ν΄μ μμ±νμ§λ§κ³ , νμλ§ μ°Έκ³ ν΄.
|
|
|
|
| 58 |
~~~
|
| 59 |
<!-- Slide 0. μ¬λΌμ΄λ μ£Όμ -->
|
| 60 |
# μ¬λΌμ΄λ μ λͺ©
|
|
|
|
| 88 |
messages.append({"role": "assistant", "content": reply})
|
| 89 |
|
| 90 |
md_text = reply[4:] if reply[:3] == "---" else reply
|
|
|
|
| 91 |
md_text_list = md_text.split('\n')
|
| 92 |
|
|
|
|
| 93 |
f = open("text2ppt_input.md", 'w')
|
| 94 |
for i in range(0, len(md_text_list)):
|
| 95 |
data = md_text_list[i] + "\n"
|
| 96 |
f.write(data)
|
| 97 |
f.close()
|
| 98 |
|
| 99 |
+
if input_theme == 'default':
|
| 100 |
+
subprocess.run(["./pandoc-2.14.2/bin/pandoc", "text2ppt_input.md", "-t", "pptx", "-o", "text2ppt_output.pptx"], capture_output=True)
|
| 101 |
+
else:
|
| 102 |
+
ppt_theme = "--reference-doc="+input_theme+".pptx"
|
| 103 |
+
subprocess.run(["./pandoc-2.14.2/bin/pandoc", "text2ppt_input.md", "-t", "pptx", ppt_theme, "-o", "text2ppt_output.pptx"], capture_output=True)
|
| 104 |
|
| 105 |
|
| 106 |
def ppt2script(token_key, input_file, input_type):
|
|
|
|
| 135 |
header = """
|
| 136 |
λλλ PPT λ°νμ λμμ μ£Όλ μ‘°λ ₯μμΌ.
|
| 137 |
~~~μλ κ·μΉμ μ§ν€κ³ , --- μλ PPT λ΄μ©μ λν΄ λ°ν μ€ν¬λ¦½νΈλ₯Ό νκΈλ‘ μμ±ν΄.
|
|
|
|
| 138 |
~~~
|
| 139 |
- [PAGE_NUM 1] μΌ λ, μ¬κΈ°μ 1μ νμ΄μ§ λ²νΈμΈλ°, νμ΄μ§ λ²νΈλ§λ€ λ°ν μ€ν¬λ¦½νΈλ₯Ό μμ±ν΄.
|
| 140 |
- λ§ν¬λ€μ΄ μΈμ΄λ₯Ό μ°μ§μκ³ , ν
μ€νΈλ‘λ§ μμ±ν΄.
|
| 141 |
- PPT λ΄μ©μ μΆκ°μ μΈ μ€λͺ
μ΄λ μ¬λ‘λ₯Ό λ§λΆμ¬μ€.
|
|
|
|
| 142 |
---
|
| 143 |
"""
|
| 144 |
|
|
|
|
| 172 |
st.title('PA!(Presentation Assistant):sparkles:')
|
| 173 |
contents = """
|
| 174 |
: μ¬μ©μκ° μ
λ ₯ν λ΄μ©μ κΈ°λ°μΌλ‘ PPTλ₯Ό :blue[μλ μ μ]νκ³ ,
|
|
|
|
| 175 |
νλ μ ν
μ΄μ
:red[μ€ν¬λ¦½νΈλ₯Ό μ 곡]νμ¬ νλ μ ν
μ΄μ
μλμ ν₯μμν΅λλ€!"""
|
| 176 |
st.markdown(contents)
|
| 177 |
st.markdown('-------------------------')
|
|
|
|
| 179 |
st.subheader('Text2PPT')
|
| 180 |
contents = """
|
| 181 |
: μ¬μ©μμκ² λ§ν¬λ νμΌμ μ λ¬λ°μΌλ©΄ κ·Έ λ΄μ©μΌλ‘ :blue[λ°ν μλ£λ₯Ό μ μ]ν΄ λ립λλ€!
|
|
|
|
| 182 |
μ¬μ©μλ μνλ ν
λ§(ν
νλ¦Ώ) μ’
λ₯μ νμ΄μ§ μλ§ μ ννμΈμ!"""
|
| 183 |
st.markdown(contents)
|
| 184 |
st.subheader('PPT2Script')
|
|
|
|
| 187 |
st.markdown(contents)
|
| 188 |
|
| 189 |
# ν
μ€νΈ
|
| 190 |
+
test_ppt_theme = "--reference-doc="+"blue"+".pptx"
|
| 191 |
+
subprocess.run(["./pandoc-2.14.2/bin/pandoc", "text2ppt_test.md", "-t", "pptx", test_ppt_theme, "-o", "output.pptx", "--output-encoding=utf8"], capture_output=True)
|
| 192 |
+
# subprocess.run(["./pandoc-2.14.2/bin/pandoc", "text2ppt_test.md", "-t", "pptx", "-o", "output.pptx"], capture_output=True)
|
| 193 |
print(os.listdir(os.getcwd()))
|
| 194 |
prs = Presentation("output.pptx")
|
| 195 |
binary_output = BytesIO()
|
|
|
|
| 199 |
file_name="export_output.pptx",
|
| 200 |
mime='application/octet-stream', key = "<Text2PPT_test_download>")
|
| 201 |
|
| 202 |
+
|
| 203 |
with tab2:
|
| 204 |
st.header('Text2PPT')
|
| 205 |
gpt_token = st.text_input('μ± gptν ν°μ μ
λ ₯ν΄ μ£ΌμΈμ.', key="<Text2PPT_token>")
|
|
|
|
| 208 |
st.subheader(':computer:λ¬Έμ ppt μλ μμ±κΈ°:computer:')
|
| 209 |
|
| 210 |
thema_select = st.selectbox(
|
| 211 |
+
'μνλ ν
νλ¦Ώμ μ ννμΈμ',
|
| 212 |
+
['default', 'blue', 'green', 'custom'])
|
| 213 |
+
|
| 214 |
+
if thema_select == "custom":
|
| 215 |
+
uploaded_template_file = st.file_uploader('Choose File!', type='pptx', key="<template_uploader>")
|
| 216 |
|
| 217 |
st.markdown('-------------------------')
|
| 218 |
|
|
|
|
| 277 |
st.success('Done!')
|
| 278 |
st.download_button('Download Script',
|
| 279 |
data=script, file_name="script_output.txt", key="<PPT2Script_download>")
|
| 280 |
+
|