Update app.py
Browse files
app.py
CHANGED
@@ -323,8 +323,15 @@ def generate_image_from_prompt(prompt):
|
|
323 |
)
|
324 |
|
325 |
if response.status_code == 200:
|
326 |
-
|
327 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
328 |
else:
|
329 |
print(f"Error: {response.status_code}")
|
330 |
print(f"Response: {response.text}")
|
@@ -539,9 +546,11 @@ def create_interface():
|
|
539 |
state, text, voice_result, text_result, prompt = analyze_voice(audio, current_state)
|
540 |
return state, text, voice_result, text_result, prompt
|
541 |
|
542 |
-
|
543 |
-
|
544 |
-
|
|
|
|
|
545 |
|
546 |
def save_reflection_fixed(text, state):
|
547 |
if not text.strip():
|
|
|
323 |
)
|
324 |
|
325 |
if response.status_code == 200:
|
326 |
+
# 이미지를 임시 파일로 저장
|
327 |
+
timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
|
328 |
+
image_path = f"generated_images/image_{timestamp}.png"
|
329 |
+
os.makedirs("generated_images", exist_ok=True)
|
330 |
+
|
331 |
+
with open(image_path, "wb") as f:
|
332 |
+
f.write(response.content)
|
333 |
+
|
334 |
+
return image_path # 파일 경로 반환
|
335 |
else:
|
336 |
print(f"Error: {response.status_code}")
|
337 |
print(f"Response: {response.text}")
|
|
|
546 |
state, text, voice_result, text_result, prompt = analyze_voice(audio, current_state)
|
547 |
return state, text, voice_result, text_result, prompt
|
548 |
|
549 |
+
def handle_image_generation(prompt):
|
550 |
+
image_path = generate_image_from_prompt(prompt)
|
551 |
+
if image_path and os.path.exists(image_path):
|
552 |
+
return image_path
|
553 |
+
return None
|
554 |
|
555 |
def save_reflection_fixed(text, state):
|
556 |
if not text.strip():
|