Update app.py
Browse files
app.py
CHANGED
@@ -158,7 +158,7 @@ def create_interface():
|
|
158 |
"voice_analysis": None,
|
159 |
"final_prompt": ""
|
160 |
})
|
161 |
-
|
162 |
# 헤더
|
163 |
header = gr.Markdown("# 디지털 굿판")
|
164 |
user_display = gr.Markdown("")
|
@@ -192,6 +192,25 @@ def create_interface():
|
|
192 |
label="기록된 감상들"
|
193 |
)
|
194 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
195 |
# 기원
|
196 |
with gr.Tab("기원"):
|
197 |
gr.Markdown("## 기원 - 목소리로 전하기")
|
|
|
158 |
"voice_analysis": None,
|
159 |
"final_prompt": ""
|
160 |
})
|
161 |
+
z
|
162 |
# 헤더
|
163 |
header = gr.Markdown("# 디지털 굿판")
|
164 |
user_display = gr.Markdown("")
|
|
|
192 |
label="기록된 감상들"
|
193 |
)
|
194 |
|
195 |
+
def save_reflection(text, state):
|
196 |
+
"""감상 저장"""
|
197 |
+
if not text.strip():
|
198 |
+
return state, state["reflections"]
|
199 |
+
|
200 |
+
try:
|
201 |
+
current_time = datetime.now().strftime("%H:%M:%S")
|
202 |
+
sentiment = text_analyzer(text)[0]
|
203 |
+
new_reflection = [current_time, text, f"{sentiment['label']} ({sentiment['score']:.2f})"]
|
204 |
+
|
205 |
+
if "reflections" not in state:
|
206 |
+
state["reflections"] = []
|
207 |
+
|
208 |
+
state["reflections"].append(new_reflection)
|
209 |
+
return state, state["reflections"]
|
210 |
+
except Exception as e:
|
211 |
+
print(f"Error in save_reflection: {str(e)}")
|
212 |
+
return state, []
|
213 |
+
|
214 |
# 기원
|
215 |
with gr.Tab("기원"):
|
216 |
gr.Markdown("## 기원 - 목소리로 전하기")
|