KeenWoo commited on
Commit
c504bd6
Β·
verified Β·
1 Parent(s): 3b5052a

Delete memory_manager.py

Browse files
Files changed (1) hide show
  1. memory_manager.py +0 -68
memory_manager.py DELETED
@@ -1,68 +0,0 @@
1
- # This is the updated gradio code for the Memory Manager tab with full features
2
- # including image, video, audio, message, voice input, and annotation capability
3
-
4
- import gradio as gr
5
- import os
6
- from datetime import datetime
7
-
8
- UPLOAD_FOLDER = "media_archive"
9
- os.makedirs(UPLOAD_FOLDER, exist_ok=True)
10
-
11
- def save_uploaded_file(file, file_type, annotation):
12
- timestamp = datetime.now().strftime("%Y%m%d-%H%M%S")
13
- filename = f"{file_type}_{timestamp}_{file.name}"
14
- save_path = os.path.join(UPLOAD_FOLDER, filename)
15
- file.save(save_path)
16
- return f"βœ… Saved {file_type}: {file.name}\nπŸ“Ž Annotation: {annotation}"
17
-
18
- with gr.Blocks() as memory_manager:
19
- gr.Markdown("""# 🧠 Memory Manager
20
- Upload images, videos, audio clips, voice notes, or written messages to help personalize the AI companion.
21
- Each upload can be annotated with notes, emotions, or reminders.""")
22
-
23
- with gr.Tabs():
24
- with gr.Tab("πŸ–ΌοΈ Image"):
25
- image_file = gr.File(type="filepath", label="Upload Image")
26
- image_annotation = gr.Textbox(label="Annotation or Note")
27
- image_button = gr.Button("Save Image Memory")
28
- image_output = gr.Textbox()
29
- image_button.click(save_uploaded_file, inputs=[image_file, gr.Textbox(value="image", visible=False), image_annotation], outputs=image_output)
30
-
31
- with gr.Tab("πŸŽ₯ Video"):
32
- video_file = gr.File(type="filepath", label="Upload Video")
33
- video_annotation = gr.Textbox(label="Annotation or Note")
34
- video_button = gr.Button("Save Video Memory")
35
- video_output = gr.Textbox()
36
- video_button.click(save_uploaded_file, inputs=[video_file, gr.Textbox(value="video", visible=False), video_annotation], outputs=video_output)
37
-
38
- with gr.Tab("🎧 Audio"):
39
- audio_file = gr.File(type="filepath", label="Upload Audio Clip")
40
- audio_annotation = gr.Textbox(label="Annotation or Note")
41
- audio_button = gr.Button("Save Audio Memory")
42
- audio_output = gr.Textbox()
43
- audio_button.click(save_uploaded_file, inputs=[audio_file, gr.Textbox(value="audio", visible=False), audio_annotation], outputs=audio_output)
44
-
45
- with gr.Tab("πŸ—£οΈ Voice Input"):
46
- # voice_input = gr.Audio(source="microphone", type="filepath", label="Record Voice Note")
47
- voice_input = gr.Audio(type="filepath", label="Record Voice Note", interactive=True)
48
- voice_annotation = gr.Textbox(label="Annotation or Emotion")
49
- voice_button = gr.Button("Save Voice Input")
50
- voice_output = gr.Textbox()
51
- voice_button.click(save_uploaded_file, inputs=[voice_input, gr.Textbox(value="voice", visible=False), voice_annotation], outputs=voice_output)
52
-
53
- with gr.Tab("✍️ Message"):
54
- message_text = gr.Textbox(label="Enter memory message")
55
- message_annotation = gr.Textbox(label="Annotation or Emotion")
56
- message_button = gr.Button("Save Text Memory")
57
- message_output = gr.Textbox()
58
-
59
- def save_text_message(msg, ann):
60
- timestamp = datetime.now().strftime("%Y%m%d-%H%M%S")
61
- filename = f"text_{timestamp}.txt"
62
- with open(os.path.join(UPLOAD_FOLDER, filename), 'w') as f:
63
- f.write(f"{msg}\n\n---\nAnnotation: {ann}")
64
- return f"βœ… Saved message at {timestamp}"
65
-
66
- message_button.click(save_text_message, inputs=[message_text, message_annotation], outputs=message_output)
67
-
68
- # memory_manager.launch()