Make scripts better
This commit is contained in:
parent
ba56147e95
commit
e8ad7df469
12 changed files with 614 additions and 432 deletions
|
|
@ -1,60 +1,73 @@
|
|||
#!/bin/bash
|
||||
# generate_report.sh — Full pipeline for generating meeting report (without diagrams)
|
||||
# Usage: ./generate_report.sh /absolute/path/to/meeting_folder
|
||||
# Example: ./generate_report.sh /app/hermes_data/meetings/2026-04-15
|
||||
# generate_report.sh — Simplified pipeline: transcription + merge + PDF
|
||||
# Usage: ./generate_report.sh <meeting-date-dir>
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
||||
|
||||
# Load .env if exists (for hotwords etc.)
|
||||
if [ -f "$SCRIPT_DIR/.env" ]; then
|
||||
set -a
|
||||
source "$SCRIPT_DIR/.env"
|
||||
set +a
|
||||
fi
|
||||
|
||||
if [ $# -lt 1 ]; then
|
||||
echo "Usage: $0 <absolute_path_to_meeting_folder>"
|
||||
echo "Example: $0 /app/hermes_data/meetings/2026-04-15"
|
||||
echo "Usage: $0 <meeting-date-dir>"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
MEETING_DIR="$1"
|
||||
|
||||
# If relative path provided, convert to absolute
|
||||
if [[ "$MEETING_DIR" != /* ]]; then
|
||||
MEETING_DIR="$SCRIPT_DIR/$MEETING_DIR"
|
||||
fi
|
||||
|
||||
# Resolve absolute path
|
||||
MEETING_DIR="$(realpath "$MEETING_DIR")"
|
||||
MEETING_DIR="$SCRIPT_DIR/$1"
|
||||
TRANSCRIPTION_DIR="$MEETING_DIR/transcription"
|
||||
DIAGRAMS_DIR="$MEETING_DIR/diagrams"
|
||||
|
||||
if [ ! -d "$MEETING_DIR" ]; then
|
||||
echo "Error: Meeting directory not found: $MEETING_DIR"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# ============================================================
|
||||
# ------------------------------------------------------------
|
||||
# Step 1: Transcription (skip if already done)
|
||||
# ============================================================
|
||||
if [ -d "$MEETING_DIR/transcription" ] && [ -f "$MEETING_DIR/transcription/plain_text.txt" ]; then
|
||||
echo "[1/2] Transcription already exists, skipping."
|
||||
# ------------------------------------------------------------
|
||||
if [ -d "$TRANSCRIPTION_DIR" ] && [ -f "$TRANSCRIPTION_DIR/plain_text.txt" ]; then
|
||||
echo "[1/3] Transcription already exists, skipping."
|
||||
else
|
||||
echo "[1/2] Running transcription..."
|
||||
echo "[1/3] Running transcription..."
|
||||
bash "$SCRIPT_DIR/transcribe.sh" "$MEETING_DIR"
|
||||
fi
|
||||
|
||||
# ============================================================
|
||||
# Step 2: Generate PDF from markdown
|
||||
# ============================================================
|
||||
echo "[2/2] Generating PDF..."
|
||||
# ------------------------------------------------------------
|
||||
# Step 2: Merge transcriptions (if both saramonic and h2n exist)
|
||||
# ------------------------------------------------------------
|
||||
echo "[2/3] Merging transcriptions where possible..."
|
||||
if [ -f "$TRANSCRIPTION_DIR/saramonic.json" ] && [ -f "$TRANSCRIPTION_DIR/h2n_xy.json" ]; then
|
||||
echo " Merging saramonic (primary) + h2n_xy (secondary) → merged.json"
|
||||
python3 "$SCRIPT_DIR/merge_transcriptions.py" \
|
||||
"$TRANSCRIPTION_DIR/saramonic.json" \
|
||||
"$TRANSCRIPTION_DIR/h2n_xy.json" \
|
||||
"$MEETING_DIR"
|
||||
elif [ -f "$TRANSCRIPTION_DIR/saramonic.json" ] && [ -f "$TRANSCRIPTION_DIR/h2n_ms.json" ]; then
|
||||
echo " Merging saramonic (primary) + h2n_ms (secondary) → merged.json"
|
||||
python3 "$SCRIPT_DIR/merge_transcriptions.py" \
|
||||
"$TRANSCRIPTION_DIR/saramonic.json" \
|
||||
"$TRANSCRIPTION_DIR/h2n_ms.json" \
|
||||
"$MEETING_DIR"
|
||||
else
|
||||
echo " Only one transcription source found or none — copying plain text to merged_plain.txt"
|
||||
# Try to find any existing plain text
|
||||
PLAIN_SRC=$(find "$TRANSCRIPTION_DIR" -name "*_plain.txt" | head -1)
|
||||
if [ -n "$PLAIN_SRC" ]; then
|
||||
cp "$PLAIN_SRC" "$MEETING_DIR/merged_plain.txt"
|
||||
echo " Copied $PLAIN_SRC -> merged_plain.txt"
|
||||
else
|
||||
echo " No plain text found yet — will be created after transcription finishes."
|
||||
fi
|
||||
fi
|
||||
|
||||
# ------------------------------------------------------------
|
||||
# Step 3: Generate PDF from report.md (if exists)
|
||||
# ------------------------------------------------------------
|
||||
echo "[3/3] Generating PDF from report.md (if present)..."
|
||||
REPORT_MD="$MEETING_DIR/report.md"
|
||||
REPORT_PDF="$MEETING_DIR/report.pdf"
|
||||
|
||||
if [ ! -f "$REPORT_MD" ]; then
|
||||
echo " Error: report.md not found at $REPORT_MD"
|
||||
exit 1
|
||||
echo " No report.md found. Agent must write this file first."
|
||||
echo " After writing the report, run: pandoc $REPORT_MD -o $REPORT_PDF ..."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
cd "$MEETING_DIR"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue