PLXR commited on
Commit
4b69b88
ยท
verified ยท
1 Parent(s): 40d4f83

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +39 -8
app.py CHANGED
@@ -56,6 +56,7 @@ if "script" not in st.session_state: st.session_state["script"] = ""
56
  if "image_data" not in st.session_state: st.session_state["image_data"] = None
57
  if "result_card_data" not in st.session_state: st.session_state["result_card_data"] = None
58
  if "audio_data" not in st.session_state: st.session_state["audio_data"] = None
 
59
 
60
  # STEP 1: ์ฃผ์ œ ์ƒ์„ฑ
61
  st.header(f"1๏ธโƒฃ {target_month}์›” ์ฃผ์ œ ๋ฝ‘๊ธฐ")
@@ -91,13 +92,36 @@ if st.session_state["topics"]:
91
  # STEP 3: ํ™•์ธ ๋ฐ ๋‹ค์šด๋กœ๋“œ
92
  if st.session_state["script"]:
93
  st.markdown("---")
94
- st.header("3๏ธโƒฃ TTS ์ƒ์„ฑ ๋ฐ ๋‹ค์šด๋กœ๋“œ")
 
95
  col1, col2 = st.columns([1.3, 1])
96
 
97
  with col1:
98
- st.subheader("๐Ÿ“ ๋Œ€๋ณธ & ์˜ค๋””์˜ค")
99
- edited_script = st.text_area("๋Œ€๋ณธ ์ˆ˜์ •", value=st.session_state["script"], height=300)
100
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
101
  if st.button("๐Ÿ”Š ๋ชฉ์†Œ๋ฆฌ ์ž…ํžˆ๊ธฐ (TTS ์ƒ์„ฑ)"):
102
  with st.spinner("์˜ค๋””์˜ค ์ƒ์„ฑ ์ค‘..."):
