Install DeepSpeech feature processing routines
mainTo use the DeepSpeech feature processing routines, install the necessary dependencies using pip from the requirements.txt file.
pip3 install -r requirements.txtrepository·main·Indexed 23 days ago
https://github.com/ziqiaopeng/synctalkSyncTalk is a talking head synthesis system that utilizes tri-plane hash representations to generate synchronized lip movements, facial expressions, and stable head poses from audio and video input. The system supports training, evaluation, and inference, offering multiple ASR model options including ave, deepspeech, and hubert. It includes utilities for extracting DeepSpeech features, capturing facial blendshapes via MediaPipe, and specialized torso training to resolve double chin artifacts.
To use the DeepSpeech feature processing routines, install the necessary dependencies using pip from the requirements.txt file.
pip3 install -r requirements.txtTo prepare a video for training or inference, use data_utils/process.py.
Requirements:
Command:
python data_utils/process.py data/<ID>/<ID>.mp4 --asr aveASR Options (--asr):
ave: Audio Visual Encoder (recommended for accurate lip sync).deepspeechhubertProcessed videos are saved in the data folder.
python data_utils/process.py data/<ID>/<ID>.mp4 --asr aveBefore running SyncTalk, you must organize your data and models as follows:
Pre-trained Models:
May.zip in the data folder and unzip it.trial_may.zip in the model folder and unzip it.Face Parsing Model:
wget https://github.com/YudongGuo/AD-NeRF/blob/master/data_util/face_parsing/79999_iter.pth?raw=true -O data_utils/face_parsing/79999_iter.pth3DMM Model for Head Pose Estimation:
Download the following files to data_utils/face_tracking/3DMM/:
exp_info.npykeys_info.npysub_mesh.objtopology_info.npyBasel Face Model (BFM):
01_MorphableModel.mat to data_util/face_tracking/3DMM/.cd data_utils/face_tracking
python convert_BFM.pyTraining can be performed using the main.py script. By default, data is loaded from disk on the fly (--preload 0).
# Basic training
python main.py data/May --workspace model/trial_may -O --iters 60000 --asr_model ave
# Training with lip fine-tuning
python main.py data/May --workspace model/trial_may -O --iters 100000 --finetune_lips --patch_size 64 --asr_model ave--asr_model)ave: Best for characters with large lip movements. Use this for better lip sync.deepspeech: Use if training with ave results in lip jitter.hubert: Use if training with ave results in lip jitter.--au45 flag.--preload 0: Load from disk (default, slower).--preload 1: Load to CPU (slightly slower).--preload 2: Load to GPU (fast, but high memory usage).python main.py data/May --workspace model/trial_may -O --iters 60000 --asr_model aveFor Windows users, a pre-integrated package is available. Download SyncTalk-Windows.zip, unzip the contents, and run the inference.bat file to start the demo.
Download Links:
double-click `inference.bat` to run the demoIf the head-only trained model produces a "double chin" effect, you can perform torso training.
Warning: When using torso training, you cannot use the --portrait mode. Adding --portrait will cause the torso model to fail.
Pass the latest head checkpoint using --head_ckpt:
# Example: training torso using a head checkpoint
python main.py data/May/ --workspace model/trial_may_torso/ -O --torso --head_ckpt model/trial_may/ngp_ep0019.pth --iters 150000 --asr_model ave# Test torso model
python main.py data/May/ --workspace model/trial_may_torso/ -O --torso --test --asr_model ave
# Inference with target audio
python main.py data/May/ --workspace model/trial_may_torso/ -O --torso --test --test_train --asr_model ave --aud ./demo/test.wavpython main.py data/May/ --workspace model/trial_may_torso/ -O --torso --head_ckpt model/trial_may/ngp_ep0019.pth --iters 150000 --asr_model aveSyncTalk is tested on Ubuntu 18.04 with Pytorch 1.12.1 and CUDA 11.3. Follow these steps to set up the environment:
git clone https://github.com/ZiqiaoPeng/SyncTalk.git
cd SyncTalkconda create -n synctalk python==3.8.8
conda activate synctalkpip install torch==1.12.1+cu113 torchvision==0.13.1+cu113 torchaudio==0.12.1 --extra-index-url https://download.pytorch.org/whl/cu113
sudo apt-get install portaudio19-dev
pip install -r requirements.txt
pip install --no-index --no-cache-dir pytorch3d -f https://dl.fbaipublicfiles.com/pytorch3d/packaging/wheels/py38_cu113_pyt1121/download.html
pip install tensorflow-gpu==2.8.1pip install ./freqencoder
pip install ./shencoder
pip install ./gridencoder
pip install ./raymarchingNote: If PyTorch3D installation fails, use the provided script:
python ./scripts/install_pytorch3d.pygit clone https://github.com/ZiqiaoPeng/SyncTalk.git
cd SyncTalkThe main.py script serves as the primary entrypoint for the SyncTalk pipeline, supporting training, testing, and GUI modes. The script requires a path argument (likely the dataset path) and provides extensive configuration via command-line flags.
--test to load a model and run on the test dataset. Use --test_train to load a model and test specifically on the training dataset.--gui to launch an interactive GUI for rendering and inspection.To prevent low numerical accuracy on RTX 30xx series GPUs, the script automatically attempts to disable tf32 features:
torch.backends.cuda.matmul.allow_tf32 = False
torch.backends.cudnn.allow_tf32 = FalseRun evaluation on a processed subject:
# Standard evaluation
python main.py data/May --workspace model/trial_may -O --test --asr_model ave
# Evaluation with Portrait mode (pasting face back onto original image for higher quality)
python main.py data/May --workspace model/trial_may -O --test --asr_model ave --portraitTo generate a talking head from a specific audio file:
python main.py data/May --workspace model/trial_may -O --test --test_train --asr_model ave --portrait --aud ./demo/test.wav.wav files for inference.model/trial_may/results/.ave), replace the .wav path with the corresponding .npy file path.python main.py data/May --workspace model/trial_may -O --test --test_train --asr_model ave --portrait --aud ./demo/test.wavUse extract_ds_features.py to generate DeepSpeech features from a directory of input files. Provide the path to your data directory using the --input flag.
python3 extract_ds_features.py --input=<you_data_dir>Use extract_wav.py to generate .wav files from a directory of video data. Provide the path to your data directory using the --in-video flag.
python3 extract_wav.py --in-video=<you_data_dir>The infer_bs(root_path) function is the core logic for the blendshape capture process. It initializes a MediaPipe FaceLandmarker with output_face_blendshapes=True and output_facial_transformation_matrixes=True.
It iterates through all .mp4 files in the root_path. For each video, it:
bs.npy already exists to avoid redundant processing.scipy.signal.savgol_filter.bs.npy using np.save.