CoolFace
Apppublic

sireme/PPT_to_mp4_with_sample_voiceover

sourceHugging Faceupdated 7mo agoView on Hugging Face
1likes
App README

๐ŸŽ™๏ธ PowerPoint Narrator --- AI Voice Cloning

Convert any .pptx presentation into a fully narrated MP4 video using your own voice, powered by Coqui XTTS v2.

๐Ÿ”— Live Hugging Face Space:\ https://huggingface.co/spaces/sireme/PPTtomp4withsample_voiceover


โœจ What It Does

Upload a PowerPoint file and a short voice sample, and the app automatically:

  1. 1.Extracts text from each slide
  2. 2.Converts PPTX โ†’ PDF โ†’ PNG (robust multi-slide rendering)
  3. 3.Clones your voice using Coqui XTTS v2
  4. 4.Generates natural narration for every slide
  5. 5.Syncs slide duration to narration length
  6. 6.Exports a clean H.264/AAC MP4 video at 24fps

No manual recording. No editing. Fully automated.


๐Ÿง  How It Works

Full Processing Pipeline

.pptx file โ”€โ”€โ” โ”œโ”€โ”€โ–ถ python-pptx โ”€โ”€โ–ถ Slide Text โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚ โ”‚ โ””โ”€โ”€โ–ถ LibreOffice โ”€โ”€โ–ถ PDF โ”€โ”€โ–ถ PNG Slides โ”€โ”€โ”€โ”€โ”€โ”ค โ”œโ”€โ”€โ–ถ moviepy โ”€โ”€โ–ถ Final MP4 Voice sample โ”€โ”€โ–ถ ffmpeg โ”€โ”€โ–ถ Clean WAV โ”€โ”€โ–ถ XTTS v2 โ”€โ”€โ–ถ Narration WAVs โ”€โ”€โ”€โ”€โ”€โ”˜

Architecture Decisions

๐Ÿ“„ Slide Rendering (Docker-Safe)

Direct PPTXโ†’PNG export can fail in headless environments.\ This app uses:

PPTX โ†’ PDF โ†’ PNG (via poppler-utils)

This guarantees: - All slides captured correctly - No "1/1 slide" issue - Stable rendering inside Docker & HF Spaces


๐Ÿ“ Text Extraction

python-pptx extracts text from every shape and text frame on each slide.

  • โ€”All visible text is included
  • โ€”Long slides are chunked intelligently
  • โ€”Slides with no text remain silent (no forced placeholder narration)

๐ŸŽค Voice Processing

Voice samples are normalized using ffmpeg to:

  • โ€”Mono
  • โ€”22050 Hz
  • โ€”16-bit PCM WAV

This ensures compatibility and stable XTTS inference.


๐Ÿ—ฃ Voice Cloning (XTTS v2)

Model:\ tts_models/multilingual/multi-dataset/xtts_v2

Optimizations:

  • โ€”Model loaded once globally at startup
  • โ€”Speaker embedding computed once per request
  • โ€”Text chunked at sentence boundaries
  • โ€”Inference wrapped in torch.inference_mode()
  • โ€”Audio normalized and faded between chunks
  • โ€”GPU memory cleared after inference (if applicable)

๐ŸŽฌ Video Assembly

moviepy:

  • โ€”24 FPS output
  • โ€”H.264 video
  • โ€”AAC audio
  • โ€”Subtle Ken Burns zoom effect
  • โ€”Slide duration = narration duration

๐Ÿ“ฆ Supported Inputs


Input Details ----------------------------------- ----------------------------------- Presentation .pptx files, up to 30 slides

Voice sample .wav, .mp3, .aac, .m4a, .flac, etc.

Languages en, es, fr, de, it, pt, pl, tr, ru, nl, cs, ar, zh-cn, hu, ko, ja -----------------------------------------------------------------------

Voice sample guidelines:

  • โ€”3--30 seconds
  • โ€”Clear speech
  • โ€”Minimal background noise
  • โ€”Natural pacing

๐Ÿ—‚ Project Structure

โ”œโ”€โ”€ app.py โ”œโ”€โ”€ Dockerfile โ”œโ”€โ”€ requirements.txt โ””โ”€โ”€ README.md


โš™๏ธ Running Locally

Prerequisites

  • โ€”Docker installed
  • โ€”Optional: NVIDIA GPU for faster inference

Build

bash
docker build -t pptx-narrator .

Run (CPU)

bash
docker run -p 7860:7860 pptx-narrator

Run (GPU)

bash
docker run --gpus all -p 7860:7860 pptx-narrator

Open in browser:

http://localhost:7860


๐Ÿš€ Deploying to Hugging Face Spaces

  1. 1.Create a new Docker Space
  2. 2.Select Docker as SDK
  3. 3.(Recommended) Enable T4 GPU
  4. 4.Push:
  5. 5.app.py
  6. 6.Dockerfile
  7. 7.requirements.txt
  8. 8.README.md

On first boot, XTTS (\~1.8GB) downloads automatically.

The Docker container includes stability configurations:

  • โ€”Hugging Face cache redirected to /tmp
  • โ€”Numba caching disabled
  • โ€”Matplotlib config redirected
  • โ€”LibreOffice given writable HOME
  • โ€”Librosa patched to remove deprecated pkg_resources dependency

This prevents:

  • โ€”Slide export failures
  • โ€”Numba locator errors
  • โ€”pkg_resources import crashes
  • โ€”HF cache permission warnings

๐ŸŽ Performance

Hardware \~Time per 10 Slides -------------------- ---------------------- T4 GPU (HF Spaces) \~1--2 minutes CPU only \~8--15 minutes

Processing time scales roughly linearly with slide count.

The 30-slide cap prevents excessive latency.


๐Ÿ“ฆ Dependencies

Python

  • โ€”TTS (Coqui XTTS v2)
  • โ€”torch / torchaudio
  • โ€”transformers
  • โ€”python-pptx
  • โ€”moviepy
  • โ€”gradio
  • โ€”soundfile

System

  • โ€”ffmpeg
  • โ€”libreoffice
  • โ€”poppler-utils

โš ๏ธ Limitations

  • โ€”Slides with no text remain silent
  • โ€”Very dense slides may produce slower narration
  • โ€”English performs best
  • โ€”30 slide maximum per run

๐Ÿ” Responsible Use

Voice cloning must only be used with explicit consent.

Do not use this tool to:

  • โ€”Clone someone's voice without permission
  • โ€”Create deceptive content
  • โ€”Impersonate individuals for fraud

Intended for:

  • โ€”Personal presentation narration
  • โ€”Accessibility tooling
  • โ€”Productivity automation

๐Ÿ“œ License

Uses Coqui XTTS v2 under the Coqui Public Model License (CPML).\ All other repository code is released under the MIT License.