103
  audio_bytes, error_msg = logic_tts.generate_audio(
@@ -110,19 +134,28 @@ if st.session_state["script"]:
110
  else:
111
  st.error(f"์˜ค๋””์˜ค ์ƒ์„ฑ ์‹คํŒจ: {error_msg}")
112
 
 
113
  if st.session_state["audio_data"]:
114
  st.markdown("### ๐Ÿ’พ ์ „์ฒด ํŒŒ์ผ ๋‹ค์šด๋กœ๋“œ")
115
  zip_buffer = io.BytesIO()
116
  with zipfile.ZipFile(zip_buffer, "w") as zf:
 
117
  if st.session_state["image_data"]:
118
  zf.writestr(f"character_{gender_select}.png", st.session_state["image_data"])
119
  if st.session_state.get("result_card_data"):
120
  zf.writestr("result_card.png", st.session_state["result_card_data"])
 
 
121
  zf.writestr("audio.mp3", st.session_state["audio_data"])
122
  srt_content = logic_tts.create_srt_from_text(edited_script)
123
  zf.writestr("subtitles.srt", srt_content)
124
  zf.writestr("script.txt", edited_script)
125
- # [NEW] Kling AI ํ”„๋กฌํ”„ํŠธ๋„ ํ…์ŠคํŠธ ํŒŒ์ผ๋กœ ๊ฐ™์ด ๋„ฃ์–ด๋“œ๋ฆผ
 
 
 
 
 
126
  zf.writestr("kling_prompt.txt", KLING_PROMPT)
127
 
128
  st.download_button(
@@ -137,9 +170,7 @@ if st.session_state["script"]:
137
  st.subheader("๐Ÿ–ผ๏ธ ์ƒ์„ฑ๋œ ์ด๋ฏธ์ง€")
138
  if st.session_state["image_data"]:
139
  st.image(st.session_state["image_data"], caption="์บ๋ฆญํ„ฐ", use_column_width=True)
140
-
141
- # [NEW] ์—ฌ๊ธฐ์— Kling AI ํ”„๋กฌํ”„ํŠธ ๋ณต์‚ฌ ๊ธฐ๋Šฅ ์ถ”๊ฐ€!
142
- st.markdown("๐Ÿ‘‡ **Kling AI ๋น„๋””์˜คํ™” ํ”„๋กฌํ”„ํŠธ (๋ณต์‚ฌํ•ด์„œ ์“ฐ์„ธ์š”)**")
143
  st.code(KLING_PROMPT, language="text")
144
 
145
  if st.session_state.get("result_card_data"):
 
56
  if "image_data" not in st.session_state: st.session_state["image_data"] = None
57
  if "result_card_data" not in st.session_state: st.session_state["result_card_data"] = None
58
  if "audio_data" not in st.session_state: st.session_state["audio_data"] = None
59
+ if "caption" not in st.session_state: st.session_state["caption"] = "" # [NEW] ์„ค๋ช…๊ธ€ ์ €์žฅ์šฉ
60
 
61
  # STEP 1: ์ฃผ์ œ ์ƒ์„ฑ
62
  st.header(f"1๏ธโƒฃ {target_month}์›” ์ฃผ์ œ ๋ฝ‘๊ธฐ")
 
92
  # STEP 3: ํ™•์ธ ๋ฐ ๋‹ค์šด๋กœ๋“œ
93
  if st.session_state["script"]:
94
  st.markdown("---")
95
+ st.header("3๏ธโƒฃ ์ƒ์„ธ ์„ค๋ช…๊ธ€ & TTS & ๋‹ค์šด๋กœ๋“œ")
96
+
97
  col1, col2 = st.columns([1.3, 1])
98
 
99
  with col1:
100
+ st.subheader("๐Ÿ“ ๋Œ€๋ณธ & ์„ค๋ช…๊ธ€")
101
+ # 1. ๋Œ€๋ณธ ์ˆ˜์ • ์˜์—ญ
102
+ edited_script = st.text_area("์‡ผ์ธ  ๋Œ€๋ณธ ์ˆ˜์ •", value=st.session_state["script"], height=200)
103
+
104
+ # 2. ์„ค๋ช…๊ธ€(์บก์…˜) ์ƒ์„ฑ ๋ฒ„ํŠผ
105
+ if st.button("๐Ÿ“ ์ธ์Šคํƒ€/์œ ํŠœ๋ธŒ ์„ค๋ช…๊ธ€(์ƒ์„ธํ’€์ด+CTA) ์ƒ์„ฑ"):
106
+ if not st.session_state["selected_topic"]:
107
+ st.warning("์ฃผ์ œ๊ฐ€ ์„ ํƒ๋˜์ง€ ์•Š์•˜์Šต๋‹ˆ๋‹ค.")
108
+ else:
109
+ with st.spinner("์ „์ž์ฑ… ํ™๋ณด ๋ฉ˜ํŠธ๊ฐ€ ํฌํ•จ๋œ ์ƒ์„ธ ํ’€์ด๋ฅผ ์ž‘์„ฑ ์ค‘์ž…๋‹ˆ๋‹ค..."):
110
+ caption_text = logic_saju.generate_caption(
111
+ st.session_state["selected_topic"],
112
+ edited_script,
113
+ google_api_key
114
+ )
115
+ st.session_state["caption"] = caption_text
116
+ st.success("์„ค๋ช…๊ธ€ ์ƒ์„ฑ ์™„๋ฃŒ!")
117
+
118
+ # 3. ์„ค๋ช…๊ธ€ ํ‘œ์‹œ ์˜์—ญ (์ƒ์„ฑ๋œ ๊ฒฝ์šฐ์—๋งŒ)
119
+ if "caption" in st.session_state and st.session_state["caption"]:
120
+ st.text_area("์ƒ์„ธ ์„ค๋ช…๊ธ€ (๋ณต์‚ฌํ•ด์„œ ์‚ฌ์šฉ)", value=st.session_state["caption"], height=300)
121
+
122
+ st.markdown("---")
123
+
124
+ # 4. TTS ์ƒ์„ฑ ๋ฒ„ํŠผ
125
  if st.button("๐Ÿ”Š ๋ชฉ์†Œ๋ฆฌ ์ž…ํžˆ๊ธฐ (TTS ์ƒ์„ฑ)"):
126
  with st.spinner("์˜ค๋””์˜ค ์ƒ์„ฑ ์ค‘..."):
127
  audio_bytes, error_msg = logic_tts.generate_audio(
 
134
  else:
135
  st.error(f"์˜ค๋””์˜ค ์ƒ์„ฑ ์‹คํŒจ: {error_msg}")
136
 
137
+ # 5. ๋‹ค์šด๋กœ๋“œ ๋ฒ„ํŠผ
138
  if st.session_state["audio_data"]:
139
  st.markdown("### ๐Ÿ’พ ์ „์ฒด ํŒŒ์ผ ๋‹ค์šด๋กœ๋“œ")
140
  zip_buffer = io.BytesIO()
141
  with zipfile.ZipFile(zip_buffer, "w") as zf:
142
+ # ์ด๋ฏธ์ง€๋“ค
143
  if st.session_state["image_data"]:
144
  zf.writestr(f"character_{gender_select}.png", st.session_state["image_data"])
145
  if st.session_state.get("result_card_data"):
146
  zf.writestr("result_card.png", st.session_state["result_card_data"])
147
+
148
+ # ์˜ค๋””์˜ค & ์ž๋ง‰ & ๋Œ€๋ณธ
149
  zf.writestr("audio.mp3", st.session_state["audio_data"])
150
  srt_content = logic_tts.create_srt_from_text(edited_script)
151
  zf.writestr("subtitles.srt", srt_content)
152
  zf.writestr("script.txt", edited_script)
153
+
154
+ # [NEW] ์„ค๋ช…๊ธ€๋„ ์ €์žฅ
155
+ if "caption" in st.session_state and st.session_state["caption"]:
156
+ zf.writestr("description.txt", st.session_state["caption"])
157
+
158
+ # Kling AI ํ”„๋กฌํ”„ํŠธ
159
  zf.writestr("kling_prompt.txt", KLING_PROMPT)
160
 
161
  st.download_button(
 
170
  st.subheader("๐Ÿ–ผ๏ธ ์ƒ์„ฑ๋œ ์ด๋ฏธ์ง€")
171
  if st.session_state["image_data"]:
172
  st.image(st.session_state["image_data"], caption="์บ๋ฆญํ„ฐ", use_column_width=True)
173
+ st.markdown("๐Ÿ‘‡ **Kling AI ๋น„๋””์˜คํ™” ํ”„๋กฌํ”„ํŠธ**")
 
 
174
  st.code(KLING_PROMPT, language="text")
175
 
176
  if st.session_state.get("result_card_data"):