Skip to content

Add Quick Generate feature and multi-provider TTS support - #250

Open
Moreno360 wants to merge 3 commits into
FujiwaraChoki:mainfrom
Moreno360:claude/improve-code-quality-7cdPR
Open

Moreno360 wants to merge 3 commits into
FujiwaraChoki:mainfrom
Moreno360:claude/improve-code-quality-7cdPR

Conversation

@Moreno360

Copy link
Copy Markdown

Summary

This PR introduces a new "Quick Generate" feature that enables one-prompt video creation, along with comprehensive multi-provider Text-to-Speech (TTS) support. The changes streamline the video generation workflow and add configuration caching for improved performance.

Key Changes

Quick Generate Feature

  • Added interactive quick_generate() function in main.py that guides users through a complete video generation workflow in a single session
  • Supports selecting language, TTS provider, voice, and subtitle style before generation
  • Includes optional YouTube upload with account selection
  • Integrated as the first menu option in the main interface

Multi-Provider TTS Support

  • Refactored TTS class to support both Edge TTS (300+ voices, free) and KittenTTS (8 English voices)
  • Added list_voices() static method with language filtering capability
  • Implemented provider-specific synthesis methods (_synthesize_edge() and _synthesize_kitten())
  • Edge TTS outputs MP3 natively; both formats are compatible with MoviePy and Whisper
  • Updated config to include tts_provider setting (defaults to "edge_tts")

Configuration Improvements

  • Implemented mtime-based caching in config.py to avoid repeated file reads
  • Added get_tts_provider() and get_subtitle_style() configuration functions
  • Updated config.example.json with new TTS and subtitle style settings

YouTube Class Enhancements

  • Added YouTube.for_generation() class method to create generation-only instances without browser/upload overhead
  • Improved error handling in generate_script(), generate_metadata(), and generate_prompts() with retry limits (max 5 attempts)
  • Fixed script length validation to truncate instead of infinite retry
  • Enhanced image persistence with directory creation safety
  • Updated TTS integration to handle variable output formats

UI/UX Improvements

  • Updated main menu with new "Quick Generate" option and improved formatting
  • Added language selection with 12 language options
  • Added subtitle style selection with 6 preset options
  • Improved voice selection with pagination (max 20 displayed) and search by name
  • Enhanced colored output and user prompts throughout

Code Quality

  • Replaced os.system() calls with subprocess.run() for better error handling
  • Added timeout parameter to HTTP requests in Outreach
  • Improved error handling in subprocess calls with return code checking
  • Fixed JSON parsing exception handling to catch json.JSONDecodeError specifically
  • Removed unused imports (e.g., termcolor from YouTube.py)

Menu Structure

  • Shifted all existing menu options down by one position to accommodate Quick Generate
  • Updated option numbering throughout (YouTube: 2→2, Twitter: 2→3, Affiliate: 3→4, Outreach: 4→5, Quit: 5→6)

Notable Implementation Details

  • Quick Generate temporarily overrides config.get_subtitle_style() during generation to apply user selection
  • Voice selection supports both numeric index selection and fuzzy name matching
  • TTS provider detection is case-insensitive
  • Configuration cache invalidation is based on file modification time (mtime)
  • Retry logic includes exponential feedback to users about attempt numbers

https://claude.ai/code/session_01Ua58n8SZptC1WQf6gfJDpK

claude added 3 commits April 9, 2026 09:59
… config I/O

- Fix bare except clause in YouTube.py upload_video (was catching SystemExit/KeyboardInterrupt)
- Add max retry limits (5) to recursive generate_script/generate_metadata/generate_prompts to prevent stack overflow
- Replace os.system() with subprocess.run() in utils.py and Outreach.py (safer, no shell injection risk)
- Add request timeouts (30-60s) to all requests.get() calls in Outreach.py that were missing them
- Add subprocess return code checking for CRON jobs in main.py
- Cache config.json reads with mtime-based invalidation in config.py (eliminates ~30 redundant file reads per call)
- Replace raw print(colored()) calls with status functions (info/success/error/warning) for consistent logging
- Narrow exception types: json.JSONDecodeError instead of Exception for JSON parsing, TimeoutException for Selenium waits
- Remove unused imports (termcolor.colored from YouTube.py and Twitter.py)
- Ensure .mp directory exists before writing images

https://claude.ai/code/session_01Ua58n8SZptC1WQf6gfJDpK
New "Quick Generate" mode (option 1 in main menu):
- One-prompt video creation: describe your video and get a complete Short
- Interactive language picker (12 languages + custom)
- TTS provider selection (Edge TTS or Kitten TTS)
- Voice browser with language filtering and search
- Subtitle style picker (6 presets)
- Optional YouTube upload after generation

Multi-provider TTS system (src/classes/Tts.py):
- Edge TTS: 300+ Microsoft neural voices, free, high quality, many languages
- Kitten TTS: 8 local English voices (preserved for offline use)
- Voice listing API with language filtering
- Automatic format handling (Edge outputs MP3, compatible with full pipeline)

Subtitle style presets (YouTube.py):
- yellow_bold (classic), white_shadow, neon_green, red_impact, minimal_white, cyan_modern
- Configurable via config.json "subtitle_style" key

YouTube.for_generation() classmethod:
- Creates generation-only instances without browser/Selenium setup
- Enables video creation without needing a YouTube account configured

Updated config: tts_provider, tts_voice defaults, subtitle_style
Added edge-tts to requirements.txt

https://claude.ai/code/session_01Ua58n8SZptC1WQf6gfJDpK
…vailable

KittenTTS depends on misaki>=0.9.4 which fails to install on some platforms.
Since Edge TTS is now the default provider, move KittenTTS to an optional
manual install with a clear error message if someone selects it without
having it installed.

https://claude.ai/code/session_01Ua58n8SZptC1WQf6gfJDpK
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants