Skip to main content

Manim plugin for all things voiceover

Project description

manim-voiceover

Github Actions Status License

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)

Here is a demo:

https://user-images.githubusercontent.com/2453968/198145393-6a1bd709-4441-4821-8541-45d5f5e25be7.mp4

Currently supported TTS services:

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

manim_voiceover-0.1.1.tar.gz (13.3 kB view details)

Uploaded Source

Built Distribution

manim_voiceover-0.1.1-py3-none-any.whl (14.6 kB view details)

Uploaded Python 3

File details

Details for the file manim_voiceover-0.1.1.tar.gz.

File metadata

  • Download URL: manim_voiceover-0.1.1.tar.gz
  • Upload date:
  • Size: 13.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.15

File hashes

Hashes for manim_voiceover-0.1.1.tar.gz
Algorithm Hash digest
SHA256 1666248a746cb207db2478901ecd813134ae1d64a3bcac9cf467a99821f83028
MD5 38b45f5dd92904f6489786fab06fee4d
BLAKE2b-256 89106de08a0a3a917dff74d60bc9931a176aa55eb9b48f1fa0f8181dacfa1a9c

See more details on using hashes here.

File details

Details for the file manim_voiceover-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for manim_voiceover-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d0229da0fc66096da77ccfa6de9ae6c5a77390d7760ec3e8e722ca217a58c7bf
MD5 e56113d5c132a9a51f98f358f7b10c90
BLAKE2b-256 50c86d04794c2704393cae3d5999d9c6d844944523b18407fcb1618ea34dfbd8

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page