feat: implement daily timestamped logs for deeper context retrieval

This commit is contained in:
Adolfo Reyna
2026-03-02 12:22:42 -05:00
parent 25a7179839
commit bf63d00a8a
3 changed files with 22 additions and 8 deletions

View File

@@ -43,16 +43,26 @@ MAX_BUFFER_SECONDS = 15
CONTEXT_CHARS = 500 # How much previous text to keep for context
WORKSPACE_DIR = "workspace"
LOGS_DIR = "logs"
SOUL_PATH = "soul.md"
SYSTEM_SOUND = "/System/Library/Sounds/Tink.aiff"
FOLLOW_UP_SOUND = "/System/Library/Sounds/Submarine.aiff"
# Ensure workspace exists
if not os.path.exists(WORKSPACE_DIR):
os.makedirs(WORKSPACE_DIR)
# Ensure workspace and logs exist
for d in [WORKSPACE_DIR, LOGS_DIR]:
if not os.path.exists(d):
os.makedirs(d)
# Initialize pygame mixer for audio playback
pygame.mixer.init()
def log_transcription(text):
"""Log all transcriptions with timestamps to a daily file."""
if not text:
return
date_str = time.strftime("%Y-%m-%d")
timestamp = time.strftime("%H:%M:%S")
log_file = os.path.join(LOGS_DIR, f"{date_str}.log")
try:
with open(log_file, "a") as f:
f.write(f"[{timestamp}] {text}\n")
except Exception as e:
print(f"Error logging transcription: {e}")
# Global state
audio_queue = queue.Queue()
@@ -196,6 +206,7 @@ def main():
if text:
print(f"[Caption]: {text}")
log_transcription(text)
# Detect Trigger Word
trigger_match = re.search(rf"\b{TRIGGER_WORD}\b", text, re.IGNORECASE)