#!/usr/bin/env python3 """ Generate TTS narration for demo video and combine with video. Usage: python scripts/generate_narration.py Output: demo_output/demo_final.mp4 """ import subprocess import pathlib import json AUDIO_DIR = pathlib.Path("demo_output/audio") AUDIO_DIR.mkdir(parents=True, exist_ok=True) VIDEO_RAW = pathlib.Path("demo_output/demo_video_raw.mp4") FINAL_VIDEO = pathlib.Path("demo_output/demo_final.mp4") # Timeline (seconds into video): # 0.0 - 2.0: Title: "Color-UX-Access" # 2.0 - 4.0: Title: "What is Color Vision Deficiency?" # 4.0 - 8.0: Form validation analysis # 8.0 - 10.3: Accessible fix shown # 10.3 - 14.6: Status badges analysis # 14.6 - 16.9: Accessible fix shown # 16.9 - 21.2: Button panel analysis # 21.2 - 23.0: Accessible fix shown # 23.0 - 27.0: Closing CTA NARRATIONS = [ (0.0, 2.0, "Color-UX-Access: automated colorblind accessibility testing with 32-billion parameter vision language models."), (2.0, 4.0, "Color vision deficiency affects one in twelve men, and one in two hundred women. That's over 350 million people worldwide who maystruggle to use your product."), (4.0, 8.0, "Let's test this form for colorblind accessibility. Uploading the screenshot — our pipeline simulates Deuteranopia, Protanopia, and Tritanopia, then sends all variants to the vision language model for WCAG 2.1 analysis."), (8.0, 10.3, "The model detected low contrast text and color-only form validation that fails for colorblind users. Remediations are provided for each finding."), (10.3, 14.6, "Now testing the status badges interface. The color-only indicators become indistinguishable under multiple CVD simulations, flagging a critical accessibility failure."), (14.6, 16.9, "Adding text labels and icons resolves the issue, making status comprehensible without relying on color alone."), (16.9, 21.2, "Finally, the button panel. Color-only buttons fail for users with red-green color blindness. The WCAG standard requires either a text label, an icon, or a 3-to-1 luminance contrast."), (21.2, 23.0, "Accessible button design passes all CVD simulations. The fix is simple: add text labels to every action button."), (23.0, 27.0, "Try Color-UX-Access now at salgadev-color-ux-access dot H F space dot io. Built on CohereLabs Aya-Vision-32B, deployed on HuggingFace Spaces. Open source on GitHub."), ] def generate_tts(text: str, output_path: pathlib.Path): """Use Hermes text_to_speech tool.""" # Write the narration text to a temp file for reference print(f"TTS: {text[:60]}... -> {output_path}") # Use curl to call the TTS API directly (MiniMax) # We'll write the audio chunks to files import urllib.request import urllib.parse import os # Get HF_TOKEN from environment for MiniMax API hf_token = os.environ.get("HF_TOKEN", "") # Actually use the built-in text_to_speech via a workaround: # Write script that we'll combine pass def combine_audio_video(): """Concatenate audio segments and merge with video.""" # For now, create a simple version without TTS # (Will be combined after TTS generation) pass if __name__ == "__main__": # Check video exists if VIDEO_RAW.exists(): size = VIDEO_RAW.stat().st_size / 1024 / 1024 print(f"Video raw: {VIDEO_RAW} ({size:.1f} MB)") print(f"Audio dir: {AUDIO_DIR}") print(f"Final video target: {FINAL_VIDEO}") print("\nNarration segments:") for start, end, text in NARRATIONS: print(f" {start:.1f}-{end:.1f}s: {text[:80]}...")