sireme/PPT_to_mp4_with_sample_voiceover
๐๏ธ 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:
- Extracts text from each slide
- Converts PPTX โ PDF โ PNG (robust multi-slide rendering)
- Clones your voice using Coqui XTTS v2
- Generates natural narration for every slide
- Syncs slide duration to narration length
- 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
docker build -t pptx-narrator .Run (CPU)
docker run -p 7860:7860 pptx-narratorRun (GPU)
docker run --gpus all -p 7860:7860 pptx-narratorOpen in browser:
http://localhost:7860
๐ Deploying to Hugging Face Spaces
- Create a new Docker Space
- Select Docker as SDK
- (Recommended) Enable T4 GPU
- Push:
- app.py
- Dockerfile
- requirements.txt
- 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.
