From a0ff8c2812b1782dfaa7358bf2e436da44a381e7 Mon Sep 17 00:00:00 2001 From: Gigi Date: Sat, 29 Mar 2025 20:06:08 +0000 Subject: [PATCH] refactor: move process script to src --- process_voice_memos.sh | 49 ---------------------------------------- src/watch_voice_memos.py | 4 ++-- 2 files changed, 2 insertions(+), 51 deletions(-) delete mode 100755 process_voice_memos.sh diff --git a/process_voice_memos.sh b/process_voice_memos.sh deleted file mode 100755 index 643519d..0000000 --- a/process_voice_memos.sh +++ /dev/null @@ -1,49 +0,0 @@ -#!/bin/bash - -# Set the directory paths -VOICE_MEMO_DIR="VoiceMemos" -TRANSCRIPT_DIR="$VOICE_MEMO_DIR/transcripts" - -# Check if the voice memo directory exists -if [ ! -d "$VOICE_MEMO_DIR" ]; then - echo "Error: $VOICE_MEMO_DIR directory does not exist" - exit 1 -fi - -# Create transcripts directory if it doesn't exist -mkdir -p "$TRANSCRIPT_DIR" - -# Check if there are any m4a files in the directory -if ! ls "$VOICE_MEMO_DIR"/*.m4a 1> /dev/null 2>&1; then - echo "No m4a files found in $VOICE_MEMO_DIR" - exit 0 -fi - -# Activate the virtual environment -source vibenv/bin/activate - -# Process each m4a file -for file in "$VOICE_MEMO_DIR"/*.m4a; do - if [ -f "$file" ]; then - # Get the filename without the path and extension - filename=$(basename "$file" .m4a) - transcript_file="$TRANSCRIPT_DIR/$filename.txt" - - # Only process if transcript doesn't exist - if [ ! -f "$transcript_file" ]; then - echo "Processing file: $file" - echo "Transcribing audio..." - - # Use whisper to transcribe the audio with tiny model - whisper "$file" --model tiny --output_dir "$TRANSCRIPT_DIR" --output_format txt - - echo "Transcription saved to: $transcript_file" - echo "----------------------------------------" - else - echo "Skipping $file - transcript already exists" - fi - fi -done - -# Deactivate the virtual environment -deactivate \ No newline at end of file diff --git a/src/watch_voice_memos.py b/src/watch_voice_memos.py index 4639a5d..c38094d 100755 --- a/src/watch_voice_memos.py +++ b/src/watch_voice_memos.py @@ -53,7 +53,7 @@ class VoiceMemoHandler(FileSystemEventHandler): try: self.processing_lock = True print("Processing voice memo...") - result = subprocess.run([str(self.base_dir / 'src' / 'process_voice_memos.sh')], + result = subprocess.run([str(self.base_dir / 'process_voice_memos.sh')], capture_output=True, text=True) if result.returncode == 0: @@ -70,7 +70,7 @@ class VoiceMemoHandler(FileSystemEventHandler): try: self.processing_lock = True print("Processing transcript...") - result = subprocess.run(['python', str(self.base_dir / 'src' / 'summarize_transcripts.py')], + result = subprocess.run(['python', str(self.base_dir / 'summarize_transcripts.py')], capture_output=True, text=True) if result.returncode == 0: