Manim plugin for all things voiceover
Project description
manim-voiceover
manim-voiceover
is a Manim plugin for all things voiceover:
- Add voiceovers to Manim videos directly in Python without having to use a video editor.
- Develop an animation with an auto-generated AI voice without having to re-record and re-sync the audio.
- Record a voiceover and have it stitched back onto the video instantly. (Note that this is not the same as AI voice cloning)
Currently supported TTS services:
- Azure Text to Speech (Recommended)
- gTTS
- pyttsx3
Installation
Install from PyPI with the extras azure
and gtts
:
pip install manim-voiceover manim-voiceover[azure] manim-voiceover[gtts]
Check whether your installation works correctly:
manim -pql examples/gtts-example.py --disable_caching
The --disable_caching
flag is required due to a Manim bug. TODO: Remove once the bug is fixed.
The example above uses gTTS which calls the Google Translate API and therefore needs an internet connection to work. If it throws an error, there might be a problem with your internet connection or the Google Translate API.
Installing SoX
manim-voiceover
can make the output from speech synthesizers faster or slower using SoX (version 14.4.2 or higher is required).
Install SoX on Mac with Homebrew:
brew install sox
Install SoX on Debian based distros:
sudo apt-get install sox
Or install from source.
Basic Usage
To use manim-voiceover
, you simply import the VoiceoverScene
class from the plugin
from manim_voiceover import VoiceoverScene
You make sure your Scene classes inherit from VoiceoverScene
:
class MyAwesomeScene(VoiceoverScene):
def construct(self):
...
manim-voiceover
offers multiple text-to-speech engines, some proprietary and some free. A good one to start with is gTTS, which uses Google Translate's proprietary API. We found out that this is the best for beginners in terms of cross-platform compatibility---however it needs an internet connection.
from manim_voiceover import VoiceoverScene
from manim_voiceover.interfaces import GTTSService
class MyAwesomeScene(VoiceoverScene):
def construct(self):
self.set_speech_service(GTTSService())
The logic for adding a voiceover is pretty simple. Wrap the animation inside a with
block that calls self.voiceover()
:
with self.voiceover(text="This circle is drawn as I speak.") as tracker:
... # animate whatever needs to be animated here
Manim will animate whatever is inside that with block. If the voiceover hasn't finished by the end of the animation, Manim will simply wait until it does. You can further use the tracker
object for getting the total or remaining duration of the voiceover programmatically, which gives you finer control over the video:
with self.voiceover(text="This circle is drawn as I speak.") as tracker:
self.play(Create(circle), run_time=tracker.duration)
Using with-blocks results in clean code, allows you to chain sentences back to back and also serve as a documentation of sorts, as the video is neatly compartmentalized according to whatever lines are spoken during the animations.
See the examples directory for more examples. We recommend starting with the gTTS example.
Configuring Azure
The highest quality text-to-speech services available to the public is currently offered by Microsoft Azure. To use it, you need to create an Azure account.
Then, you need to find out your subscription key and service region. Check out Azure docs for more details.
Create a file called .env
that contains your authentication information in the same directory where you call Manim.
AZURE_SUBSCRIPTION_KEY="..."
AZURE_SERVICE_REGION="..."
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file manim_voiceover-0.1.0.tar.gz
.
File metadata
- Download URL: manim_voiceover-0.1.0.tar.gz
- Upload date:
- Size: 13.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.15
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 54fba74fada260ae1e5909dc5278792f429cb8a10a3fd96a76fa698f09e577fb |
|
MD5 | 6fd4b7b4a8a511da50bd9425ac16c5f9 |
|
BLAKE2b-256 | 56749c1a2102cccd89254312afc5e4ab64819b3f2aa60c000c99ab70b35e68e4 |
File details
Details for the file manim_voiceover-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: manim_voiceover-0.1.0-py3-none-any.whl
- Upload date:
- Size: 14.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.15
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 33e2a20410579fdfbefea7b8340cc7122800399d67e3f28fc24bf160cd34653e |
|
MD5 | 4620594fbb79ac1722d21781e1725e21 |
|
BLAKE2b-256 | 3445bf992cb79c13acf5dca2d1dd5425ae8da69feb947508096f02662b4711ae |