# How MoneyPrinterTurbo Generates Subtitles: Edge vs Whisper Pipeline Explained

> Learn how MoneyPrinterTurbo generates subtitles using its edge provider and Whisper pipeline. Understand its fallback transcription and alignment process for efficient subtitle creation.

- Repository: [Harry/MoneyPrinterTurbo](https://github.com/harry0703/MoneyPrinterTurbo)
- Tags: how-to-guide
- Published: 2026-03-23

---

**MoneyPrinterTurbo generates subtitles through a dual-provider pipeline that first attempts to convert TTS timestamps directly to SRT format (edge provider), and falls back to Whisper speech-to-text transcription with Levenshtein-based script alignment when needed.**

The open-source video generation tool MoneyPrinterTurbo automates subtitle creation by synchronizing text with audio through two distinct backend strategies. Whether using Microsoft's Edge TTS service or OpenAI's Whisper model, the system ensures subtitle files match the original video script with precise timing. This article examines the three-stage pipeline implemented in the `harry0703/MoneyPrinterTurbo` repository.

## Subtitle Generation Pipeline Overview

MoneyPrinterTurbo constructs subtitle files through three distinct stages orchestrated across multiple service modules. The pipeline prioritizes efficiency by leveraging existing TTS metadata before resorting to computationally expensive speech recognition.

The process flows through these core components:

- **app/services/task.py** – Orchestrates provider selection and fallback logic via `generate_subtitle`
- **app/services/voice.py** – Handles edge-provider conversion through `create_subtitle`
- **app/services/subtitle.py** – Manages Whisper transcription and script correction via `create` and `correct`

The system defaults to the **edge** provider, which utilizes timing data already generated during text-to-speech synthesis. If this fails or if the user explicitly selects **whisper**, the system transcribes the audio file and corrects the output against the original script.

## Stage 1: Provider Selection and Orchestration

The entry point `generate_subtitle` in [`app/services/task.py`](https://github.com/harry0703/MoneyPrinterTurbo/blob/main/app/services/task.py) (line 124) determines which subtitle generation strategy to employ based on the `subtitle_provider` configuration value.

```python
subtitle_provider = config.app.get("subtitle_provider", "edge").strip().lower()

if subtitle_provider == "edge":
    voice.create_subtitle(text=video_script,
                         sub_maker=sub_maker,
                         subtitle_file=subtitle_path)
    

# Fallback mechanism

if subtitle_provider == "whisper" or subtitle_fallback:
    subtitle.create(audio_file=audio_file, subtitle_file=subtitle_path)
    subtitle.correct(subtitle_file=subtitle_path, video_script=video_script)

```

The function receives the **`sub_maker`** object returned from the TTS generation process, which contains precise word-level timestamps. When the edge provider fails to produce a valid SRT file, the `subtitle_fallback` flag triggers the Whisper pipeline automatically.

## Stage 2: Edge Provider - Converting TTS Timestamps to SRT

The `voice.create_subtitle` function in [`app/services/voice.py`](https://github.com/harry0703/MoneyPrinterTurbo/blob/main/app/services/voice.py) (line 1574) transforms the TTS `SubMaker` object into a synchronized SRT file without requiring additional audio processing.

The implementation performs these operations:

1. **Sanitizes the input script** using `_format_text` to normalize whitespace and punctuation
2. **Splits the script** into chunks using `utils.split_string_by_punctuations` to match natural speech segments
3. **Iterates through `sub_maker.offset`** and **`sub_maker.subs`** arrays containing millisecond timestamps and corresponding words
4. **Matches accumulated words** against script chunks using exact, punctuation-stripped, or alphanumeric comparison strategies
5. **Writes SRT entries** via `mktimestamp` when word boundaries align with punctuation breaks

This approach leverages the TTS engine's internal timing data to produce perfectly synchronized subtitles with minimal computational overhead.

## Stage 3: Whisper Provider - Transcription and Script Correction

When the edge provider is unavailable or insufficient, MoneyPrinterTurbo employs the **faster-whisper** library for speech-to-text conversion and subsequent script alignment.

### Transcription with `subtitle.create`

The `create` function in [`app/services/subtitle.py`](https://github.com/harry0703/MoneyPrinterTurbo/blob/main/app/services/subtitle.py) (line 21) loads the Whisper model and processes the audio file:

```python
from faster_whisper import WhisperModel

model = WhisperModel(model_size, device=device, compute_type=compute_type)
segments, _ = model.transcribe(audio_file, word_timestamps=True)

```

The function converts Whisper's segment output into standard SRT format using `utils.text_to_srt`, producing a raw subtitle file based purely on audio content.

### Script Correction with `subtitle.correct`

The `correct` function in [`app/services/subtitle.py`](https://github.com/harry0703/MoneyPrinterTurbo/blob/main/app/services/subtitle.py) (line 93) reconciles the Whisper-generated SRT with the original video script to ensure content accuracy:

1. **Loads the generated SRT** using `file_to_subtitles` to extract timing and text data
2. **Splits the original script** using the same punctuation logic applied in the edge provider
3. **Calculates Levenshtein similarity** between subtitle lines and script chunks to find optimal alignments
4. **Merges consecutive subtitle lines** when similarity scores improve alignment, or forces script text into existing timecodes when discrepancies exist
5. **Overwrites the original SRT** with the corrected version that preserves the video script verbatim

This correction step ensures that regardless of Whisper's transcription accuracy, the final subtitle file contains the exact text provided in the video generation parameters.

## Practical Implementation Examples

### Enabling Subtitles in Video Generation Tasks

Configure subtitle generation through the `VideoParams` schema:

```python
from app.services.task import start
from app.models.schema import VideoParams

params = VideoParams(
    video_subject="AI Technology Trends",
    voice_name="en-US-AndrewNeural-Male",
    subtitle_enabled=True,
    subtitle_position="bottom",
)

task_id = "task-001"
result = start(task_id, params, stop_at="video")
print(result["subtitle_path"])  # Outputs: /path/to/subtitle.srt

```

### Direct Edge Provider Subtitle Generation

Generate subtitles manually from existing TTS output:

```python
from app.services.voice import create_subtitle, tts
from app.utils import utils

script = "Welcome to automated content creation. This is a demonstration."
audio_path = utils.storage_dir("temp") + "/audio.mp3"

# Generate TTS with timing data

sub_maker = tts(
    text=script,
    voice_name="zh-CN-XiaoyiNeural-Female",
    voice_rate=1.0,
    voice_file=audio_path
)

# Convert to SRT

srt_path = utils.storage_dir("temp") + "/subtitles.srt"
create_subtitle(sub_maker=sub_maker, text=script, subtitle_file=srt_path)

```

### Whisper Transcription with Script Alignment

Force Whisper processing for existing audio files:

```python
from app.services.subtitle import create, correct

audio_file = "/path/to/existing_audio.mp3"
subtitle_file = "/tmp/output.srt"

# Generate raw transcription

create(audio_file=audio_file, subtitle_file=subtitle_file)

# Align with original script

original_script = "Today we explore machine learning applications."
correct(subtitle_file=subtitle_file, video_script=original_script)

```

## Summary

MoneyPrinterTurbo implements a robust subtitle generation system with the following characteristics:

- **Dual-provider architecture** defaults to efficient TTS timestamp extraction (edge) while supporting high-accuracy speech recognition (whisper)
- **Zero-overhead synchronization** when using the edge provider by recycling `SubMaker` metadata from the TTS process
- **Levenshtein-based correction** ensures Whisper-generated subtitles match the original script exactly, regardless of transcription variations
- **Automatic fallback** triggers whisper transcription when edge generation fails
- **Punctuation-aware chunking** aligns subtitle breaks with natural speech patterns using `utils.split_string_by_punctuations`

## Frequently Asked Questions

### What is the difference between the edge and whisper subtitle providers?

The **edge provider** extracts timing information directly from the TTS engine's `SubMaker` object, converting word-level timestamps into SRT format without additional audio processing. The **whisper provider** transcribes the generated audio file using the faster-whisper model, then aligns the transcription with the original script using Levenshtein distance algorithms to ensure text accuracy.

### Why does MoneyPrinterTurbo correct Whisper-generated subtitles?

Whisper transcription may introduce minor deviations from the original script due to audio quality, pronunciation variations, or model hallucinations. The `subtitle.correct` function forces the subtitle text to match the original video script exactly while preserving Whisper's timing data, ensuring content consistency with the video generation parameters.

### Can I use MoneyPrinterTurbo to generate subtitles for existing audio files?

Yes. While primarily designed for automated video generation, you can import the `subtitle` service module directly to process existing audio. Use `subtitle.create()` to generate initial SRT files from audio, then `subtitle.correct()` to align the timing with your target script, as demonstrated in the code examples above.

### Where is the subtitle provider configured?

The subtitle provider is controlled by the `subtitle_provider` key in the application configuration file ([`app/config.py`](https://github.com/harry0703/MoneyPrinterTurbo/blob/main/app/config.py)). Valid values are `"edge"` (default) or `"whisper"`. Additionally, the `subtitle_fallback` flag determines whether the system automatically switches to Whisper when edge generation fails.