PyToon
Overview
PyToon is a Python-based animation library for animating characters and their mouth movements. This tool uses machine learning-based audio analysis techniques to automatically lip-sync animated character mouth movements to a given audio recording of someone talking.
Features
- Automatically create cartoon animated lip-sync videos from just an audio file.
- Use a provided transcript or let PyToon automatically generate the transcript from the audio with built-in text-to-speech.
- Programmatically generate animated videos.
- OS Independent! PyToon works on Mac, Windows, and Linux.
- Optimized for both CPU and GPU.
- Fast Processing! A 60-second lip-sync animation clip takes ~39 seconds to generate.
Getting Started
- Install pytoon:
pip3 install pytoon - Install ffmpeg:
- Mac:
brew install ffmpeg - Linux:
sudo apt install ffmpeg - Windows: Install from ffmpeg.org
- Mac:
Basic Usage
Example 1: Generating Animation from an MP3 File (with transcript)
If you have a transcript of the audio, you can directly pass it to the animate function.
from pytoon.animator import animate
from moviepy.editor import VideoFileClip
# Read audio transcript to a string.
transcript_path = "./.temp/speech.txt"
with open(transcript_path, "r") as file:
transcript = file.read()
# Create a PyToon animation
animation = animate(
audio_file="speech.mp3", # Input audio
transcript=transcript, # Audio transcript
)
# Overlay the animation on top of another video and save as an .mp4 file.
background_video = VideoFileClip("./path/to/background_video.mp4")
animation.export(path='video_with_transcript.mp4', background=background_video, scale=0.7)
Example 2: Example 1: Generating Animation from an MP3 File (without transcript)
If you do not have a transcript, PyToon can automatically generate one using text-to-speech.
from pytoon.animator import animate
from moviepy.editor import VideoFileClip
# Create a PyToon animation without providing a transcript
animation = animate(
audio_file="speech.mp3" # Input audio (transcript will be auto-generated)
)
# Overlay the animation on top of another video and save as an .mp4 file.
background_video = VideoFileClip("./path/to/background_video.mp4")
animation.export(path='video_auto_transcript.mp4', background=background_video, scale=0.7)
Acknowledgements
This project uses character images created by lazykh.
Metadata
Release files for pytoon 1.5.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pytoon-1.5.0.tar.gz | 3.8 MB | Without provenance | Details for pytoon-1.5.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pytoon-1.5.0-py3-none-any.whl | Python 3 | none | any | Details for pytoon-1.5.0-py3-none-any.whl |
Total release size: 7.7 MB
Release files / pytoon-1.5.0.tar.gz
| Download URL | pytoon-1.5.0.tar.gz |
|---|---|
| Size | 3.8 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a48afa9f23b32bc8c0085a68cd98f3debb6298c7b5ef60f0be28efbaa29d2d31
|
|
BLAKE2b-256 checksum How to use checksums |
7531d118c3d80cc1a4c0020a40cb21230eb670c3b7ffab30db56308ee06d40e3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.10.15
|
Release files / pytoon-1.5.0-py3-none-any.whl
| Download URL | pytoon-1.5.0-py3-none-any.whl |
|---|---|
| Size | 3.8 MB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
bb7913f23770f6e39019c6a177a515319e0f7fb77dcc916fc979a784cbae737f
|
|
BLAKE2b-256 checksum How to use checksums |
eb6a1de5a2460113c5c7990d2b52e5860bf20aafc565b5780b5585aeeaab8d14
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.10.15
|
Security for pytoon 1.5.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.