DiffSinger

repository·master·Indexed 26 days ago

https://github.com/moonintheriver/diffsinger

A Singing Voice Synthesis (SVS) system utilizing a shallow diffusion mechanism. The project also includes DiffSpeech for Text-to-Speech (TTS) tasks and supports various pipelines for datasets like PopCS and OpenCpop. It features integration with HifiGAN-Singing vocoders, PNDM speedup for inference, and a two-step cascade training process involving FFT-Singer.

Tokens
5.6K
Snippets
19
Records
34
Agent score
88%

What's inside DiffSinger

  1. Overview of DiffSinger and DiffSpeech Pipelines

    master

    DiffSinger provides several Mel pipelines depending on the task (SVS vs TTS), dataset, and input type (MIDI vs Lyric).

    PipelineTaskDatasetPitch InputF0 PredictionAccelerationVocoder
    DiffSpeechTTSLjspeechNoneExplicitShallow DiffusionHiFiGAN
    DiffSingerSVSPopCSGround-Truth F0NoneShallow DiffusionNSF-HiFiGAN
    DiffSingerSVSOpenCpopMIDIExplicitShallow DiffusionNSF-HiFiGAN
    FFT-SingerSVSOpenCpopMIDIExplicitInvalidNSF-HiFiGAN
    DiffSingerSVSOpenCpopMIDIImplicitNonePitch-Extractor + NSF-HiFiGAN
    DiffSinger+PNDMSVSOpenCpopMIDIImplicitPLMSPitch-Extractor + NSF-HiFiGAN
    DiffSpeech+PNDMTTSLjspeechNoneImplicitPLMSHiFiGAN
  2. Run DiffSinger on Opencpop (End-to-End/Joint Prediction)

    master

    Use this pipeline to avoid issues with explicit F0 prediction in the melody frontend (such as bad uv/v predictions). This method uses joint prediction with spectrograms.

    Pipeline Flow:

    1. Melody Frontend: [lyrics] + [MIDI] -> [linguistic representation] + [predicted phoneme duration]
    2. Acoustic Model: [linguistic representation (with MIDI information)] + [predicted phoneme duration] -> [mel-spectrogram]
    3. Pitch Extractor: [mel-spectrogram] -> [predicted F0]
    4. Vocoder: [mel-spectrogram] + [predicted F0] -> [waveform]

    For detailed instructions, refer to README-SVS-opencpop-e2e.md.

  3. Install DiffSinger using Python Virtual Environment

    master

    If you prefer using a standard Python virtual environment, ensure Python 3.8 is installed first. You must manually install pip, Cython, numpy, and torch before installing the project requirements.

    ## Install Python 3.8 first. 
    python -m venv venv
    source venv/bin/activate
    # install requirements.
    pip install -U pip
    pip install Cython numpy==1.19.1
    pip install torch==1.9.0
    pip install -r requirements.txt
  4. Prepare Opencpop dataset for DiffSinger-PNDM

    master

    To use the Opencpop dataset with the DiffSinger-PNDM pipeline, follow these steps:

    1. Acquire Data: Download and extract the Opencpop dataset following the official instructions.
    2. Link Dataset: Create a symbolic link from your Opencpop folder to the project's raw data directory: ln -s /path/to/opencpop data/raw/
    3. Binarize Data: Run the binarization script to generate the packed dataset (data/binary/opencpop-midi-dp) required for training and inference.

    Ensure PYTHONPATH is set to the project root.

    export PYTHONPATH=.
    CUDA_VISIBLE_DEVICES=0 python data_gen/tts/bin/binarize.py --config usr/configs/midi/cascade/opencs/aux_rel.yaml
  5. Train FFT-Singer and DiffSinger

    master

    Training follows a two-stage process: first training the FFT-Singer (the shallow diffusion mechanism component), then training DiffSinger.

    1. Train and Infer FFT-Singer

    You must first train FFT-Singer or use a pre-trained checkpoint. To train and then run inference on FFT-Singer:

    # Train fft-singer
    CUDA_VISIBLE_DEVICES=0 python tasks/run.py --config usr/configs/popcs_fs2.yaml --exp_name popcs_fs2_pmf0_1230 --reset
    
    # Infer fft-singer
    CUDA_VISIBLE_DEVICES=0 python tasks/run.py --config usr/configs/popcs_fs2.yaml --exp_name popcs_fs2_pmf0_1230 --reset --infer

    2. Train DiffSinger

    Once FFT-Singer is ready, train DiffSinger using the following command.

    Important: You must edit usr/configs/popcs_ds_beta6_offline.yaml and update the fs2_ckpt parameter to point to your FFT-Singer checkpoint path.

    CUDA_VISIBLE_DEVICES=0 python tasks/run.py --config usr/configs/popcs_ds_beta6_offline.yaml --exp_name popcs_ds_beta6_offline_pmf0_1230 --reset
  6. Apply for the PopCS dataset

    master

    To request access to the PopCS dataset, you must send an email to jinglinliu@zju.edu.cn using your Official Email Address (e.g., xxx@zju.edu.cn). Your email must include your name, affiliation, research fields, and a specific legal agreement statement.

    By using PopCS, you are automatically agreeing to the dataset license: CC by-nc-sa 4.0 (NonCommercial!) and accepting full responsibility for its use, including indemnifying the DiffSinger authors against claims arising from your use of the dataset or any copyrighted audio files created from it.

    name: ***
    
    affiliations: *** (school or institution)
    
    research fields: ***
    
    We want to apply for PopCS and agree to the dataset license: CC by-nc-sa 4.0 (NonCommercial!). 
    
    We accept full responsibility for our use of the dataset and shall defend and indemnify the authors of DiffSinger, against any and all claims arising from our use of the dataset, including but not limited to our use of any copies of copyrighted audio files that we may create from the dataset.
    
    We hereby represent that we are fully authorized to enter into this agreement on behalf of my employer.
    
    We will cite your paper if these codes or data have been used. We will not distribute the download link to others without informing the authors of DiffSinger.
  7. Install DiffSinger using Anaconda

    master

    To set up a DiffSinger environment using Anaconda, create a new environment with Python 3.8 and install the requirements specific to your GPU hardware.

    For NVIDIA 2080Ti (CUDA 10.2): Use requirements_2080.txt.

    For NVIDIA 3090 (CUDA 11.4): Use requirements_3090.txt.

  8. Train DiffSinger-PNDM model

    master

    Run the training task using tasks/run.py. You must provide a configuration file, an experiment name, and optionally use --reset to clear previous progress. Use CUDA_VISIBLE_DEVICES to specify the GPU.

    export MY_DS_EXP_NAME=0831_opencpop_ds1000
    CUDA_VISIBLE_DEVICES=0 python tasks/run.py --config usr/configs/midi/e2e/opencpop/ds1000.yaml --exp_name $MY_DS_EXP_NAME --reset