MuseTalk: Real-Time High-Fidelity Video Dubbing via Spatio-Temporal Sampling
Yue Zhang*, Zhizhou Zhong*, Minhao Liu*, Zhaokang Chen, Bin Wuβ , Yubin Zeng, Chao Zhan, Junxin Huang, Yingjie He, Wenjiang Zhou (*Equal Contribution, β Corresponding Author, [email protected])
Lyra Lab, Tencent Music Entertainment
github huggingface space Technical report
We introduce MuseTalk
, a real-time high quality lip-syncing model (30fps+ on an NVIDIA Tesla V100). MuseTalk can be applied with input videos, e.g., generated by MuseV, as a complete virtual human solution.
We're excited to unveil MuseTalk 1.5. This version (1) integrates training with perceptual loss, GAN loss, and sync loss, significantly boosting its overall performance. (2) We've implemented a two-stage training strategy and a spatio-temporal data sampling approach to strike a balance between visual quality and lip-sync accuracy. Learn more details here. The inference codes, training codes and model weights of MuseTalk 1.5 are all available now! π
MuseTalk
is a real-time high quality audio-driven lip-syncing model trained in the latent space of ft-mse-vae
, which
- modifies an unseen face according to the input audio, with a size of face region of
256 x 256
. - supports audio in various languages, such as Chinese, English, and Japanese.
- supports real-time inference with 30fps+ on an NVIDIA Tesla V100.
- supports modification of the center point of the face region proposes, which SIGNIFICANTLY affects generation results.
- checkpoint available trained on the HDTF and private dataset.
- [04/05/2025] π£ We are excited to announce that the training code is now open-sourced! You can now train your own MuseTalk model using our provided training scripts and configurations.
- [03/28/2025] We are thrilled to announce the release of our 1.5 version. This version is a significant improvement over the 1.0 version, with enhanced clarity, identity consistency, and precise lip-speech synchronization. We update the technical report with more details.
- [10/18/2024] We release the technical report. Our report details a superior model to the open-source L1 loss version. It includes GAN and perceptual losses for improved clarity, and sync loss for enhanced performance.
- [04/17/2024] We release a pipeline that utilizes MuseTalk for real-time inference.
- [04/16/2024] Release Gradio demo on HuggingFace Spaces (thanks to HF team for their community grant)
- [04/02/2024] Release MuseTalk project and pretrained models.
MuseTalk was trained in latent spaces, where the images were encoded by a freezed VAE. The audio was encoded by a freezed
whisper-tiny
model. The architecture of the generation network was borrowed from the UNet of the stable-diffusion-v1-4
, where the audio embeddings were fused to the image embeddings by cross-attention.
Note that although we use a very similar architecture as Stable Diffusion, MuseTalk is distinct in that it is NOT a diffusion model. Instead, MuseTalk operates by inpainting in the latent space with a single step.
sun_musev.mp4output.mp49.mp411.mp4sli_480P.mp4talk_480P.mp4 |
8_8.mp4output_V1.mp49_9.mp411_11.mp4silent_v1.mp4talk_v1.mp4 |
8_8.mp4V1.5.mp49_9.mp411_11.mp4silent_v15.mp4talk_v15.mp4 |
- trained models and inference codes.
- Huggingface Gradio demo.
- codes for real-time inference.
- technical report.
- a better model with updated technical report.
- realtime inference code for 1.5 version.
- training and data preprocessing codes.
- always welcome to submit issues and PRs to improve this repository! π
We provide a detailed tutorial about the installation and the basic usage of MuseTalk for new users:
Thanks for the third-party integration, which makes installation and use more convenient for everyone. We also hope you note that we have not verified, maintained, or updated third-party. Please refer to this project for specific results.
To prepare the Python environment and install additional packages such as opencv, diffusers, mmcv, etc., please follow the steps below:
We recommend Python 3.10 and CUDA 11.7. Set up your environment as follows:
conda create -n MuseTalk python==3.10
conda activate MuseTalk
Choose one of the following installation methods:
# Option 1: Using pip
pip install torch==2.0.1 torchvision==0.15.2 torchaudio==2.0.2 --index-url https://download.pytorch.org/whl/cu118
# Option 2: Using conda
conda install pytorch==2.0.1 torchvision==0.15.2 torchaudio==2.0.2 pytorch-cuda=11.8 -c pytorch -c nvidia
Install the remaining required packages:
pip install -r requirements.txt
Install the MMLab ecosystem packages:
pip install --no-cache-dir -U openmim
mim install mmengine
mim install "mmcv==2.0.1"
mim install "mmdet==3.1.0"
mim install "mmpose==1.1.0"
-
Download the ffmpeg-static package
-
Configure FFmpeg based on your operating system:
For Linux:
export FFMPEG_PATH=/path/to/ffmpeg
# Example:
export FFMPEG_PATH=/musetalk/ffmpeg-4.4-amd64-static
For Windows:
Add the ffmpeg-xxx\bin
directory to your system's PATH environment variable. Verify the installation by running ffmpeg -version
in the command prompt - it should display the ffmpeg version information.
You can download weights in two ways:
We provide two scripts for automatic downloading:
For Linux:
sh ./download_weights.sh
For Windows:
# Run the script
download_weights.bat
You can also download the weights manually from the following links:
- Download our trained weights
- Download the weights of other components:
Finally, these weights should be organized in models
as follows:
./models/
βββ musetalk
β βββ musetalk.json
β βββ pytorch_model.bin
βββ musetalkV15
β βββ musetalk.json
β βββ unet.pth
βββ syncnet
β βββ latentsync_syncnet.pt
βββ dwpose
β βββ dw-ll_ucoco_384.pth
βββ face-parse-bisent
β βββ 79999_iter.pth
β βββ resnet18-5c106cde.pth
βββ sd-vae
β βββ config.json
β βββ diffusion_pytorch_model.bin
βββ whisper
βββ config.json
βββ pytorch_model.bin
βββ preprocessor_config.json
We provide inference scripts for both versions of MuseTalk:
Before running inference, please ensure ffmpeg is installed and accessible:
# Check ffmpeg installation
ffmpeg -version
If ffmpeg is not found, please install it first:
- Windows: Download from ffmpeg-static and add to PATH
- Linux:
sudo apt-get install ffmpeg
# MuseTalk 1.5 (Recommended)
sh inference.sh v1.5 normal
# MuseTalk 1.0
sh inference.sh v1.0 normal
Please ensure that you set the ffmpeg_path
to match the actual location of your FFmpeg installation.
# MuseTalk 1.5 (Recommended)
python -m scripts.inference --inference_config configs\inference\test.yaml --result_dir results\test --unet_model_path models\musetalkV15\unet.pth --unet_config models\musetalkV15\musetalk.json --version v15 --ffmpeg_path ffmpeg-master-latest-win64-gpl-shared\bin
# For MuseTalk 1.0, change:
# - models\musetalkV15 -> models\musetalk
# - unet.pth -> pytorch_model.bin
# - --version v15 -> --version v1
# MuseTalk 1.5 (Recommended)
sh inference.sh v1.5 realtime
# MuseTalk 1.0
sh inference.sh v1.0 realtime
# MuseTalk 1.5 (Recommended)
python -m scripts.realtime_inference --inference_config configs\inference\realtime.yaml --result_dir results\realtime --unet_model_path models\musetalkV15\unet.pth --unet_config models\musetalkV15\musetalk.json --version v15 --fps 25 --ffmpeg_path ffmpeg-master-latest-win64-gpl-shared\bin
# For MuseTalk 1.0, change:
# - models\musetalkV15 -> models\musetalk
# - unet.pth -> pytorch_model.bin
# - --version v15 -> --version v1
The configuration file configs/inference/test.yaml
contains the inference settings, including:
video_path
: Path to the input video, image file, or directory of imagesaudio_path
: Path to the input audio file
Note: For optimal results, we recommend using input videos with 25fps, which is the same fps used during model training. If your video has a lower frame rate, you can use frame interpolation or convert it to 25fps using ffmpeg.
Important notes for real-time inference:
- Set
preparation
toTrue
when processing a new avatar - After preparation, the avatar will generate videos using audio clips from
audio_clips
- The generation process can achieve 30fps+ on an NVIDIA Tesla V100
- Set
preparation
toFalse
for generating more videos with the same avatar
For faster generation without saving images, you can use:
python -m scripts.realtime_inference --inference_config configs/inference/realtime.yaml --skip_save_images
We provide an intuitive web interface through Gradio for users to easily adjust input parameters. To optimize inference time, users can generate only the first frame to fine-tune the best lip-sync parameters, which helps reduce facial artifacts in the final output.
For minimum hardware requirements, we tested the system on a Windows environment using an NVIDIA GeForce RTX 3050 Ti Laptop GPU with 4GB VRAM. In fp16 mode, generating an 8-second video takes approximately 5 minutes.
Both Linux and Windows users can launch the demo using the following command. Please ensure that the ffmpeg_path
parameter matches your actual FFmpeg installation path:
# You can remove --use_float16 for better quality, but it will increase VRAM usage and inference time
python app.py --use_float16 --ffmpeg_path ffmpeg-master-latest-win64-gpl-shared\bin
To train MuseTalk, you need to prepare your dataset following these steps:
-
Place your source videos
For example, if you're using the HDTF dataset, place all your video files in
./dataset/HDTF/source
. -
Run the preprocessing script
python -m scripts.preprocess --config ./configs/training/preprocess.yaml
This script will:
- Extract frames from videos
- Detect and align faces
- Generate audio features
- Create the necessary data structure for training
After data preprocessing, you can start the training process:
-
First Stage
sh train.sh stage1
-
Second Stage
sh train.sh stage2
Before starting the training, you should adjust the configuration files according to your hardware and requirements:
-
GPU Configuration (
configs/training/gpu.yaml
):gpu_ids
: Specify the GPU IDs you want to use (e.g., "0,1,2,3")num_processes
: Set this to match the number of GPUs you're using
-
Stage 1 Configuration (
configs/training/stage1.yaml
):data.train_bs
: Adjust batch size based on your GPU memory (default: 32)data.n_sample_frames
: Number of sampled frames per video (default: 1)
-
Stage 2 Configuration (
configs/training/stage2.yaml
):random_init_unet
: Must be set toFalse
to use the model from stage 1data.train_bs
: Smaller batch size due to high GPU memory cost (default: 2)data.n_sample_frames
: Higher value for temporal consistency (default: 16)solver.gradient_accumulation_steps
: Increase to simulate larger batch sizes (default: 8)
Based on our testing on a machine with 8 NVIDIA H20 GPUs:
Batch Size | Gradient Accumulation | Memory per GPU | Recommendation |
---|---|---|---|
8 | 1 | ~32GB | |
16 | 1 | ~45GB | |
32 | 1 | ~74GB | β |
Batch Size | Gradient Accumulation | Memory per GPU | Recommendation |
---|---|---|---|
1 | 8 | ~54GB | |
2 | 2 | ~80GB | |
2 | 8 | ~85GB | β |
π We have found that upper-bound of the mask has an important impact on mouth openness. Thus, to control the mask region, we suggest using the bbox_shift
parameter. Positive values (moving towards the lower half) increase mouth openness, while negative values (moving towards the upper half) decrease mouth openness.
You can start by running with the default configuration to obtain the adjustable value range, and then re-run the script within this range.
For example, in the case of Xinying Sun
, after running the default configuration, it shows that the adjustable value rage is [-9, 9]. Then, to decrease the mouth openness, we set the value to be -7
.
python -m scripts.inference --inference_config configs/inference/test.yaml --bbox_shift -7
π More technical details can be found in bbox_shift.
As a complete solution to virtual human generation, you are suggested to first apply MuseV to generate a video (text-to-video, image-to-video or pose-to-video) by referring this. Frame interpolation is suggested to increase frame rate. Then, you can use MuseTalk
to generate a lip-sync video by referring this.
- We thank open-source components like whisper, dwpose, face-alignment, face-parsing, S3FD and LatentSync.
- MuseTalk has referred much to diffusers and isaacOnline/whisper.
- MuseTalk has been built on HDTF datasets.
Thanks for open-sourcing!
-
Resolution: Though MuseTalk uses a face region size of 256 x 256, which make it better than other open-source methods, it has not yet reached the theoretical resolution bound. We will continue to deal with this problem.
If you need higher resolution, you could apply super resolution models such as GFPGAN in combination with MuseTalk. -
Identity preservation: Some details of the original face are not well preserved, such as mustache, lip shape and color.
-
Jitter: There exists some jitter as the current pipeline adopts single-frame generation.
@article{musetalk,
title={MuseTalk: Real-Time High-Fidelity Video Dubbing via Spatio-Temporal Sampling},
author={Zhang, Yue and Zhong, Zhizhou and Liu, Minhao and Chen, Zhaokang and Wu, Bin and Zeng, Yubin and Zhan, Chao and He, Yingjie and Huang, Junxin and Zhou, Wenjiang},
journal={arxiv},
year={2025}
}
code
: The code of MuseTalk is released under the MIT License. There is no limitation for both academic and commercial usage.model
: The trained model are available for any purpose, even commercially.other opensource model
: Other open-source models used must comply with their license, such aswhisper
,ft-mse-vae
,dwpose
,S3FD
, etc..- The testdata are collected from internet, which are available for non-commercial research purposes only.
AIGC
: This project strives to impact the domain of AI-driven video generation positively. Users are granted the freedom to create videos using this tool, but they are expected to comply with local laws and utilize it responsibly. The developers do not assume any responsibility for potential misuse by users.