# How to Integrate RedditVideoMakerBot with Other Tools: A Complete Developer Guide

> Learn to integrate RedditVideoMakerBot with external workflows programmatically. Import pure functions and drive the pipeline without using the CLI. A complete developer guide.

- Repository: [Lewis Menelaws/RedditVideoMakerBot](https://github.com/elebumm/RedditVideoMakerBot)
- Tags: how-to-guide
- Published: 2026-04-08

---

**You can integrate RedditVideoMakerBot into external workflows by importing pure functions from [`utils/settings.py`](https://github.com/elebumm/RedditVideoMakerBot/blob/main/utils/settings.py), [`reddit/subreddit.py`](https://github.com/elebumm/RedditVideoMakerBot/blob/main/reddit/subreddit.py), and [`video_creation/final_video.py`](https://github.com/elebumm/RedditVideoMakerBot/blob/main/video_creation/final_video.py) to drive the pipeline programmatically without invoking the CLI.**

The RedditVideoMakerBot (RVMB) repository by elebumm is architected as a modular Python package that separates configuration, data acquisition, and media generation into distinct layers. This design makes it straightforward to integrate the bot with external automation frameworks, CI/CD pipelines, or custom applications by importing specific functions rather than running the command-line interface.

## Understanding the Modular Architecture

The codebase organizes functionality into three logical layers that communicate through plain Python dictionaries and the `settings.config` object. Each layer exposes specific entry points in the source files:

- **Configuration Layer**: Located in [`utils/settings.py`](https://github.com/elebumm/RedditVideoMakerBot/blob/main/utils/settings.py), the `check_toml()` function validates TOML files and populates missing values. You can inject custom configurations by passing a pre-filled [`config.toml`](https://github.com/elebumm/RedditVideoMakerBot/blob/main/config.toml) path or calling `check_toml()` directly with template and target paths.

- **Data Acquisition Layer**: The [`reddit/subreddit.py`](https://github.com/elebumm/RedditVideoMakerBot/blob/main/reddit/subreddit.py) module contains `get_subreddit_threads()`, which authenticates to Reddit, fetches submission data, filters comments, and returns a standardized dictionary object (reddit_obj) containing `thread_title`, `thread_id`, and `comments`.

- **Media Pipeline Layer**: Spread across `video_creation/` and `TTS/` directories, this layer handles text-to-speech generation, screenshot capture, and final video assembly. Key functions include `save_text_to_mp3()` in [`video_creation/voices.py`](https://github.com/elebumm/RedditVideoMakerBot/blob/main/video_creation/voices.py) and `make_final_video()` in [`video_creation/final_video.py`](https://github.com/elebumm/RedditVideoMakerBot/blob/main/video_creation/final_video.py). Each stage writes artifacts to `assets/temp/<submission_id>/` and expects the reddit_obj dictionary as input.

## Integration Methods for External Tools

### Orchestrating the Complete Pipeline

To run the entire workflow programmatically, import the `main()` function from [`main.py`](https://github.com/elebumm/RedditVideoMakerBot/blob/main/main.py) and pass a specific Reddit post ID. This bypasses interactive prompts while preserving all processing stages.

### Executing Individual Stages

For granular control, import functions from specific modules to run only the TTS generation, screenshot capture, or video composition. This approach allows you to insert custom processing between stages, such as modifying audio files before final assembly or uploading screenshots to cloud storage immediately after capture.

### Swapping TTS Providers

The TTS architecture uses a class-based plugin system. The `TTSEngine` wrapper in [`TTS/engine_wrapper.py`](https://github.com/elebumm/RedditVideoMakerBot/blob/main/TTS/engine_wrapper.py) expects providers to implement a `run(text, filepath, random_voice)` method and expose a `max_chars` attribute. You can register custom engines by adding them to the `TTSProviders` dictionary in [`video_creation/voices.py`](https://github.com/elebumm/RedditVideoMakerBot/blob/main/video_creation/voices.py) without modifying core logic.

## Practical Implementation Examples

### Standalone Automation Script

```python
from reddit.subreddit import get_subreddit_threads
from video_creation.voices import save_text_to_mp3
from video_creation.final_video import make_final_video
from video_creation.background import get_background_config, download_background_video, download_background_audio, chop_background
from utils.settings import check_toml

# Initialize configuration

check_toml("utils/.config.template.toml", "production_config.toml")

# Fetch specific Reddit thread

reddit_obj = get_subreddit_threads("k1j2p3")

# Generate audio via TTS

total_len, last_comment_idx = save_text_to_mp3(reddit_obj)

# Prepare background assets

bg_config = {
    "video": get_background_config("video"),
    "audio": get_background_config("audio")
}
download_background_video(bg_config["video"])
download_background_audio(bg_config["audio"])
chop_background(bg_config, total_len, reddit_obj)

# Assemble final output

make_final_video(last_comment_idx, total_len, reddit_obj, bg_config)

```

### Embedding as a Library

```python

# integrations/rvmb_wrapper.py

from RedditVideoMakerBot.reddit.subreddit import get_subreddit_threads
from RedditVideoMakerBot.video_creation.voices import save_text_to_mp3
from RedditVideoMakerBot.video_creation.final_video import make_final_video
from RedditVideoMakerBot.utils.settings import check_toml

def generate_video(post_id: str, config_path: str = "config.toml") -> str:
    """Render video for post_id and return the output path."""
    check_toml("utils/.config.template.toml", config_path)
    
    reddit_data = get_subreddit_threads(post_id)
    _, comment_count = save_text_to_mp3(reddit_data)
    
    # Background configuration simplified for brevity

    bg_cfg = {"video": {"choice": "default"}, "audio": {"choice": "default"}}
    make_final_video(comment_count, 0, reddit_data, bg_cfg)
    
    return f"results/{reddit_data['subreddit']}/{reddit_data['thread_title'][:50]}.mp4"

```

### Custom TTS Integration

```python

# TTS/custom_provider.py

class AzureTTS:
    max_chars = 5000
    
    def run(self, text: str, filepath: str, random_voice: bool = False):
        # Implementation specific to Azure Cognitive Services

        audio_data = azure_synthesizer.speak_text_async(text).get()
        with open(filepath, "wb") as f:
            f.write(audio_data)

# Register the provider

from RedditVideoMakerBot.video_creation.voices import TTSProviders
TTSProviders["AzureTTS"] = AzureTTS

```

## Critical Source Files for Integration

- **[`main.py`](https://github.com/elebumm/RedditVideoMakerBot/blob/main/main.py)**: Contains the `main(post_id)` orchestration function that sequences all pipeline stages when called programmatically.

- **[`utils/settings.py`](https://github.com/elebumm/RedditVideoMakerBot/blob/main/utils/settings.py)**: Houses `check_toml()` for configuration validation and the global `config` object accessed by other modules.

- **[`reddit/subreddit.py`](https://github.com/elebumm/RedditVideoMakerBot/blob/main/reddit/subreddit.py)**: Implements `get_subreddit_threads()` for Reddit API authentication and data retrieval, returning the standardized dictionary used downstream.

- **[`video_creation/voices.py`](https://github.com/elebumm/RedditVideoMakerBot/blob/main/video_creation/voices.py)**: Manages TTS provider selection via `save_text_to_mp3()` and the `TTSProviders` mapping dictionary for engine registration.

- **[`TTS/engine_wrapper.py`](https://github.com/elebumm/RedditVideoMakerBot/blob/main/TTS/engine_wrapper.py)**: Defines the `TTSEngine` class interface that normalizes calls across different TTS implementations.

- **[`video_creation/final_video.py`](https://github.com/elebumm/RedditVideoMakerBot/blob/main/video_creation/final_video.py)**: Contains `make_final_video()` for assembling screenshots, audio, and background video into the final MP4.

- **[`utils/id.py`](https://github.com/elebumm/RedditVideoMakerBot/blob/main/utils/id.py)**: Provides helpers for extracting Reddit post IDs used in temporary folder naming under `assets/temp/`.

## Summary

- RedditVideoMakerBot exposes pure functions in [`reddit/subreddit.py`](https://github.com/elebumm/RedditVideoMakerBot/blob/main/reddit/subreddit.py), [`video_creation/voices.py`](https://github.com/elebumm/RedditVideoMakerBot/blob/main/video_creation/voices.py), and [`video_creation/final_video.py`](https://github.com/elebumm/RedditVideoMakerBot/blob/main/video_creation/final_video.py) that accept standardized dictionary objects.
- The `check_toml()` function in [`utils/settings.py`](https://github.com/elebumm/RedditVideoMakerBot/blob/main/utils/settings.py) allows programmatic configuration injection without interactive prompts.
- Individual pipeline stages can run independently, enabling integration with external audio processors, image manipulation tools, or cloud upload services.
- Custom TTS engines integrate by implementing the `run()` method and `max_chars` attribute, then registering in [`video_creation/voices.py`](https://github.com/elebumm/RedditVideoMakerBot/blob/main/video_creation/voices.py).
- All heavy lifting occurs in isolated functions with no global state except `settings.config`, making the library safe for use in web services, serverless functions, and CI/CD environments.

## Frequently Asked Questions

### Can I run RedditVideoMakerBot from a Python script without using the command line?

Yes. Import the `main()` function from [`main.py`](https://github.com/elebumm/RedditVideoMakerBot/blob/main/main.py) or individual stage functions from [`reddit/subreddit.py`](https://github.com/elebumm/RedditVideoMakerBot/blob/main/reddit/subreddit.py) and [`video_creation/final_video.py`](https://github.com/elebumm/RedditVideoMakerBot/blob/main/video_creation/final_video.py) to drive the pipeline programmatically. The bot functions as a standard Python library when imported into other projects.

### How do I supply my own configuration file when integrating the bot?

Call `check_toml(template_path, your_config_path)` from [`utils/settings.py`](https://github.com/elebumm/RedditVideoMakerBot/blob/main/utils/settings.py) before executing other functions. This validates your TOML file and populates the global `settings.config` object that downstream modules reference for Reddit credentials, voice choices, and video settings.

### Is it possible to use only the text-to-speech generation without creating the full video?

Yes. Import `save_text_to_mp3()` from [`video_creation/voices.py`](https://github.com/elebumm/RedditVideoMakerBot/blob/main/video_creation/voices.py) and pass the reddit_obj dictionary returned by `get_subreddit_threads()`. This function generates MP3 files in `assets/temp/<submission_id>/` and returns the total audio length and last comment index without invoking video composition.

### What is required to add a custom TTS provider like Google Cloud or Azure?

Create a class with a `run(text, filepath, random_voice)` method and a `max_chars` integer attribute. Place the file in the `TTS/` directory, import it in your integration script, and add the class to the `TTSProviders` dictionary in [`video_creation/voices.py`](https://github.com/elebumm/RedditVideoMakerBot/blob/main/video_creation/voices.py) with a unique key name that matches your [`config.toml`](https://github.com/elebumm/RedditVideoMakerBot/blob/main/config.toml) voice_choice setting.