Skip to main content

A Python library for lip-syncing cartoons to voice recordings.

Project description

PyToon

Downloads

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.

Example Output Video

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

  1. Install pytoon: pip3 install pytoon
  2. Install ffmpeg:
    • Mac: brew install ffmpeg
    • Linux: sudo apt install ffmpeg
    • Windows: Install from ffmpeg.org

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.

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

pytoon-1.5.0.tar.gz (3.8 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pytoon-1.5.0-py3-none-any.whl (3.8 MB view details)

Uploaded Python 3

File details

Details for the file pytoon-1.5.0.tar.gz.

File metadata

  • Download URL: pytoon-1.5.0.tar.gz
  • Upload date:
  • Size: 3.8 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.10.15

File hashes

Hashes for pytoon-1.5.0.tar.gz
Algorithm Hash digest
SHA256 a48afa9f23b32bc8c0085a68cd98f3debb6298c7b5ef60f0be28efbaa29d2d31
MD5 9a0cd53af60e09fe6f2406891401236e
BLAKE2b-256 7531d118c3d80cc1a4c0020a40cb21230eb670c3b7ffab30db56308ee06d40e3

See more details on using hashes here.

File details

Details for the file pytoon-1.5.0-py3-none-any.whl.

File metadata

  • Download URL: pytoon-1.5.0-py3-none-any.whl
  • Upload date:
  • Size: 3.8 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.10.15

File hashes

Hashes for pytoon-1.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 bb7913f23770f6e39019c6a177a515319e0f7fb77dcc916fc979a784cbae737f
MD5 0baa641636aebe1a224b9bc8b3208ff5
BLAKE2b-256 eb6a1de5a2460113c5c7990d2b52e5860bf20aafc565b5780b5585aeeaab8d14

See more details on using hashes here.

Supported by

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