Professional library for generating high-quality voiceovers in Manim animations using Kokoro-82M model
Project description
Kokoro Manim Voiceover
Professional library for generating high-quality voiceovers in Manim animations using the Kokoro-82M model.
Installation
From PyPI (Recommended)
pip install kokoro-manim-voiceover
Using uv (Alternative)
# For new projects
uv init my-project
cd my-project
uv add kokoro-manim-voiceover
# Or install directly
uv pip install kokoro-manim-voiceover
Note: uv is a modern, high-performance Python package manager that offers significantly faster installations and better dependency resolution than pip. It's fully compatible with existing Python workflows.
From Source
git clone https://github.com/xposed73/kokoro-manim-voiceover.git
cd kokoro-manim-voiceover
pip install -e .
Quick Start
from manim import *
from manim_voiceover import VoiceoverScene
from kokoro_mv import KokoroService
class MyAnimation(VoiceoverScene):
def construct(self):
self.set_speech_service(KokoroService(voice="af_sarah", lang="en-us"))
with self.voiceover(text="Hello, this is my first voiceover!") as tracker:
self.play(Write(Text("Hello, this is my first voiceover!")), run_time=tracker.duration)
Voices (Kokoro-82M)
This library uses the Kokoro-82M voice models. Below is a curated list of available voices grouped by language, adapted from the upstream model's VOICES.md.
Note: Voice quality varies by dataset size/quality. Some languages have fewer voices and may rely on fallback G2P. See the Kokoro-82M model card for details.
English (American)
af_heart, af_alloy, af_aoede, af_bella, af_jessica, af_kore,
af_nicole, af_nova, af_river, af_sarah, af_sky,
am_adam, am_echo, am_eric, am_fenrir, am_liam, am_michael,
am_onyx, am_puck, am_santa
English (British)
bf_alice, bf_emma, bf_isabella, bf_lily,
bm_daniel, bm_fable, bm_george, bm_lewis
Japanese
jf_alpha, jf_gongitsune, jf_nezumi, jf_tebukuro,
jm_kumo
Mandarin Chinese
zf_xiaobei, zf_xiaoni, zf_xiaoxiao, zf_xiaoyi,
zm_yunjian, zm_yunxi, zm_yunxia, zm_yunyang
Spanish
ef_dora, em_alex, em_santa
French
ff_siwis
Hindi
hf_alpha, hf_beta, hm_omega, hm_psi
Italian
if_sara, im_nicola
Brazilian Portuguese
pf_dora, pm_alex, pm_santa
Selecting voices and languages
- Set
voiceto one of the codes above. - Set
langto match your target locale. Recommended codes for phonemizer compatibility:- English (US):
en-us - English (GB):
en-gb - Japanese:
ja - Mandarin Chinese:
cmn(instead ofzh) - Spanish:
es - French:
fr-fr(instead offr) - Hindi:
hi - Italian:
it - Brazilian Portuguese:
pt-br
- English (US):
Example:
self.set_speech_service(KokoroService(voice="hf_alpha", lang="hi"))
Source: Kokoro-82M VOICES.md by hexgrad (Apache-2.0).
Video Samples
Preview recordings rendered from the included sample scenes:
Mandarin Chinese
https://github.com/user-attachments/assets/cc9cacd6-001e-43f8-a441-14ad20da6cfa
English (GB)
https://github.com/user-attachments/assets/12e01a68-35b6-435d-9cfe-5f414f16210a
English (US)
https://github.com/user-attachments/assets/d1b0de7a-42fb-4e46-a2c7-6ec0f2a37006
French
https://github.com/user-attachments/assets/f3c7eed1-b5c0-4423-a62a-19d56405d486
Hindi
https://github.com/user-attachments/assets/cc131788-03f7-4157-bb4e-db074f328d3e
Italian
https://github.com/user-attachments/assets/d2fd228e-0179-4008-9e5f-464b5cbfe053
Portuguese
https://github.com/user-attachments/assets/ed17f48f-e541-4b2a-b820-f0a13b175df8
Sample Scenes (code)
Code examples for each language are available in the samples/ folder. Each file sets an appropriate voice and lang and renders the same demo scene.
samples/english_us.py→ voiceaf_sarah, langen-ussamples/english_gb.py→ voicebf_emma, langen-gbsamples/hindi.py→ voicehf_alpha, langhisamples/chinese_mandarin.py→ voicezf_xiaobei, langcmnsamples/spanish.py→ voiceef_dora, langessamples/french.py→ voiceff_siwis, langfr-frsamples/italian.py→ voiceif_sara, langitsamples/portuguese_br.py→ voicepf_dora, langpt-br
Run any sample (replace the filename as needed):
# Option A: from repository root
manim -pql samples/english_us.py Example
# or with uv
uv run manim -pql samples/english_us.py Example
# Option B: cd into samples first
cd samples
manim -pql english_us.py Example
Notes:
- For Japanese and Mandarin, ensure eSpeak NG is installed and
langcodes are set as above (e.g.,cmnfor Mandarin) to avoid phonemizer issues. - If you encounter “phonemes too long” errors, split long narration into multiple
with self.voiceover(...)blocks. - The sample scenes use the
manim-dsalibrary for data-structure visuals. Install it first if needed:pip install manim-dsa # OR uv add manim-dsa
Usage Examples
Basic Animation
class BasicExample(VoiceoverScene):
def construct(self):
self.set_speech_service(KokoroService(voice="af_sarah", lang="en-us"))
circle = Circle()
square = Square().shift(2 * RIGHT)
with self.voiceover(text="This circle is drawn as I speak.") as tracker:
self.play(Create(circle), run_time=tracker.duration)
with self.voiceover(text="Now let's transform it into a square.") as tracker:
self.play(Transform(circle, square), run_time=tracker.duration)
Custom Configuration
service = KokoroService(
voice="af_sarah", # Female voice
speed=1.2, # 20% faster
lang="en-us", # Language setting
volume=1.2 # Volume
)
Requirements
- Python 3.11+
- Dependencies are automatically installed
Model Files
The library automatically downloads required model files (~220MB) on first use.
Development
Setting up development environment
Using uv (Recommended)
# Clone the repository
git clone https://github.com/xposed73/kokoro-manim-voiceover.git
cd kokoro-manim-voiceover
# Install in development mode with all dependencies
uv sync --dev
# Run tests
uv run pytest
# Format code
uv run black .
uv run isort .
# Type checking
uv run mypy .
Using pip
# Clone the repository
git clone https://github.com/xposed73/kokoro-manim-voiceover.git
cd kokoro-manim-voiceover
# Create virtual environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install in development mode
pip install -e ".[dev]"
# Run tests
pytest
# Format code
black .
isort .
Publishing to PyPI
To publish this package to PyPI:
-
Install build tools:
pip install build twine
-
Build the package:
python -m build
This creates
dist/directory with wheel and source distribution files. -
Upload to PyPI (TestPyPI first for testing):
# Test on TestPyPI twine upload --repository-url https://test.pypi.org/legacy/ dist/* # Once verified, upload to production PyPI twine upload dist/*
-
Verify installation:
pip install kokoro-manim-voiceover
Note: You'll need PyPI credentials (API token recommended). Create one at pypi.org/manage/account/token/
License
MIT License
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file kokoro_manim_voiceover-0.1.5.tar.gz.
File metadata
- Download URL: kokoro_manim_voiceover-0.1.5.tar.gz
- Upload date:
- Size: 10.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cbceb158886ecd2560c1e8440d287c32667bbd39e35ac3b569b80e5e785293c9
|
|
| MD5 |
cc0d4ce2ca6287dfd447e53d1988f62f
|
|
| BLAKE2b-256 |
aa673f80092064db0973f2f6d1d39691a32145631281271f7d3ac22179ca7d29
|
Provenance
The following attestation bundles were made for kokoro_manim_voiceover-0.1.5.tar.gz:
Publisher:
publish.yml on xposed73/kokoro-manim-voiceover
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
kokoro_manim_voiceover-0.1.5.tar.gz -
Subject digest:
cbceb158886ecd2560c1e8440d287c32667bbd39e35ac3b569b80e5e785293c9 - Sigstore transparency entry: 652106467
- Sigstore integration time:
-
Permalink:
xposed73/kokoro-manim-voiceover@f551e5e90ae993e88e5a80255271beccab3f3a07 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/xposed73
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@f551e5e90ae993e88e5a80255271beccab3f3a07 -
Trigger Event:
push
-
Statement type:
File details
Details for the file kokoro_manim_voiceover-0.1.5-py3-none-any.whl.
File metadata
- Download URL: kokoro_manim_voiceover-0.1.5-py3-none-any.whl
- Upload date:
- Size: 10.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0fb0ec90a91afc271ed9b83f7b8e304fa17e1af3d17873c9c80bd5ae40ed278f
|
|
| MD5 |
8e2e75f6ebc6338404897991c1f0403e
|
|
| BLAKE2b-256 |
48c3845e9708e4844e38c7ff03bf7d5c67bfb248c5ea9f9f97621ccabcf37264
|
Provenance
The following attestation bundles were made for kokoro_manim_voiceover-0.1.5-py3-none-any.whl:
Publisher:
publish.yml on xposed73/kokoro-manim-voiceover
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
kokoro_manim_voiceover-0.1.5-py3-none-any.whl -
Subject digest:
0fb0ec90a91afc271ed9b83f7b8e304fa17e1af3d17873c9c80bd5ae40ed278f - Sigstore transparency entry: 652106472
- Sigstore integration time:
-
Permalink:
xposed73/kokoro-manim-voiceover@f551e5e90ae993e88e5a80255271beccab3f3a07 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/xposed73
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@f551e5e90ae993e88e5a80255271beccab3f3a07 -
Trigger Event:
push
-
Statement type: