Hyeonseo commited on
Commit
32a03d4
β€’
1 Parent(s): fc5c97d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -15
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
- λ„ˆκ°€ Marp λ¬Έλ²•μœΌλ‘œ PPTλ₯Ό μ œμž‘ν•˜λŠ” λ””μžμ΄λ„ˆλΌκ³  κ°€μ •ν•˜κ³ , %sμž₯의 PPTλ₯Ό μž‘μ„±ν•΄.
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
- subprocess.run(["./pandoc-2.14.2/bin/pandoc", "text2ppt_input.md", "-t", "pptx", "-o", "text2ppt_output.pptx"], capture_output=True)
 
 
 
 
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
- subprocess.run(["./pandoc-2.14.2/bin/pandoc", "text2ppt_test.md", "-t", "pptx", "-o", "output.pptx"], capture_output=True)
 
 
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', 'gaia', 'uncover'])
 
 
 
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
+