Presentation file

This is the Presentation file which details the entire project that we have worked on. It explains the entire codebase in depth
pull/2291/head
Soham Doshi 5 months ago committed by GitHub
parent 3d4c34d60c
commit 573652e172
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -0,0 +1,685 @@
# RedditVideoMakerBot: A Comprehensive and Detailed Overview 🌟
## Presentation Outline 📋
- [Introduction](#introduction) ✨
- [GUI](#gui) 🖥️
- [Background](#background) 🎥
- [INDEX](#index) 📄
- [SETTINGS](#settings) ⚙️
- [LAYOUT](#layout) 🏗️
- [TTS](#tts) 🗣️
- [TTS Codebase](#tts-codebase) 💻
- [TTS Functionality](#tts-functionality) 🔊
- [Fonts](#fonts) 🔠
- [Reddit](#reddit) 📱
- [Video Creation](#video-creation) 🎬
- [Screenshotdownloader](#screenshotdownloader) 📸
- [Voice](#voice) 🎙️
- [Final Video](#final-video) 📽️
- [Cookies](#cookies) 🍪
- [Pylint Configuration](#pylint-configuration) 🛠️
- [Docker Setup](#docker-setup) 🐳
- [Flask GUI](#flask-gui) 🌐
- [Web Layout](#web-layout) 🎨
- [TTS Testing](#tts-testing) 🔍
- [Build Script](#build-script) 🔧
- [Install Script](#install-script) 📦
- [Requirements](#requirements) 📋
- [Run Shell Script](#run-shell-script) 🚀
- [Run Batch Script](#run-batch-script) 🖱️
---
## Introduction ✨
The **RedditVideoMakerBot** is a *sophisticated* open-source project that transforms Reddit posts and comments into **engaging video content** 🎥. With a modular architecture, it leverages web scraping, advanced text-to-speech (TTS) synthesis, video editing, and a user-friendly web interface. This presentation dives deep into its components, based on detailed documentation 📚. Perfect for creators repurposing Reddit discussions, it offers *extensive customization* and API integration, blending Python scripting, Jinja2 templating, and modern web tech for hobbyists and pros alike! 🚀
---
## GUI 🖥️
### Background 🎥
#### Purpose
The **Background** module manages video and audio assets, ensuring videos are *visually and audibly stunning* 🌟. It handles dynamic selection, downloading, and processing to match video length and style.
#### Key Functions
- **📂 `load_background_options() -> Dict[str, Dict[str, Any]]`**:
- *Purpose*: Loads options from `background_videos.json` and `background_audios.json`.
- *Functionality*: Parses JSON, removes `__comment` keys, and converts positioning into lambdas (e.g., `("center", pos + t)`). Returns a nested dictionary for video/audio configs.
- **⏱️ `get_start_and_end_times(video_length: int, length_of_clip: int) -> Tuple[int, int]`**:
- *Purpose*: Generates random start/end times for background clips.
- *Functionality*: Uses a 180-second offset, ensures clip length, returns `(random_time, random_time + video_length)`.
- **⚙️ `get_background_config(mode: str) -> Any`**:
- *Purpose*: Retrieves video or audio configuration.
- *Functionality*: Fetches user choice from `settings.config`, defaults to random if invalid.
- **📥 `download_background_video(background_config: Tuple[str, str, str, Any]) -> None`**:
- *Purpose*: Downloads YouTube videos.
- *Functionality*: Creates directories, uses `yt-dlp` for 1080p MP4, skips existing files, logs success.
- **🎵 `download_background_audio(background_config: Tuple[str, str, str]) -> None`**:
- *Purpose*: Downloads background audio.
- *Functionality*: Extracts best audio format, skips existing files.
- **✂️ `chop_background(background_config: Dict[str, Tuple], video_length: int, reddit_object: dict) -> str`**:
- *Purpose*: Clips and saves media segments.
- *Functionality*: Processes audio (if volume > 0) and video with `ffmpeg_extract_subclip`, returns credit.
#### Summary
This module is the *backbone* for background assets, boosting video quality and variety! 🎉
---
### INDEX 📄
#### Purpose
The **INDEX** module crafts an HTML template (via Jinja2) for a webpage to *display and manage* Reddit-derived videos, with search, dynamic cards, and clipboard support 📋.
#### Structure
- **Main Content**:
- 🔍 Search input (`class="searchFilter"`) triggers `searchFilter()` on keyup.
- 📊 Bootstrap grid (`#videos`) fills with video cards.
- **JavaScript**:
- ⏳ **`timeSince(date)`**: Shows elapsed time (e.g., "3 days ago").
- 🎴 **Load Video Cards**: Fetches `videos.json`, sorts by time, builds cards with subreddit, title, and buttons (view, download, copy).
- 💡 **Tooltip Initialization**: Applies Bootstrap tooltips, hides on click.
- 📋 **Clipboard Functionality**: Uses ClipboardJS for copying text (e.g., subreddit, hashtags) with "Copied!" feedback.
- ✍️ **Text Formatting**:
- **`getCopyData()`**: Combines subreddit, title, credit.
- **`checkTitle()`**: Picks `reddit_title` or `filename` (no extension).
- 🔎 **Search Filter**: Filters cards by case-insensitive `.card-text` match.
#### Assumptions
- `videos.json` format: `[{ "subreddit": "funny", "time": 1610000000, "reddit_title": "Cool Video", "filename": "cool-video.mp4", "id": "abc123", "background_credit": "CreatorX" }]`.
- Dependencies: Bootstrap, jQuery, ClipboardJS, Bootstrap Icons.
#### Summary
Delivers an *interactive, responsive* interface for video management, with real-time filtering and copying! 😄
---
### SETTINGS ⚙️
#### Purpose
The **SETTINGS** module builds a Jinja2-powered HTML page for configuring Reddit credentials, content, general options, and TTS settings 🔧.
#### Structure
- **Reddit Credentials**:
- 🔐 Inputs for `client_id`, `client_secret`, `username`, `password`, `2fa` checkbox with tooltips.
- **Reddit Thread**:
- 🎲 `random` checkbox, `subreddit` (multi-support), `post_id`, `max_comment_length` (slider), `post_lang`, `min_comments` (slider).
- **General Settings**:
- 🔞 `allow_nsfw`, `theme` (dark/light), `times_to_run`, `opacity`, `transition` sliders, `background_choice`, `background_thumbnail`, font options (`family`, `size`, `color`).
- **TTS Settings**:
- 🗣️ `voice_choice` (e.g., Streamlabspolly, TikTok), voice dropdowns (e.g., `aws_polly_voice`), `tiktok_sessionid`, `python_voice`, `py_voice_num`, `silence_duration` slider.
- **Buttons**: 🔄 `defaultSettingsBtn` (reset), ✅ `submitButton` (save).
- **Audio Element**: 🎧 For voice previews.
#### JavaScript
- **Voice Previews**: Toggles play/stop icons, plays audio via `<audio>`.
- **DOM Ready**: Initializes tooltips, updates sliders, sets values, submits unchecked checkboxes as "False", resets defaults, validates forms.
- **Validation**: Uses Bootstrap classes (`is-valid`, `is-invalid`) with custom rules.
#### Summary
Offers a *highly configurable* interface with real-time feedback, tailoring the bot to your needs! 🛠️
---
### LAYOUT 🏗️
#### Purpose
The **LAYOUT** module sets up the base HTML structure for the bots web interface, ensuring consistency across pages 🌐.
#### Structure
- **Head**:
- 📜 Metadata: UTF-8, responsive viewport, no-cache.
- 🎨 CSS: Bootstrap (v4.1.3, 5.2), Bootstrap Icons, custom styles.
- **Body**:
- **Header**: 🚨 Flask flash messages (`alert-danger`, `alert-success`), dark navbar with links ("Background Manager", "Settings").
- **Main**: 📑 Jinja2 `{% block main %}` placeholder.
- **Footer**: 🔝 Back-to-top link, credits, "hard-reload" option.
- **Scripts**: jQuery, Popper.js, Bootstrap JS, ClipboardJS, Isotope, reload listener.
#### Functionality
- Shows temporary messages, supports cache-bypassing reloads.
#### Summary
Ensures a *consistent, responsive* design with modern web tech! 🎨
---
## TTS 🗣️
### TTS Codebase 💻
#### Overview
The **TTS Codebase** dives into the TTS modules in the `TTS` folder, powering *voice synthesis* for video narration 🎙️.
#### Modules
- **🎧 `GTTS.py`**:
- Initializes: `max_chars=5000`, empty `voices`.
- `run()`: Uses `gTTS` with config language, saves to `filepath`.
- `randomvoice()`: Unused due to empty list.
- **🔊 `pyttsx.py`**:
- Initializes: `max_chars=5000`, empty `voices`.
- `run()`: Loads `python_voice`, `py_voice_num`, defaults to (2,3) on error.
- `randomvoice()`: Picks random index.
- **🌐 `streamlabs_polly.py`**:
- Uses: `url="https://streamlabs.com/polly/speak"`, `max_chars=550`.
- `run()`: POSTs to API, retries on rate-limit, downloads MP3.
- `randomvoice()`: Random voice selection.
- **🎥 `TikTok.py`**:
- Defines: Voice tuples (e.g., `disney_voices`), uses `requests.Session`.
- `run()`: Calls `get_voices()`, decodes base64 `v_str`.
- `get_voices()`: Sanitizes text, retries on errors.
- `random_voice()`: Picks from `eng_voices`.
- `TikTokTTSException`: Custom error handling.
- **☁️ `aws_polly.py`**:
- Initializes: `max_chars=3000`.
- `run()`: Uses AWS `polly` client, writes `AudioStream`.
- `randomvoice()`: Random voice pick.
- **🤖 `elevenlabs.py`**:
- Initializes: `max_chars=2500`, lazy `client` init.
- `run()`: Generates audio with `eleven_multilingual_v1`, saves.
- `initialize()`: Sets API key.
- `randomvoice()`: Fetches and picks voice.
- **🛠️ `engine_wrapper.py`**:
- Constructor: Initializes with TTS module, Reddit data, paths.
- `add_periods()`: Cleans comments (removes URLs, adds periods).
- `run()`: Processes title/comments, splits long text, returns length/index.
- `split_post()`: Chunks text, adds silence, concatenates with `ffmpeg`.
- `call_tts()`: Delegates to TTS, measures duration.
- `create_silence_mp3()`: Generates silent audio.
- `process_text()`: Sanitizes and translates text.
#### `__init__.py`
- Marks `TTS` as a package for imports (e.g., `from TTS import GTTS`).
#### Summary
A *flexible, extensible* TTS framework with robust error handling! 🚀
---
### TTS Functionality 🔊
#### Overview
The **TTS Functionality** summarizes how each TTS module operates for *practical narration* 🎤.
#### Key Points
- **🌟 GTTS**: Fast Google TTS, config language, 5,000-char limit.
- **💻 pyttsx**: Offline TTS, OS voices, defaults to (2,3) on error.
- **🌐 streamlabs_polly**: API-based, 550-char limit, retries rate-limits.
- **🎥 TikTok**: Diverse voices, sanitizes text (+ → "plus"), retries errors.
- **☁️ aws_polly**: Neural voices, needs AWS profile, 3,000-char limit.
- **🤖 elevenlabs**: Realistic AI voices, lazy init, 2,500-char limit.
- **🛠️ engine_wrapper**: Orchestrates TTS, splits posts, adds silence, translates.
#### Integration & Customization
- Engine picked via `settings.config["settings"]["tts"]["tts_engine"]`.
- Voices and limits customizable through config or defaults.
#### Summary
Delivers a *robust, customizable* audio pipeline for Reddit videos! 🎙️
---
## Fonts 🔠
#### Purpose
The **/fonts** directory holds font files (e.g., `.ttf`, `.otf`) to style text overlays, making videos *visually appealing* 🎨.
#### Font Files
- Examples: `Arial.ttf`, `Roboto.ttf`, `OpenSans.ttf`, or custom fonts.
- Used for titles, comments, captions.
#### Apache License 2.0
- **Key Sections**:
- 📜 **Definitions**: "Work" as fonts, "You" as user.
- ✅ **Copyright License**: Free use, modification, distribution.
- 🔒 **Patent License**: Covers patented tech, ends on lawsuits.
- 📦 **Redistribution**: Needs license copy, notices, attribution.
- 🏷️ **Trademarks**: No unauthorized trademark use.
- ⚠️ **Warranty/Liability**: "As is", no liability.
- **Implications**: Free use with attribution, no warranty.
#### Why Apache 2.0?
- Encourages creative use while protecting contributors.
#### Summary
Provides *licensed, customizable* fonts to elevate video aesthetics! ✨
---
## Reddit 📱
#### Purpose
The **Reddit** module fetches submissions and comments, forming the *data foundation* for videos 📊.
#### Flow
- **🔐 Authentication**:
- Logs in with `settings.config` credentials, handles 2FA, initializes PRAW.
- **📌 Subreddit Selection**:
- Uses config `subreddit`, defaults to `r/askreddit`.
- **📝 Post Selection**:
- **Specific ID**: Uses `POST_ID` or `post_id`.
- **AI Similarity**: Fetches 50 hot posts, sorts by `sort_by_similarity`.
- **Default**: Takes 25 hot posts, picks unprocessed.
- **✅ Validation**:
- Recalls if no valid post, exits if no comments (non-story mode).
- **📈 Metadata**:
- Collects `upvotes`, `ratio`, `num_comments`, `threadurl`.
- **📜 Content**:
- Populates `content` with `thread_url`, `thread_title`, `thread_id`, `is_nsfw`.
- **Story Mode**: Processes `selftext` with `posttextparser`.
- **Comment Mode**: Filters top-level comments, sanitizes, applies length filters.
#### Utilities
- `sanitize_text`: Cleans text.
- `check_done`: Tracks processed posts.
- `get_subreddit_undone`: Picks unprocessed posts.
- `sort_by_similarity`: AI-based sorting.
- `posttextparser`: Formats self-text.
#### Summary
Powers the *core data pipeline* for targeted video content! 🚀
---
## Video Creation 🎬
### Screenshotdownloader 📸
#### Purpose
The **Screenshotdownloader** module captures Reddit post and comment screenshots using `playwright`, ensuring *accurate visuals* 🖼️.
#### Key Functions
- **📷 `get_screenshots_of_reddit_posts(reddit_object: dict, screenshot_num: int) -> None`**:
- *Purpose*: Captures thread title and comments (or story content).
- *Functionality*:
- Sets browser settings (resolution, theme, language) from `settings.config`.
- Launches headless Chromium, logs into Reddit, navigates to thread.
- Handles NSFW prompts, redesign opt-outs, popups.
- Translates content if needed via Google Translate.
- Saves screenshots: `title.png`, `story_content.png`, or `comment_{idx}.png`.
- Stores in `assets/temp/{reddit_id}/png`.
- *Error Handling*: Skips issues with prompts, saves skipped metadata.
#### Key Features
- **🎨 Customization**: Supports dark/light/transparent themes, adjustable resolution, zoom.
- **🌍 Multilingual**: Translates titles/comments.
- **🛡️ Robustness**: Adapts to Reddits UI with error handling.
- **⚡ Efficiency**: Bypasses browser in story mode using `imagemaker`.
#### Summary
Delivers *high-quality visuals* with automation and flexibility! 🌟
---
### Voice 🎙️
#### Purpose
The **Voice** module converts Reddit text to MP3 audio using TTS providers, creating *engaging narration* 🗣️.
#### Key Functions
- **🎵 `save_text_to_mp3(reddit_obj: dict) -> Tuple[float, int]`**:
- *Purpose*: Generates audio from thread data.
- *Functionality*:
- Picks TTS provider from `settings.config["settings"]["tts"]["voice_choice"]`.
- Validates against `TTSProviders`, prompts if invalid.
- Initializes `TTSEngine`, processes title/comments.
- Returns audio length and comment count.
- *Providers*:
- 🌐 GoogleTranslate (`GTTS`): Cloud-based.
- ☁️ AWSPolly: Neural voices, AWS.
- 🌍 StreamlabsPolly: API-based, 550-char limit.
- 🎥 TikTok: Diverse voices, retries.
- 💻 pyttsx: Offline system TTS.
- 🤖 ElevenLabs: AI voices, 2,500-char limit.
#### Key Features
- **🔄 Flexibility**: Supports multiple providers.
- **😊 User-Friendly**: Interactive prompts for invalid choices.
- **🧩 Modularity**: Uses dictionary-based `TTSProviders`.
- **🛡️ Robustness**: Handles case variations, invalid configs.
#### Summary
Powers *customizable, resilient* narration for videos! 🎤
---
### Final Video 📽️
#### Purpose
The **Final Video** module assembles screenshots, audio, and backgrounds into a *polished video* 🎥.
#### Key Functions
- **🧹 `name_normalize(name: str) -> str`**:
- *Purpose*: Cleans and translates filenames.
- *Functionality*: Removes invalid chars, replaces patterns (e.g., `w/o` → "without").
- **🎬 `prepare_background(reddit_id: str, W: int, H: int) -> None`**:
- *Purpose*: Crops/encodes background video.
- *Functionality*: Outputs `background_noaudio.mp4` with `ffmpeg`.
- **🖼️ `create_fancy_thumbnail(image: PIL.Image, text: str, text_color: tuple, padding: int, wrap: int) -> PIL.Image`**:
- *Purpose*: Generates branded thumbnails.
- *Functionality*: Draws text with `PIL`, adjusts font, adds channel name.
- **🎵 `merge_background_audio(audio: ffmpeg.Stream, reddit_id: str) -> ffmpeg.Stream`**:
- *Purpose*: Combines TTS and background audio.
- *Functionality*: Applies volume, merges with `amix`.
- **📹 `make_final_video(number_of_clips: int, length: float, reddit_obj: dict, background_config: dict) -> None`**:
- *Purpose*: Assembles final video.
- *Functionality*:
- Concatenates TTS audio (`audio.mp3`).
- Overlays screenshots/comments with timing.
- Adds background credit text.
- Renders to `results/{subreddit}/{filename}.mp4` with H.264.
- Optionally creates "OnlyTTS" version, thumbnail.
- Tracks progress with `ProgressFffmpeg`, `tqdm`.
#### Key Features
- **🤖 Automation**: Streamlines video creation.
- **🎨 Customization**: Supports story mode, fonts, opacity, volumes.
- **📊 Feedback**: Real-time progress via `rich`, `tqdm`.
- **⚡ Efficiency**: Multithreaded rendering.
#### Summary
Delivers *polished videos* with seamless integration! 🎉
---
### Cookies 🍪
#### Purpose
The **Cookies** module handles Reddit cookies (`USER`, `eu_cookie`) to ensure *authentic screenshot capture* 📸.
#### Details
- **USER Cookie**:
- **Preferences**:
- 🎨 Theme: "REDDIT" (dark mode).
- 🌙 Night mode: `true`.
- 📑 Collapsed sections: `false`.
- 📊 Top content dismissed: `0`.
- *Role*: Renders Reddit in users theme.
- **eu_cookie**:
- 🔒 Essential cookie consent, not non-essential.
- *Role*: Ensures GDPR compliance.
#### Summary
Enhances *authentic content capture* with settings and compliance! ✅
---
## Pylint Configuration 🛠️
#### Purpose
The **Pylint Configuration** sets up **Pylint** to enforce *coding standards* and ensure *code quality* across the project 📝.
#### Structure
- **📋 MAIN**:
- Disables import fallback checks (`analyse-fallback-blocks=no`).
- Targets Python 3.6 (`py-version=3.6`).
- Runs single-threaded (`jobs=1`).
- Fails if score <10 (`fail-under=10`).
- Ignores `CVS` directories.
- Enables caching (`persistent=yes`).
- Supports suggestion mode (`suggestion-mode=yes`).
- **📊 REPORTS**:
- Shows messages only (`reports=no`).
- Displays quality score (`score=yes`).
- Uses custom scoring formula.
- **🚨 MESSAGES CONTROL**:
- Disables docstring, name warnings, `black`-handled issues.
- Enforces naming:
- 🐍 `snake_case` for args, attributes, functions, variables.
- 🏛️ `PascalCase` for classes.
- 🔠 `UPPER_CASE` for constants.
- Lists good/bad variable names.
- **🏗️ CLASSES**:
- Limits complexity (max 2 public methods).
- Warns on protected attribute access.
- **⚠️ EXCEPTIONS**:
- Flags broad exceptions (e.g., `BaseException`).
- **📏 FORMAT**:
- Enforces 100-char lines (`max-line-length=100`).
- Uses 4-space indentation.
- Limits modules to 1,000 lines.
- Bans single-line class/if statements.
- **📥 IMPORTS**:
- Prohibits wildcard imports without `__all__`.
- Recognizes `enchant` as third-party.
- **📜 LOGGING**:
- Requires `%`-style logging.
- **📌 MISCELLANEOUS**:
- Tracks `FIXME`, `XXX`, `TODO` notes.
- **🔄 REFACTORING**:
- Limits nesting to 5 levels (`max-nested-blocks=5`).
#### Key Features
- **✅ Consistency**: Uniform naming and style.
- **🧠 Complexity Control**: Enhances maintainability.
- **🔗 Integration**: Works with `black`.
- **⚖️ Flexibility**: Balances strictness for Python 3.6+.
#### Summary
Ensures *high-quality, readable* code tailored for the project! 🌟
---
## Docker Setup 🐳
#### Purpose
The **Docker Setup** creates a *containerized environment* for consistent bot execution across systems 🖥️.
#### Structure
- **📦 Base Image**:
- `python:3.10.14-slim`: Lightweight Python 3.10.
- **🛠️ System Dependencies**:
- Installs `ffmpeg` for media processing.
- Adds `python3-pip` for packages.
- Updates lists with `apt update`.
- **📂 Application Setup**:
- Creates `/app` directory.
- Copies project files to `/app`.
- Sets `/app` as working directory.
- **📥 Python Dependencies**:
- Installs from `requirements.txt`.
- **🚀 Entry Point**:
- Runs `python3 main.py`.
#### Key Features
- **🌍 Portability**: Consistent across environments.
- **📏 Minimalism**: Slim image reduces size.
- **🤖 Automation**: Easy dependency setup.
- **💪 Robustness**: Supports video processing.
#### Summary
Provides a *streamlined, reproducible* environment for deployment! 🎉
---
## Flask GUI 🌐
#### Purpose
The **Flask GUI** builds a *web-based interface* to manage backgrounds, settings, and videos 📱.
#### Structure
- **⚙️ Configuration**:
- Runs on `localhost:4000`.
- Uses `GUI` for templates.
- Employs `tomlkit` for `config.toml`.
- Sets secret key for sessions.
- Disables caching.
- **🛤️ Routes**:
- 🏠 **`/`**: Renders `index.html` with `videos.json`.
- 🎥 **`/backgrounds` (GET)**: Shows `backgrounds.html`.
- **`/background/add` (POST)**: Adds background (`youtube_uri`, `filename`, etc.).
- 🗑️ **`/background/delete` (POST)**: Deletes by key.
- ⚙️ **`/settings` (GET/POST)**: Manages `config.toml`.
- 📜 **`/videos.json`**: Serves `videos.json`.
- 📂 **`/backgrounds.json`**: Serves `backgrounds.json`.
- 📥 **`/results/<path:name>`**: Serves videos.
- 🎧 **`/voices/<path:name>`**: Serves voice samples.
- **Functionality**:
- Auto-opens browser to `localhost:4000`.
- Uses `gui_utils` for logic.
- Prompts reload if page fails.
#### Key Features
- **🖱️ Interactivity**: Dynamic settings and backgrounds.
- **🌐 Accessibility**: Direct media access.
- **😊 User-Friendly**: Intuitive forms.
- **🛡️ Reliability**: Robust form handling.
#### Summary
Delivers a *responsive, feature-rich* GUI for easy interaction! 🚀
---
## Web Layout 🎨
#### Purpose
The **Web Layout** defines the HTML template for a *consistent, stylish* web interface 🌐.
#### Structure
- **📜 Head**:
- Metadata: UTF-8, responsive, no-cache.
- CSS: Bootstrap v4.1.3/v5.2, Icons, custom styles.
- **📑 Body**:
- **Header**: 🚨 Flash messages, dark navbar with links.
- **Main**: 📄 Jinja2 `{% block main %}` placeholder.
- **Footer**: 🔝 Back-to-top, credits, reload option.
- **🛠️ Scripts**:
- jQuery, Popper.js, Bootstrap JS, ClipboardJS, Isotope.
- Enables tooltips, grids, copy-to-clipboard.
#### Key Features
- **✅ Consistency**: Uniform design.
- **📱 Responsiveness**: Adapts to screens.
- **🖱️ Interactivity**: Dynamic UI elements.
- **⚡ Performance**: CDN-hosted assets.
#### Summary
A *cohesive, professional* foundation for usability! 🌟
---
## TTS Testing 🔍
#### Purpose
The **TTS Testing** module (`ptt.py`) tests system TTS voices with `pyttsx3`, aiding *offline narration setup* 🎙️.
#### Structure
- **📥 Imports**:
- `pyttsx3`: Cross-platform TTS library.
- **Functionality**:
- Initializes `pyttsx3` engine.
- Gets voices with `engine.getProperty("voices")`.
- Iterates:
- Prints `voice.id` (e.g., "Microsoft David Desktop").
- Sets voice with `engine.setProperty`.
- Plays "Hello World!" via `say()` and `runAndWait()`.
- Stops engine to avoid overlap.
- **Output**:
- 📜 Console: Lists voice names/IDs.
- 🎧 Audio: Plays test phrase.
#### Key Features
- **🌍 Cross-Platform**: Windows (SAPI5), Linux (eSpeak), macOS (NSSpeechSynthesizer).
- **😊 Simplicity**: Minimal, standalone code.
- **🛠️ Utility**: Guides `python_voice`, `py_voice_num` settings.
- **🔗 Integration**: Linked in settings tooltip.
#### Summary
Streamlines *offline TTS setup* with easy voice testing! ✅
---
## Build Script 🔧
#### Purpose
The **Build Script** (`buildsh.txt`) aims to automate building the bot, though details are currently missing 📜.
#### Structure
- **Content**: No commands provided.
- **Assumptions**:
- Likely a shell script (`build.sh`) for compiling dependencies or preparing assets.
- May install tools like `ffmpeg`, `yt-dlp`.
#### Key Features
- **🤖 Potential Automation**: Could streamline setup.
- **🌍 Portability**: Likely for Unix-like systems.
- **🔄 Extensibility**: May support custom builds.
#### Summary
A placeholder for *build automation*, awaiting details! ⏳
---
## Install Script 📦
#### Purpose
The **Install Script** (`installsh.txt`) aims to automate bot installation, though details are unavailable 📜.
#### Structure
- **Content**: No commands provided.
- **Assumptions**:
- Likely a shell script (`install.sh`) for dependencies or setup.
- May handle Python, `pip`, or project files.
#### Key Features
- **😊 Potential Simplicity**: Could ease setup.
- **🌍 Compatibility**: Likely for Unix-like systems.
- **🔄 Reusability**: May support repeated installs.
#### Summary
A placeholder for *installation automation*, needing specifics! ⏳
---
## Requirements 📋
#### Purpose
The **Requirements** (`requirements.txt`) lists Python dependencies, though currently undefined 📜.
#### Structure
- **Content**: No packages listed.
- **Assumptions**:
- Likely includes `praw`, `pyttsx3`, `ffmpeg-python`, `playwright`, `flask`, `tomlkit`.
- Used with `pip install -r requirements.txt`.
#### Key Features
- **🛠️ Dependency Management**: Ensures libraries are installed.
- **✅ Reproducibility**: Consistent setups.
- **🔄 Extensibility**: May include optional dependencies.
#### Summary
Critical for *dependencies*, but awaits details! ⏳
---
## Run Shell Script 🚀
#### Purpose
The **Run Shell Script** (`runsh.txt`) aims to execute the bot, though details are missing 📜.
#### Structure
- **Content**: No commands provided.
- **Assumptions**:
- Likely a shell script (`run.sh`) to run `main.py`.
- May activate virtual environments or set variables.
#### Key Features
- **🤖 Potential Automation**: Simplifies launching.
- **🌍 Portability**: Targets Unix-like systems.
- **🔄 Flexibility**: May allow runtime args.
#### Summary
A placeholder for *execution automation*, needing content! ⏳
---
## Run Batch Script 🖱️
#### Purpose
The **Run Batch Script** (`runbat.txt`) launches the bot on Windows by activating a virtual environment and running `main.py` with error handling 🚀.
#### Structure
- **Content**:
- 🛑 **`@echo off`**: Clean console output.
- 📂 **`set VENV_DIR=.venv`**: Sets virtual env directory.
- **Virtual Environment**:
- Checks `.venv` with `if exist "%VENV_DIR%"`.
- Prints "Activating virtual environment..." and runs `activate.bat`.
- **Execution**:
- Prints "Running Python script...".
- Runs `python main.py`.
- **Error Handling**:
- Checks `errorlevel 1` for failures.
- Shows "An error occurred. Press any key to exit." and pauses.
- **Flow**:
- Initializes quietly.
- Activates virtual env if present.
- Runs `main.py` with correct Python.
- Reports errors and pauses.
#### Key Features
- **🛡️ Environment Isolation**: Uses `.venv` for correct dependencies.
- **😊 User Feedback**: Clear messages for actions and errors.
- **🚨 Error Handling**: Informs and pauses on failures.
- **😊 Simplicity**: Easy Windows execution.
#### Summary
A *reliable, user-friendly* way to launch the bot on Windows! 🌟
---
Loading…
Cancel
Save