Files
meetus/process_meeting.py
Mariano Gabriel 8606520ef2 doocus improvemnts
2026-07-05 20:35:44 -03:00

214 lines
6.5 KiB
Python

#!/usr/bin/env python3
"""
Process meeting recordings to extract audio + screen content.
Combines Whisper transcripts with vision analysis or OCR from screen shares.
"""
import argparse
import sys
import logging
from meetus.workflow import WorkflowConfig, ProcessingWorkflow
def setup_logging(verbose: bool = False):
"""Configure logging for the application."""
level = logging.DEBUG if verbose else logging.INFO
logging.basicConfig(
level=level,
format='%(asctime)s - %(levelname)s - %(message)s',
datefmt='%H:%M:%S'
)
# Suppress verbose output from libraries
logging.getLogger('PIL').setLevel(logging.WARNING)
logging.getLogger('easyocr').setLevel(logging.WARNING)
logging.getLogger('paddleocr').setLevel(logging.WARNING)
def main():
parser = argparse.ArgumentParser(
description="Extract screen content from meeting recordings and merge with transcripts",
formatter_class=argparse.RawDescriptionHelpFormatter,
epilog="""
Examples:
# Reference frames for LLM analysis (recommended - transcript includes frame paths)
python process_meeting.py samples/meeting.mkv --run-whisper --embed-images --scene-detection
# Adjust frame extraction quality (lower = smaller files)
python process_meeting.py samples/meeting.mkv --run-whisper --embed-images --embed-quality 60 --scene-detection
# Iterate on scene threshold (reuse whisper transcript)
python process_meeting.py samples/meeting.mkv --embed-images --scene-detection --scene-threshold 5 --skip-cache-frames
"""
)
# Required arguments
parser.add_argument(
'video',
help='Path to video file'
)
# Whisper options
parser.add_argument(
'--transcript', '-t',
help='Path to Whisper transcript (JSON or TXT)',
default=None
)
parser.add_argument(
'--run-whisper',
action='store_true',
help='Run Whisper transcription before processing'
)
parser.add_argument(
'--whisper-model',
choices=['tiny', 'base', 'small', 'medium', 'large'],
help='Whisper model to use (default: medium)',
default='medium'
)
parser.add_argument(
'--diarize',
action='store_true',
help='Use WhisperX with speaker diarization (requires whisperx and HuggingFace token)'
)
parser.add_argument(
'--language',
help='Language of the audio (e.g. en, es, fr). Default: auto-detect',
default=None
)
parser.add_argument(
'--transcript-formats',
help='Comma-separated extra transcript/diarization formats to write '
'alongside JSON (choices: srt, vtt, txt, tsv, or all). JSON is '
'always written as the base for the enhanced transcript. '
'Only produced when transcription actually runs (use '
'--skip-cache-whisper to regenerate). Example: --transcript-formats srt,txt',
default=None
)
# Output options
parser.add_argument(
'--output', '-o',
help='Output file for enhanced transcript (default: auto-generated in output directory)',
default=None
)
parser.add_argument(
'--output-dir',
help='Base directory for outputs (default: output/)',
default='output'
)
parser.add_argument(
'--out-format',
help='Run-folder name template. Tokens: {date} {run} {stem} {name}. '
'Default: "{date}-{run:03d}-{stem}". Omit {run} for a stable folder '
'(e.g. "{name}.meetus" → a docs-coherent sidecar for doocus).',
default=None
)
# Frame extraction options
parser.add_argument(
'--interval',
type=int,
help='Extract frame every N seconds (default: 5)',
default=5
)
parser.add_argument(
'--scene-detection',
action='store_true',
help='Use scene detection instead of interval extraction'
)
parser.add_argument(
'--scene-threshold',
type=float,
help='Scene detection threshold (0-100, lower=more sensitive, default: 15)',
default=15.0
)
# Processing options
parser.add_argument(
'--no-cache',
action='store_true',
help='Disable caching - reprocess everything even if outputs exist'
)
parser.add_argument(
'--skip-cache-frames',
action='store_true',
help='Skip cached frames, re-extract from video (but keep whisper cache)'
)
parser.add_argument(
'--skip-cache-whisper',
action='store_true',
help='Skip cached whisper transcript, re-run transcription (but keep frames cache)'
)
parser.add_argument(
'--extract-only',
action='store_true',
help='Only extract frames + transcript, skip the enhanced-transcript merge'
)
parser.add_argument(
'--format',
choices=['detailed', 'compact'],
help='Output format style (default: detailed)',
default='detailed'
)
parser.add_argument(
'--embed-images',
action='store_true',
help='Reference extracted frames in the transcript for the LLM to read '
'(now the default behavior; flag kept for compatibility)'
)
parser.add_argument(
'--embed-quality',
type=int,
help='JPEG quality for extracted frames (default: 80, lower = smaller files)',
default=80
)
# Logging
parser.add_argument(
'--verbose', '-v',
action='store_true',
help='Enable verbose logging (DEBUG level)'
)
args = parser.parse_args()
# Setup logging
setup_logging(args.verbose)
try:
# Create workflow configuration
config = WorkflowConfig(**vars(args))
# Run processing workflow
workflow = ProcessingWorkflow(config)
result = workflow.run()
# Print final summary
print("\n" + "=" * 80)
print("✓ SUCCESS!")
print("=" * 80)
print(f"Output directory: {result['output_dir']}")
if result.get('enhanced_transcript'):
print(f"Enhanced transcript ready for AI summarization!")
print("=" * 80)
return 0
except FileNotFoundError as e:
logging.error(f"File not found: {e}")
return 1
except RuntimeError as e:
logging.error(f"Processing failed: {e}")
return 1
except KeyboardInterrupt:
logging.warning("\nProcessing interrupted by user")
return 130
except Exception as e:
logging.exception(f"Unexpected error: {e}")
return 1
if __name__ == '__main__':
sys.exit(main())