Run this model with HF Jobs
Run SnapOtter/deepsafe-services on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.
Paste one of these prompts into your coding agent:
Fine-tune on my dataset
Use HF Jobs to fine-tune https://huggingface.co/SnapOtter/deepsafe-services. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.
Run batch inference
Use HF Jobs to run batch inference with https://huggingface.co/SnapOtter/deepsafe-services on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.
Instructions to use SnapOtter/deepsafe-services with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Diffusers
How to use SnapOtter/deepsafe-services with Diffusers:
pip install -U diffusers transformers accelerate
import torch from diffusers import DiffusionPipeline # switch to "mps" for apple devices pipe = DiffusionPipeline.from_pretrained("SnapOtter/deepsafe-services", dtype=torch.bfloat16, device_map="cuda") prompt = "Astronaut in a jungle, cold color palette, muted colors, detailed, 8k" image = pipe(prompt).images[0] - Notebooks
- Google Colab
- Kaggle
DeepSafe commited on
chore: remove non-weight files (batch 5)
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
Files changed (50)
- audio/shiftyspeech/speech_synthesis/vocoders/ParallelWaveGAN/egs/template_single_spk/voc1/local/data_prep.shDeleted-87
- audio/shiftyspeech/speech_synthesis/vocoders/ParallelWaveGAN/egs/template_single_spk/voc1/path.shDeleted-33
- audio/shiftyspeech/speech_synthesis/vocoders/ParallelWaveGAN/egs/template_single_spk/voc1/run.shDeleted-188
- audio/shiftyspeech/speech_synthesis/vocoders/ParallelWaveGAN/egs/vctk/hubert_voc1/cmd.shDeleted-91
- audio/shiftyspeech/speech_synthesis/vocoders/ParallelWaveGAN/egs/vctk/hubert_voc1/conf/hifigan_hubert.v1.yamlDeleted-176
- audio/shiftyspeech/speech_synthesis/vocoders/ParallelWaveGAN/egs/vctk/hubert_voc1/conf/hifigan_hubert_24k.v1.yamlDeleted-176
- audio/shiftyspeech/speech_synthesis/vocoders/ParallelWaveGAN/egs/vctk/hubert_voc1/conf/slurm.confDeleted-12
- audio/shiftyspeech/speech_synthesis/vocoders/ParallelWaveGAN/egs/vctk/hubert_voc1/conf/style_melgan_hubert.v1.yamlDeleted-145
- audio/shiftyspeech/speech_synthesis/vocoders/ParallelWaveGAN/egs/vctk/hubert_voc1/path.shDeleted-33
- audio/shiftyspeech/speech_synthesis/vocoders/ParallelWaveGAN/egs/vctk/hubert_voc1/run.shDeleted-151
- audio/shiftyspeech/speech_synthesis/vocoders/ParallelWaveGAN/egs/vctk/voc1/cmd.shDeleted-91
- audio/shiftyspeech/speech_synthesis/vocoders/ParallelWaveGAN/egs/vctk/voc1/conf/hifigan.v1.yamlDeleted-180
- audio/shiftyspeech/speech_synthesis/vocoders/ParallelWaveGAN/egs/vctk/voc1/conf/multi_band_melgan.v2.yamlDeleted-154
- audio/shiftyspeech/speech_synthesis/vocoders/ParallelWaveGAN/egs/vctk/voc1/conf/parallel_wavegan.v1.long.yamlDeleted-122
- audio/shiftyspeech/speech_synthesis/vocoders/ParallelWaveGAN/egs/vctk/voc1/conf/parallel_wavegan.v1.yamlDeleted-122
- audio/shiftyspeech/speech_synthesis/vocoders/ParallelWaveGAN/egs/vctk/voc1/conf/slurm.confDeleted-12
- audio/shiftyspeech/speech_synthesis/vocoders/ParallelWaveGAN/egs/vctk/voc1/conf/style_melgan.v1.yamlDeleted-147
- audio/shiftyspeech/speech_synthesis/vocoders/ParallelWaveGAN/egs/vctk/voc1/local/data_download.shDeleted-37
- audio/shiftyspeech/speech_synthesis/vocoders/ParallelWaveGAN/egs/vctk/voc1/local/data_prep.shDeleted-118
- audio/shiftyspeech/speech_synthesis/vocoders/ParallelWaveGAN/egs/vctk/voc1/local/decode_from_text.pyDeleted-174
- audio/shiftyspeech/speech_synthesis/vocoders/ParallelWaveGAN/egs/vctk/voc1/local/preprocess_hubert.pyDeleted-249
- audio/shiftyspeech/speech_synthesis/vocoders/ParallelWaveGAN/egs/vctk/voc1/path.shDeleted-33
- audio/shiftyspeech/speech_synthesis/vocoders/ParallelWaveGAN/egs/vctk/voc1/run.shDeleted-188
- audio/shiftyspeech/speech_synthesis/vocoders/ParallelWaveGAN/egs/vctk/vq1/cmd.shDeleted-91
- audio/shiftyspeech/speech_synthesis/vocoders/ParallelWaveGAN/egs/vctk/vq1/conf/conditioned_melgan_vae.v3.yamlDeleted-130
- audio/shiftyspeech/speech_synthesis/vocoders/ParallelWaveGAN/egs/vctk/vq1/conf/local_conditioned_melgan_vae.v3.yamlDeleted-134
- audio/shiftyspeech/speech_synthesis/vocoders/ParallelWaveGAN/egs/vctk/vq1/conf/slurm.confDeleted-12
- audio/shiftyspeech/speech_synthesis/vocoders/ParallelWaveGAN/egs/vctk/vq1/local/data_download.shDeleted-37
- audio/shiftyspeech/speech_synthesis/vocoders/ParallelWaveGAN/egs/vctk/vq1/local/data_prep.shDeleted-121
- audio/shiftyspeech/speech_synthesis/vocoders/ParallelWaveGAN/egs/vctk/vq1/local/data_prep_2mix.shDeleted-54
- audio/shiftyspeech/speech_synthesis/vocoders/ParallelWaveGAN/egs/vctk/vq1/local/decode_from_text.pyDeleted-174
- audio/shiftyspeech/speech_synthesis/vocoders/ParallelWaveGAN/egs/vctk/vq1/local/setup_for_vc.pyDeleted-222
- audio/shiftyspeech/speech_synthesis/vocoders/ParallelWaveGAN/egs/vctk/vq1/path.shDeleted-33
- audio/shiftyspeech/speech_synthesis/vocoders/ParallelWaveGAN/egs/vctk/vq1/run.shDeleted-295
- audio/shiftyspeech/speech_synthesis/vocoders/ParallelWaveGAN/egs/yesno/voc1/cmd.shDeleted-91
- audio/shiftyspeech/speech_synthesis/vocoders/ParallelWaveGAN/egs/yesno/voc1/conf/hifigan.v1.debug.yamlDeleted-152
- audio/shiftyspeech/speech_synthesis/vocoders/ParallelWaveGAN/egs/yesno/voc1/conf/melgan.v1.debug.yamlDeleted-112
- audio/shiftyspeech/speech_synthesis/vocoders/ParallelWaveGAN/egs/yesno/voc1/conf/melgan.v3.debug.yamlDeleted-121
- audio/shiftyspeech/speech_synthesis/vocoders/ParallelWaveGAN/egs/yesno/voc1/conf/multi_band_melgan.v1.debug.yamlDeleted-126
- audio/shiftyspeech/speech_synthesis/vocoders/ParallelWaveGAN/egs/yesno/voc1/conf/parallel_wavegan.v1.debug.diff_fs.yamlDeleted-121
- audio/shiftyspeech/speech_synthesis/vocoders/ParallelWaveGAN/egs/yesno/voc1/conf/parallel_wavegan.v1.debug.npy.yamlDeleted-121
- audio/shiftyspeech/speech_synthesis/vocoders/ParallelWaveGAN/egs/yesno/voc1/conf/parallel_wavegan.v1.debug.yamlDeleted-120
- audio/shiftyspeech/speech_synthesis/vocoders/ParallelWaveGAN/egs/yesno/voc1/conf/slurm.confDeleted-12
- audio/shiftyspeech/speech_synthesis/vocoders/ParallelWaveGAN/egs/yesno/voc1/conf/style_melgan.v1.debug.yamlDeleted-135
- audio/shiftyspeech/speech_synthesis/vocoders/ParallelWaveGAN/egs/yesno/voc1/conf/uhifigan.v1.debug.yamlDeleted-155
- audio/shiftyspeech/speech_synthesis/vocoders/ParallelWaveGAN/egs/yesno/voc1/local/data_download.shDeleted-28
- audio/shiftyspeech/speech_synthesis/vocoders/ParallelWaveGAN/egs/yesno/voc1/local/data_prep.shDeleted-88
- audio/shiftyspeech/speech_synthesis/vocoders/ParallelWaveGAN/egs/yesno/voc1/path.shDeleted-33
- audio/shiftyspeech/speech_synthesis/vocoders/ParallelWaveGAN/egs/yesno/voc1/run.shDeleted-178
- audio/shiftyspeech/speech_synthesis/vocoders/ParallelWaveGAN/egs/yesno/vq1/cmd.shDeleted-91
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687#!/bin/bash
# Copyright 2020 Tomoki Hayashi# MIT License (https://opensource.org/licenses/MIT)
# shellcheck disable=SC1091. ./path.sh || exit 1;
fs=22050num_dev=100num_eval=100train_set="train_nodev"dev_set="dev"eval_set="eval"shuffle=false
# shellcheck disable=SC1091. utils/parse_options.sh || exit 1;
db_root=$1data_dir=$2
# check argumentsif [ $# != 2 ]; then echo "Usage: $0 [Options] <db_root> <data_dir>" echo "" echo "Options:" echo " --num_dev: number of development uttreances (default=250)." echo " --num_eval: number of evaluation uttreances (default=250)." echo " --train_set: name of train set (default=train_nodev)." echo " --dev_set: name of dev set (default=dev)." echo " --eval_set: name of eval set (default=eval)." echo " --shuffle: whether to perform shuffle in making dev / eval set (default=false)." exit 1fi
set -euo pipefail
[ ! -e "${data_dir}/all" ] && mkdir -p "${data_dir}/all"
# set filenamesscp="${data_dir}/all/wav.scp"
# check file existence[ -e "${scp}" ] && rm "${scp}"
# make all scpfind "${db_root}" -follow -name "*.wav" | sort | while read -r filename; do id=$(basename "${filename}" | sed -e "s/\.[^\.]*$//g") echo "${id} cat ${filename} | sox -t wav - -c 1 -b 16 -t wav - rate ${fs} |" >> "${scp}"done
# splitnum_all=$(wc -l < "${scp}")num_deveval=$((num_dev + num_eval))num_train=$((num_all - num_deveval))if [ ${num_eval} -ne 0 ]; then utils/split_data.sh \ --num_first "${num_train}" \ --num_second "${num_deveval}" \ --shuffle "${shuffle}" \ "${data_dir}/all" \ "${data_dir}/${train_set}" \ "${data_dir}/deveval" utils/split_data.sh \ --num_first "${num_dev}" \ --num_second "${num_eval}" \ --shuffle "${shuffle}" \ "${data_dir}/deveval" \ "${data_dir}/${dev_set}" \ "${data_dir}/${eval_set}"else utils/split_data.sh \ --num_first "${num_train}" \ --num_second "${num_deveval}" \ --shuffle "${shuffle}" \ "${data_dir}/all" \ "${data_dir}/${train_set}" \ "${data_dir}/${dev_set}" cp -r "${data_dir}/${dev_set}" "${data_dir}/${eval_set}"fi
# remove tmp directoriesrm -rf "${data_dir}/all"rm -rf "${data_dir}/deveval"
echo "Successfully prepared data."123456789101112131415161718192021222324252627282930313233# cuda relatedexport CUDA_HOME=/usr/local/cuda-11.3export LD_LIBRARY_PATH="${CUDA_HOME}/lib64:${LD_LIBRARY_PATH}"
# path relatedexport PRJ_ROOT="${PWD}/../../.."if [ -e "${PRJ_ROOT}/tools/venv/bin/activate" ]; then # shellcheck disable=SC1090 . "${PRJ_ROOT}/tools/venv/bin/activate"fi
# python relatedexport OMP_NUM_THREADS=1export PYTHONIOENCODING=UTF-8export MPL_BACKEND=Agg
# check installationif ! command -v parallel-wavegan-train > /dev/null; then echo "Error: It seems setup is not finished." >&2 echo "Error: Please setup your environment by following README.md" >&2 return 1fiif ! command -v jq > /dev/null; then echo "Error: It seems jq is not installed." >&2 echo "Error: Please install via \`sudo apt-get install jq\`." >&2 echo "Error: If you do not have sudo, please download from https://stedolan.github.io/jq/download/." >&2 return 1fiif ! command -v yq > /dev/null; then echo "Error: It seems yq is not installed." >&2 echo "Error: Please install via \`pip install yq\`." >&2 return 1fi123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188#!/bin/bash
# Copyright 2020 Tomoki Hayashi# MIT License (https://opensource.org/licenses/MIT)
. ./cmd.sh || exit 1;. ./path.sh || exit 1;
# basic settingsstage=0 # stage to startstop_stage=100 # stage to stopverbose=1 # verbosity level (lower is less info)n_gpus=1 # number of gpus in trainingn_jobs=4 # number of parallel jobs in feature extraction
# NOTE(kan-bayashi): renamed to conf to avoid conflict in parse_options.shconf=conf/parallel_wavegan.v1.yaml
# directory path settingdb_root=/path/to/database # direcotry including wavfiles (MODIFY BY YOURSELF) # each wav filename in the directory should be unique # e.g. # /path/to/database # ├── utt_1.wav # ├── utt_2.wav # │ ... # └── utt_N.wavdumpdir=dump # directory to dump features
# subset settingshuffle=false # whether to shuffle the data to create subsetnum_dev=100 # the number of development datanum_eval=100 # the number of evaluation data # (if set to 0, the same dev set is used as eval set)
# training related settingtag="" # tag for directory to save modelresume="" # checkpoint path to resume training # (e.g. <path>/<to>/checkpoint-10000steps.pkl)pretrain="" # checkpoint path to load pretrained parameters # (e.g. ../../jsut/<path>/<to>/checkpoint-400000steps.pkl)
# decoding related settingcheckpoint="" # checkpoint path to be used for decoding # if not provided, the latest one will be used # (e.g. <path>/<to>/checkpoint-400000steps.pkl)
# shellcheck disable=SC1091. utils/parse_options.sh || exit 1;
train_set="train_nodev" # name of training data directorydev_set="dev" # name of development data direcotryeval_set="eval" # name of evaluation data direcotry
set -euo pipefail
if [ "${stage}" -le 0 ] && [ "${stop_stage}" -ge 0 ]; then echo "Stage 0: Data preparation" local/data_prep.sh \ --fs "$(yq ".sampling_rate" "${conf}")" \ --num_dev "${num_dev}" \ --num_eval "${num_eval}" \ --train_set "${train_set}" \ --dev_set "${dev_set}" \ --eval_set "${eval_set}" \ --shuffle "${shuffle}" \ "${db_root}" datafi
stats_ext=$(grep -q "hdf5" <(yq ".format" "${conf}") && echo "h5" || echo "npy")if [ "${stage}" -le 1 ] && [ "${stop_stage}" -ge 1 ]; then echo "Stage 1: Feature extraction" # extract raw features pids=() for name in "${train_set}" "${dev_set}" "${eval_set}"; do ( [ ! -e "${dumpdir}/${name}/raw" ] && mkdir -p "${dumpdir}/${name}/raw" echo "Feature extraction start. See the progress via ${dumpdir}/${name}/raw/preprocessing.*.log." utils/make_subset_data.sh "data/${name}" "${n_jobs}" "${dumpdir}/${name}/raw" ${train_cmd} JOB=1:${n_jobs} "${dumpdir}/${name}/raw/preprocessing.JOB.log" \ parallel-wavegan-preprocess \ --config "${conf}" \ --scp "${dumpdir}/${name}/raw/wav.JOB.scp" \ --dumpdir "${dumpdir}/${name}/raw/dump.JOB" \ --verbose "${verbose}" echo "Successfully finished feature extraction of ${name} set." ) & pids+=($!) done i=0; for pid in "${pids[@]}"; do wait "${pid}" || ((++i)); done [ "${i}" -gt 0 ] && echo "$0: ${i} background jobs are failed." && exit 1; echo "Successfully finished feature extraction."
# calculate statistics for normalization if [ -z "${pretrain}" ]; then # calculate statistics for normalization echo "Statistics computation start. See the progress via ${dumpdir}/${train_set}/compute_statistics.log." ${train_cmd} "${dumpdir}/${train_set}/compute_statistics.log" \ parallel-wavegan-compute-statistics \ --config "${conf}" \ --rootdir "${dumpdir}/${train_set}/raw" \ --dumpdir "${dumpdir}/${train_set}" \ --verbose "${verbose}" echo "Successfully finished calculation of statistics." else echo "Use statistics of pretrained model. Skip statistics computation." cp "$(dirname "${pretrain}")/stats.${stats_ext}" "${dumpdir}/${train_set}" fi
# normalize and dump them pids=() for name in "${train_set}" "${dev_set}" "${eval_set}"; do ( [ ! -e "${dumpdir}/${name}/norm" ] && mkdir -p "${dumpdir}/${name}/norm" echo "Nomalization start. See the progress via ${dumpdir}/${name}/norm/normalize.*.log." ${train_cmd} JOB=1:${n_jobs} "${dumpdir}/${name}/norm/normalize.JOB.log" \ parallel-wavegan-normalize \ --config "${conf}" \ --stats "${dumpdir}/${train_set}/stats.${stats_ext}" \ --rootdir "${dumpdir}/${name}/raw/dump.JOB" \ --dumpdir "${dumpdir}/${name}/norm/dump.JOB" \ --verbose "${verbose}" echo "Successfully finished normalization of ${name} set." ) & pids+=($!) done i=0; for pid in "${pids[@]}"; do wait "${pid}" || ((++i)); done [ "${i}" -gt 0 ] && echo "$0: ${i} background jobs are failed." && exit 1; echo "Successfully finished normalization."fi
if [ -z "${tag}" ]; then expdir="exp/${train_set}_$(basename "${conf}" .yaml)" if [ -n "${pretrain}" ]; then pretrain_tag=$(basename "$(dirname "${pretrain}")") expdir+="_${pretrain_tag}" fielse expdir="exp/${train_set}_${tag}"fiif [ "${stage}" -le 2 ] && [ "${stop_stage}" -ge 2 ]; then echo "Stage 2: Network training" [ ! -e "${expdir}" ] && mkdir -p "${expdir}" cp "${dumpdir}/${train_set}/stats.${stats_ext}" "${expdir}" if [ "${n_gpus}" -gt 1 ]; then train="python -m parallel_wavegan.distributed.launch --nproc_per_node ${n_gpus} -c parallel-wavegan-train" else train="parallel-wavegan-train" fi echo "Training start. See the progress via ${expdir}/train.log." ${cuda_cmd} --gpu "${n_gpus}" "${expdir}/train.log" \ ${train} \ --config "${conf}" \ --train-dumpdir "${dumpdir}/${train_set}/norm" \ --dev-dumpdir "${dumpdir}/${dev_set}/norm" \ --outdir "${expdir}" \ --resume "${resume}" \ --pretrain "${pretrain}" \ --verbose "${verbose}" echo "Successfully finished training."fi
if [ "${stage}" -le 3 ] && [ "${stop_stage}" -ge 3 ]; then echo "Stage 3: Network decoding" # shellcheck disable=SC2012 [ -z "${checkpoint}" ] && checkpoint="$(ls -dt "${expdir}"/*.pkl | head -1 || true)" outdir="${expdir}/wav/$(basename "${checkpoint}" .pkl)" pids=() for name in "${dev_set}" "${eval_set}"; do ( [ ! -e "${outdir}/${name}" ] && mkdir -p "${outdir}/${name}" [ "${n_gpus}" -gt 1 ] && n_gpus=1 echo "Decoding start. See the progress via ${outdir}/${name}/decode.log." ${cuda_cmd} --gpu "${n_gpus}" "${outdir}/${name}/decode.log" \ parallel-wavegan-decode \ --dumpdir "${dumpdir}/${name}/norm" \ --checkpoint "${checkpoint}" \ --outdir "${outdir}/${name}" \ --verbose "${verbose}" echo "Successfully finished decoding of ${name} set." ) & pids+=($!) done i=0; for pid in "${pids[@]}"; do wait "${pid}" || ((++i)); done [ "${i}" -gt 0 ] && echo "$0: ${i} background jobs are failed." && exit 1; echo "Successfully finished decoding."fiecho "Finished."12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091# ====== About run.pl, queue.pl, slurm.pl, and ssh.pl ======# Usage: <cmd>.pl [options] JOB=1:<nj> <log> <command...># e.g.# run.pl --mem 4G JOB=1:10 echo.JOB.log echo JOB## Options:# --time <time>: Limit the maximum time to execute.# --mem <mem>: Limit the maximum memory usage.# -–max-jobs-run <njob>: Limit the number parallel jobs. This is ignored for non-array jobs.# --num-threads <ngpu>: Specify the number of CPU core.# --gpu <ngpu>: Specify the number of GPU devices.# --config: Change the configuration file from default.## "JOB=1:10" is used for "array jobs" and it can control the number of parallel jobs.# The left string of "=", i.e. "JOB", is replaced by <N>(Nth job) in the command and the log file name,# e.g. "echo JOB" is changed to "echo 3" for the 3rd job and "echo 8" for 8th job respectively.# Note that the number must start with a positive number, so you can't use "JOB=0:10" for example.## run.pl, queue.pl, slurm.pl, and ssh.pl have unified interface, not depending on its backend.# These options are mapping to specific options for each backend and# it is configured by "conf/queue.conf" and "conf/slurm.conf" by default.# If jobs failed, your configuration might be wrong for your environment.### The official documentaion for run.pl, queue.pl, slurm.pl, and ssh.pl:# "Parallelization in Kaldi": http://kaldi-asr.org/doc/queue.html# =========================================================~
# Select the backend used by run.sh from "local", "stdout", "sge", "slurm", or "ssh"cmd_backend="local"
# Local machine, without any Job scheduling systemif [ "${cmd_backend}" = local ]; then
# The other usage export train_cmd="utils/run.pl" # Used for "*_train.py": "--gpu" is appended optionally by run.sh export cuda_cmd="utils/run.pl" # Used for "*_recog.py" export decode_cmd="utils/run.pl"
# Local machine, without any Job scheduling systemelif [ "${cmd_backend}" = stdout ]; then
# The other usage export train_cmd="utils/stdout.pl" # Used for "*_train.py": "--gpu" is appended optionally by run.sh export cuda_cmd="utils/stdout.pl" # Used for "*_recog.py" export decode_cmd="utils/stdout.pl"
# "qsub" (SGE, Torque, PBS, etc.)elif [ "${cmd_backend}" = sge ]; then # The default setting is written in conf/queue.conf. # You must change "-q g.q" for the "queue" for your environment. # To know the "queue" names, type "qhost -q" # Note that to use "--gpu *", you have to setup "complex_value" for the system scheduler.
export train_cmd="utils/queue.pl" export cuda_cmd="utils/queue.pl" export decode_cmd="utils/queue.pl"
# "sbatch" (Slurm)elif [ "${cmd_backend}" = slurm ]; then # The default setting is written in conf/slurm.conf. # You must change "-p cpu" and "-p gpu" for the "partion" for your environment. # To know the "partion" names, type "sinfo". # You can use "--gpu * " by defualt for slurm and it is interpreted as "--gres gpu:*" # The devices are allocated exclusively using "${CUDA_VISIBLE_DEVICES}".
export train_cmd="utils/slurm.pl" export cuda_cmd="utils/slurm.pl" export decode_cmd="utils/slurm.pl"
elif [ "${cmd_backend}" = ssh ]; then # You have to create ".queue/machines" to specify the host to execute jobs. # e.g. .queue/machines # host1 # host2 # host3 # Assuming you can login them without any password, i.e. You have to set ssh keys.
export train_cmd="utils/ssh.pl" export cuda_cmd="utils/ssh.pl" export decode_cmd="utils/ssh.pl"
else echo "$0: Error: Unknown cmd_backend=${cmd_backend}" 1>&2 return 1fi123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176# This configuration is based on HiFiGAN V1, derived# from official repository (https://github.com/jik876/hifi-gan).
############################################################ FEATURE EXTRACTION SETTING ############################################################sampling_rate: 16000 # Sampling rate.fft_size: null # FFT size.hop_size: 320 # Hop size.win_length: null # Window length. # If set to null, it will be the same as fft_size.window: null # Window function.num_mels: 2 # Number of mel basis.fmin: null # Minimum freq in mel basis calculation.fmax: null # Maximum frequency in mel basis calculation.global_gain_scale: 1.0 # Will be multiplied to all of waveform.trim_silence: false # Whether to trim the start and end of silence.trim_threshold_in_db: 20 # Need to tune carefully if the recording is not good.trim_frame_size: 1024 # Frame size in trimming.trim_hop_size: 256 # Hop size in trimming.format: "hdf5" # Feature file format. "npy" or "hdf5" is supported.
############################################################ GENERATOR NETWORK ARCHITECTURE SETTING ############################################################generator_type: DiscreteSymbolHiFiGANGeneratorgenerator_params: in_channels: 512 # Number of input channels. out_channels: 1 # Number of output channels. channels: 512 # Number of initial channels. num_embs: 100 num_spk_embs: 128 spk_emb_dim: 512 concat_spk_emb: false kernel_size: 7 # Kernel size of initial and final conv layers. upsample_scales: [10, 8, 2, 2] # Upsampling scales. upsample_kernel_sizes: [20, 16, 4, 4] # Kernel size for upsampling layers. resblock_kernel_sizes: [3, 7, 11] # Kernel size for residual blocks. resblock_dilations: # Dilations for residual blocks. - [1, 3, 5] - [1, 3, 5] - [1, 3, 5] use_additional_convs: true # Whether to use additional conv layer in residual blocks. bias: true # Whether to use bias parameter in conv. nonlinear_activation: "LeakyReLU" # Nonlinear activation type. nonlinear_activation_params: # Nonlinear activation paramters. negative_slope: 0.1 use_weight_norm: true # Whether to apply weight normalization.
############################################################ DISCRIMINATOR NETWORK ARCHITECTURE SETTING ############################################################discriminator_type: HiFiGANMultiScaleMultiPeriodDiscriminatordiscriminator_params: scales: 3 # Number of multi-scale discriminator. scale_downsample_pooling: "AvgPool1d" # Pooling operation for scale discriminator. scale_downsample_pooling_params: kernel_size: 4 # Pooling kernel size. stride: 2 # Pooling stride. padding: 2 # Padding size. scale_discriminator_params: in_channels: 1 # Number of input channels. out_channels: 1 # Number of output channels. kernel_sizes: [15, 41, 5, 3] # List of kernel sizes. channels: 128 # Initial number of channels. max_downsample_channels: 1024 # Maximum number of channels in downsampling conv layers. max_groups: 16 # Maximum number of groups in downsampling conv layers. bias: true downsample_scales: [4, 4, 4, 4, 1] # Downsampling scales. nonlinear_activation: "LeakyReLU" # Nonlinear activation. nonlinear_activation_params: negative_slope: 0.1 follow_official_norm: true # Whether to follow the official norm setting. periods: [2, 3, 5, 7, 11] # List of period for multi-period discriminator. period_discriminator_params: in_channels: 1 # Number of input channels. out_channels: 1 # Number of output channels. kernel_sizes: [5, 3] # List of kernel sizes. channels: 32 # Initial number of channels. downsample_scales: [3, 3, 3, 3, 1] # Downsampling scales. max_downsample_channels: 1024 # Maximum number of channels in downsampling conv layers. bias: true # Whether to use bias parameter in conv layer." nonlinear_activation: "LeakyReLU" # Nonlinear activation. nonlinear_activation_params: # Nonlinear activation paramters. negative_slope: 0.1 use_weight_norm: true # Whether to apply weight normalization. use_spectral_norm: false # Whether to apply spectral normalization.
############################################################ STFT LOSS SETTING ############################################################use_stft_loss: false # Whether to use multi-resolution STFT loss.use_mel_loss: true # Whether to use Mel-spectrogram loss.mel_loss_params: # Mel-spectrogram loss parameters. fs: 16000 fft_size: 1024 hop_size: 256 win_length: null window: "hann" num_mels: 80 fmin: 0 fmax: 8000 log_base: null # Log base. If set to null, use natural logarithm.generator_adv_loss_params: average_by_discriminators: false # Whether to average loss by #discriminators.discriminator_adv_loss_params: average_by_discriminators: false # Whether to average loss by #discriminators.use_feat_match_loss: truefeat_match_loss_params: average_by_discriminators: false # Whether to average loss by #discriminators. average_by_layers: false # Whether to average loss by #layers in each discriminator. include_final_outputs: true # Whether to include final outputs in feat match loss calculation.
############################################################ ADVERSARIAL LOSS SETTING ############################################################lambda_aux: 45.0 # Loss balancing coefficient for STFT loss.lambda_adv: 1.0 # Loss balancing coefficient for adversarial loss.lambda_feat_match: 2.0 # Loss balancing coefficient for feat match loss..
############################################################ DATA LOADER SETTING ############################################################batch_size: 16 # Batch size.batch_max_steps: 10240 # Length of each audio in batch. Make sure dividable by hop_size.pin_memory: true # Whether to pin memory in Pytorch DataLoader.num_workers: 2 # Number of workers in Pytorch DataLoader.remove_short_samples: false # Whether to remove samples the length of which are less than batch_max_steps.allow_cache: true # Whether to allow cache in dataset. If true, it requires cpu memory.
############################################################ OPTIMIZER & SCHEDULER SETTING ############################################################generator_optimizer_type: Adamgenerator_optimizer_params: lr: 2.0e-4 betas: [0.5, 0.9] weight_decay: 0.0generator_scheduler_type: MultiStepLRgenerator_scheduler_params: gamma: 0.5 milestones: - 200000 - 400000 - 600000 - 800000generator_grad_norm: -1discriminator_optimizer_type: Adamdiscriminator_optimizer_params: lr: 2.0e-4 betas: [0.5, 0.9] weight_decay: 0.0discriminator_scheduler_type: MultiStepLRdiscriminator_scheduler_params: gamma: 0.5 milestones: - 200000 - 400000 - 600000 - 800000discriminator_grad_norm: -1
############################################################ INTERVAL SETTING ############################################################generator_train_start_steps: 1 # Number of steps to start to train discriminator.discriminator_train_start_steps: 0 # Number of steps to start to train discriminator.train_max_steps: 2500000 # Number of training steps.save_interval_steps: 50000 # Interval steps to save checkpoint.eval_interval_steps: 1000 # Interval steps to evaluate the network.log_interval_steps: 100 # Interval steps to record the training log.
############################################################ OTHER SETTING ############################################################num_save_intermediate_results: 4 # Number of results to be saved as intermediate results.123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176# This configuration is based on HiFiGAN V1, derived# from official repository (https://github.com/jik876/hifi-gan).
############################################################ FEATURE EXTRACTION SETTING ############################################################sampling_rate: 24000 # Sampling rate.fft_size: null # FFT size.hop_size: 480 # Hop size.win_length: null # Window length. # If set to null, it will be the same as fft_size.window: null # Window function.num_mels: 2 # Number of mel basis.fmin: null # Minimum freq in mel basis calculation.fmax: null # Maximum frequency in mel basis calculation.global_gain_scale: 1.0 # Will be multiplied to all of waveform.trim_silence: false # Whether to trim the start and end of silence.trim_threshold_in_db: 20 # Need to tune carefully if the recording is not good.trim_frame_size: 1024 # Frame size in trimming.trim_hop_size: 256 # Hop size in trimming.format: "hdf5" # Feature file format. "npy" or "hdf5" is supported.
############################################################ GENERATOR NETWORK ARCHITECTURE SETTING ############################################################generator_type: DiscreteSymbolHiFiGANGeneratorgenerator_params: in_channels: 512 # Number of input channels. out_channels: 1 # Number of output channels. channels: 512 # Number of initial channels. num_embs: 100 num_spk_embs: 128 spk_emb_dim: 512 concat_spk_emb: false kernel_size: 7 # Kernel size of initial and final conv layers. upsample_scales: [12, 10, 2, 2] # Upsampling scales. upsample_kernel_sizes: [24, 20, 4, 4] # Kernel size for upsampling layers. resblock_kernel_sizes: [3, 7, 11] # Kernel size for residual blocks. resblock_dilations: # Dilations for residual blocks. - [1, 3, 5] - [1, 3, 5] - [1, 3, 5] use_additional_convs: true # Whether to use additional conv layer in residual blocks. bias: true # Whether to use bias parameter in conv. nonlinear_activation: "LeakyReLU" # Nonlinear activation type. nonlinear_activation_params: # Nonlinear activation paramters. negative_slope: 0.1 use_weight_norm: true # Whether to apply weight normalization.
############################################################ DISCRIMINATOR NETWORK ARCHITECTURE SETTING ############################################################discriminator_type: HiFiGANMultiScaleMultiPeriodDiscriminatordiscriminator_params: scales: 3 # Number of multi-scale discriminator. scale_downsample_pooling: "AvgPool1d" # Pooling operation for scale discriminator. scale_downsample_pooling_params: kernel_size: 4 # Pooling kernel size. stride: 2 # Pooling stride. padding: 2 # Padding size. scale_discriminator_params: in_channels: 1 # Number of input channels. out_channels: 1 # Number of output channels. kernel_sizes: [15, 41, 5, 3] # List of kernel sizes. channels: 128 # Initial number of channels. max_downsample_channels: 1024 # Maximum number of channels in downsampling conv layers. max_groups: 16 # Maximum number of groups in downsampling conv layers. bias: true downsample_scales: [4, 4, 4, 4, 1] # Downsampling scales. nonlinear_activation: "LeakyReLU" # Nonlinear activation. nonlinear_activation_params: negative_slope: 0.1 follow_official_norm: true # Whether to follow the official norm setting. periods: [2, 3, 5, 7, 11] # List of period for multi-period discriminator. period_discriminator_params: in_channels: 1 # Number of input channels. out_channels: 1 # Number of output channels. kernel_sizes: [5, 3] # List of kernel sizes. channels: 32 # Initial number of channels. downsample_scales: [3, 3, 3, 3, 1] # Downsampling scales. max_downsample_channels: 1024 # Maximum number of channels in downsampling conv layers. bias: true # Whether to use bias parameter in conv layer." nonlinear_activation: "LeakyReLU" # Nonlinear activation. nonlinear_activation_params: # Nonlinear activation paramters. negative_slope: 0.1 use_weight_norm: true # Whether to apply weight normalization. use_spectral_norm: false # Whether to apply spectral normalization.
############################################################ STFT LOSS SETTING ############################################################use_stft_loss: false # Whether to use multi-resolution STFT loss.use_mel_loss: true # Whether to use Mel-spectrogram loss.mel_loss_params: # Mel-spectrogram loss parameters. fs: 24000 fft_size: 2048 hop_size: 300 win_length: 1200 window: "hann" num_mels: 80 fmin: 80 fmax: 7600 log_base: null # Log base. If set to null, use natural logarithm.generator_adv_loss_params: average_by_discriminators: false # Whether to average loss by #discriminators.discriminator_adv_loss_params: average_by_discriminators: false # Whether to average loss by #discriminators.use_feat_match_loss: truefeat_match_loss_params: average_by_discriminators: false # Whether to average loss by #discriminators. average_by_layers: false # Whether to average loss by #layers in each discriminator. include_final_outputs: true # Whether to include final outputs in feat match loss calculation.
############################################################ ADVERSARIAL LOSS SETTING ############################################################lambda_aux: 45.0 # Loss balancing coefficient for STFT loss.lambda_adv: 1.0 # Loss balancing coefficient for adversarial loss.lambda_feat_match: 2.0 # Loss balancing coefficient for feat match loss..
############################################################ DATA LOADER SETTING ############################################################batch_size: 16 # Batch size.batch_max_steps: 12000 # Length of each audio in batch. Make sure dividable by hop_size.pin_memory: true # Whether to pin memory in Pytorch DataLoader.num_workers: 2 # Number of workers in Pytorch DataLoader.remove_short_samples: false # Whether to remove samples the length of which are less than batch_max_steps.allow_cache: true # Whether to allow cache in dataset. If true, it requires cpu memory.
############################################################ OPTIMIZER & SCHEDULER SETTING ############################################################generator_optimizer_type: Adamgenerator_optimizer_params: lr: 2.0e-4 betas: [0.5, 0.9] weight_decay: 0.0generator_scheduler_type: MultiStepLRgenerator_scheduler_params: gamma: 0.5 milestones: - 200000 - 400000 - 600000 - 800000generator_grad_norm: -1discriminator_optimizer_type: Adamdiscriminator_optimizer_params: lr: 2.0e-4 betas: [0.5, 0.9] weight_decay: 0.0discriminator_scheduler_type: MultiStepLRdiscriminator_scheduler_params: gamma: 0.5 milestones: - 200000 - 400000 - 600000 - 800000discriminator_grad_norm: -1
############################################################ INTERVAL SETTING ############################################################generator_train_start_steps: 1 # Number of steps to start to train discriminator.discriminator_train_start_steps: 0 # Number of steps to start to train discriminator.train_max_steps: 2500000 # Number of training steps.save_interval_steps: 20000 # Interval steps to save checkpoint.eval_interval_steps: 1000 # Interval steps to evaluate the network.log_interval_steps: 100 # Interval steps to record the training log.
############################################################ OTHER SETTING ############################################################num_save_intermediate_results: 4 # Number of results to be saved as intermediate results.123456789101112# Default configurationcommand sbatch --export=PATH --ntasks-per-node=1option time=* --time $0option mem=* --mem-per-cpu $0option mem=0 # Do not add anything to qsub_optsoption num_threads=* --cpus-per-task $0 --ntasks-per-node=1option num_threads=1 --cpus-per-task 1 --ntasks-per-node=1 # Do not add anything to qsub_optsdefault gpu=0option gpu=0 -p cpuoption gpu=* -p gpu --gres=gpu:$0# note: the --max-jobs-run option is supported as a special case# by slurm.pl and you don't have to handle it in the config file.123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145# This configuration is based on StyleMelGAN paper.
############################################################ FEATURE EXTRACTION SETTING ############################################################sampling_rate: 16000 # Sampling rate.fft_size: null # FFT size.hop_size: 320 # Hop size.win_length: null # Window length. # If set to null, it will be the same as fft_size.window: null # Window function.num_mels: 1 # Number of mel basis.fmin: null # Minimum freq in mel basis calculation.fmax: null # Maximum frequency in mel basis calculation.global_gain_scale: 1.0 # Will be multiplied to all of waveform.trim_silence: false # Whether to trim the start and end of silence.trim_threshold_in_db: 60 # Need to tune carefully if the recording is not good.trim_frame_size: 1024 # Frame size in trimming.trim_hop_size: 256 # Hop size in trimming.format: "hdf5" # Feature file format. " npy " or " hdf5 " is supported.
############################################################ GENERATOR NETWORK ARCHITECTURE SETTING ############################################################generator_type: "DiscreteSymbolStyleMelGANGenerator" # Generator type.generator_params: in_channels: 128 aux_channels: 128 channels: 64 out_channels: 1 num_embs: 100 num_spk_embs: 128 spk_emb_dim: 128 concat_spk_emb: false kernel_size: 9 dilation: 2 bias: True noise_upsample_scales: [7, 2, 2, 2] noise_upsample_activation: "LeakyReLU" noise_upsample_activation_params: negative_slope: 0.2 upsample_scales: [5, 2, 2, 2, 2, 2, 2, 1, 1] upsample_mode: "nearest" gated_function: "softmax" use_weight_norm: True
############################################################ DISCRIMINATOR NETWORK ARCHITECTURE SETTING ############################################################discriminator_type: "StyleMelGANDiscriminator" # Discriminator type.discriminator_params: repeats: 4 window_sizes: [512, 1024, 2048, 4096] pqmf_params: - [1, None, None, None] - [2, 62, 0.26700, 9.0] - [4, 62, 0.14200, 9.0] - [8, 62, 0.07949, 9.0] discriminator_params: out_channels: 1 kernel_sizes: [5, 3] channels: 16 max_downsample_channels: 512 bias: True downsample_scales: [4, 4, 4, 1] nonlinear_activation: "LeakyReLU" nonlinear_activation_params: negative_slope: 0.2 use_weight_norm: True
############################################################ STFT LOSS SETTING ############################################################stft_loss_params: fft_sizes: [1024, 2048, 512] # List of FFT size for STFT-based loss. hop_sizes: [120, 240, 50] # List of hop size for STFT-based loss win_lengths: [600, 1200, 240] # List of window length for STFT-based loss. window: "hann_window" # Window function for STFT-based losslambda_aux: 1.0 # Loss balancing coefficient for aux loss.
############################################################ ADVERSARIAL LOSS SETTING ############################################################lambda_adv: 1.0 # Loss balancing coefficient for adv loss.generator_adv_loss_params: average_by_discriminators: false # Whether to average loss by #discriminators.discriminator_adv_loss_params: average_by_discriminators: false # Whether to average loss by #discriminators.
############################################################ DATA LOADER SETTING ############################################################batch_size: 16 # Batch size.batch_max_steps: 17920 # Length of each audio in batch. Make sure dividable by hop_size.pin_memory: true # Whether to pin memory in Pytorch DataLoader.num_workers: 2 # Number of workers in Pytorch DataLoader.remove_short_samples: false # Whether to remove samples the length of which are less than batch_max_steps.allow_cache: true # Whether to allow cache in dataset. If true, it requires cpu memory.
############################################################ OPTIMIZER & SCHEDULER SETTING ############################################################generator_optimizer_type: Adamgenerator_optimizer_params: lr: 1.0e-4 betas: [0.5, 0.9] weight_decay: 0.0generator_scheduler_type: MultiStepLRgenerator_scheduler_params: gamma: 0.5 milestones: - 100000 - 300000 - 500000 - 700000 - 900000generator_grad_norm: -1discriminator_optimizer_type: Adamdiscriminator_optimizer_params: lr: 2.0e-4 betas: [0.5, 0.9] weight_decay: 0.0discriminator_scheduler_type: MultiStepLRdiscriminator_scheduler_params: gamma: 0.5 milestones: - 200000 - 400000 - 600000 - 800000discriminator_grad_norm: -1 # Discriminator's gradient norm.
############################################################ INTERVAL SETTING ############################################################discriminator_train_start_steps: 100000 # Number of steps to start to train discriminator.train_max_steps: 1500000 # Number of training steps.save_interval_steps: 50000 # Interval steps to save checkpoint.eval_interval_steps: 1000 # Interval steps to evaluate the network.log_interval_steps: 100 # Interval steps to record the training log.
############################################################ OTHER SETTING ############################################################num_save_intermediate_results: 4 # Number of results to be saved as intermediate results.123456789101112131415161718192021222324252627282930313233# cuda relatedexport CUDA_HOME=/usr/local/cuda-11.3export LD_LIBRARY_PATH="${CUDA_HOME}/lib64:${LD_LIBRARY_PATH}"
# path relatedexport PRJ_ROOT="${PWD}/../../.."if [ -e "${PRJ_ROOT}/tools/venv/bin/activate" ]; then # shellcheck disable=SC1090 . "${PRJ_ROOT}/tools/venv/bin/activate"fi
# python relatedexport OMP_NUM_THREADS=1export PYTHONIOENCODING=UTF-8export MPL_BACKEND=Agg
# check installationif ! command -v parallel-wavegan-train > /dev/null; then echo "Error: It seems setup is not finished." >&2 echo "Error: Please setup your environment by following README.md" >&2 return 1fiif ! command -v jq > /dev/null; then echo "Error: It seems jq is not installed." >&2 echo "Error: Please install via \`sudo apt-get install jq\`." >&2 echo "Error: If you do not have sudo, please download from https://stedolan.github.io/jq/download/." >&2 return 1fiif ! command -v yq > /dev/null; then echo "Error: It seems yq is not installed." >&2 echo "Error: Please install via \`pip install yq\`." >&2 return 1fi123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151#!/bin/bash
# Copyright 2020 Tomoki Hayashi# MIT License (https://opensource.org/licenses/MIT)
. ./cmd.sh || exit 1;. ./path.sh || exit 1;
# basic settingsstage=-1 # stage to startstop_stage=100 # stage to stopverbose=1 # verbosity level (lower is less info)n_gpus=1 # number of gpus in trainingn_jobs=16 # number of parallel jobs in feature extraction
# NOTE(kan-bayashi): renamed to conf to avoid conflict in parse_options.shconf=conf/parallel_wavegan_hubert.v1.yaml
# directory path settingdumpdir=dump # directory to dump features
# training related settingtag="" # tag for directory to save modelresume="" # checkpoint path to resume training # (e.g. <path>/<to>/checkpoint-10000steps.pkl)
# decoding related settingcheckpoint="" # checkpoint path to be used for decoding # if not provided, the latest one will be used # (e.g. <path>/<to>/checkpoint-400000steps.pkl)
train_set=tr_2mix_trimdev_set=cv_2mixeval_set=tt_2mix
hubert_text=downloads/dump_feature_hubert9/label_km100_vctk_16k_tr_2mix_trim/all.txt
# shellcheck disable=SC1091. utils/parse_options.sh || exit 1;
set -euo pipefail
if [ "${stage}" -le 0 ] && [ "${stop_stage}" -ge 0 ]; then echo "Stage 0: Data preparation" echo "Data preparation is not prepared." echo "Please manually locate kaldi-style directories as follows:" cat << EOF$ ls data/${train_set}wav.scp utt2spk$ ls data/${dev_set}wav.scp utt2spk$ ls data/${eval_set}wav.scp utt2spkEOF # shellcheck disable=SC2016 echo 'Please make sure "${hubert_text}" is correctly set.' echo "Then, please run from stage 1 via --stage 1." exit 1;fi
if [ "${stage}" -le 1 ] && [ "${stop_stage}" -ge 1 ]; then echo "Stage 1: Feature extraction" if [ ! -e "${hubert_text}" ]; then echo "Valid --hubert_text is not provided. Please prepare it by yourself." echo "hubert_text should be like kaldi-style text as follows:" cat << EOFutt_id_1 0 0 0 0 1 1 1 1 2 2 2 2utt_id_2 0 0 0 0 0 0 3 3 3 3 3 3 5 5 5 5...EOF exit 1 fi # extract raw features pids=() for name in "${train_set}" "${dev_set}" "${eval_set}"; do ( [ ! -e "${dumpdir}/${name}/raw" ] && mkdir -p "${dumpdir}/${name}/raw" echo "Feature extraction start. See the progress via ${dumpdir}/${name}/raw/preprocessing.*.log." utils/make_subset_data.sh "data/${name}" "${n_jobs}" "${dumpdir}/${name}/raw" ${train_cmd} JOB=1:${n_jobs} "${dumpdir}/${name}/raw/preprocessing.JOB.log" \ local/preprocess_hubert.py \ --config "${conf}" \ --scp "${dumpdir}/${name}/raw/wav.JOB.scp" \ --dumpdir "${dumpdir}/${name}/raw/dump.JOB" \ --utt2spk "data/${name}/utt2spk" \ --spk2idx "data/${train_set}/spk2idx" \ --text "${hubert_text}" \ --verbose "${verbose}" echo "Successfully finished feature extraction of ${name} set." ) & pids+=($!) done i=0; for pid in "${pids[@]}"; do wait "${pid}" || ((++i)); done [ "${i}" -gt 0 ] && echo "$0: ${i} background jobs are failed." && exit 1; echo "Successfully finished feature extraction."
fi
if [ -z "${tag}" ]; then expdir="exp/${train_set}_vctk_$(basename "${conf}" .yaml)"else expdir="exp/${train_set}_vctk_${tag}"fiif [ "${stage}" -le 2 ] && [ "${stop_stage}" -ge 2 ]; then echo "Stage 2: Network training" [ ! -e "${expdir}" ] && mkdir -p "${expdir}" if [ "${n_gpus}" -gt 1 ]; then train="python -m parallel_wavegan.distributed.launch --nproc_per_node ${n_gpus} -c parallel-wavegan-train" else train="parallel-wavegan-train" fi # shellcheck disable=SC2012 resume="$(ls -dt "${expdir}"/*.pkl | head -1 || true)" echo "Training start. See the progress via ${expdir}/train.log." ${cuda_cmd} --gpu "${n_gpus}" "${expdir}/train.log" \ ${train} \ --config "${conf}" \ --train-dumpdir "${dumpdir}/${train_set}/raw" \ --dev-dumpdir "${dumpdir}/${dev_set}/raw" \ --outdir "${expdir}" \ --resume "${resume}" \ --verbose "${verbose}" echo "Successfully finished training."fi
if [ "${stage}" -le 3 ] && [ "${stop_stage}" -ge 3 ]; then echo "Stage 3: Network decoding" # shellcheck disable=SC2012 [ -z "${checkpoint}" ] && checkpoint="$(ls -dt "${expdir}"/*.pkl | head -1 || true)" outdir="${expdir}/wav/$(basename "${checkpoint}" .pkl)" pids=() for name in "${dev_set}" "${eval_set}"; do ( [ ! -e "${outdir}/${name}" ] && mkdir -p "${outdir}/${name}" [ "${n_gpus}" -gt 1 ] && n_gpus=1 echo "Decoding start. See the progress via ${outdir}/${name}/decode.log." ${cuda_cmd} --gpu "${n_gpus}" "${outdir}/${name}/decode.log" \ parallel-wavegan-decode \ --dumpdir "${dumpdir}/${name}/raw" \ --checkpoint "${checkpoint}" \ --outdir "${outdir}/${name}" \ --verbose "${verbose}" echo "Successfully finished decoding of ${name} set." ) & pids+=($!) done i=0; for pid in "${pids[@]}"; do wait "${pid}" || ((++i)); done [ "${i}" -gt 0 ] && echo "$0: ${i} background jobs are failed." && exit 1; echo "Successfully finished decoding."fiecho "Finished."12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091# ====== About run.pl, queue.pl, slurm.pl, and ssh.pl ======# Usage: <cmd>.pl [options] JOB=1:<nj> <log> <command...># e.g.# run.pl --mem 4G JOB=1:10 echo.JOB.log echo JOB## Options:# --time <time>: Limit the maximum time to execute.# --mem <mem>: Limit the maximum memory usage.# -–max-jobs-run <njob>: Limit the number parallel jobs. This is ignored for non-array jobs.# --num-threads <ngpu>: Specify the number of CPU core.# --gpu <ngpu>: Specify the number of GPU devices.# --config: Change the configuration file from default.## "JOB=1:10" is used for "array jobs" and it can control the number of parallel jobs.# The left string of "=", i.e. "JOB", is replaced by <N>(Nth job) in the command and the log file name,# e.g. "echo JOB" is changed to "echo 3" for the 3rd job and "echo 8" for 8th job respectively.# Note that the number must start with a positive number, so you can't use "JOB=0:10" for example.## run.pl, queue.pl, slurm.pl, and ssh.pl have unified interface, not depending on its backend.# These options are mapping to specific options for each backend and# it is configured by "conf/queue.conf" and "conf/slurm.conf" by default.# If jobs failed, your configuration might be wrong for your environment.### The official documentaion for run.pl, queue.pl, slurm.pl, and ssh.pl:# "Parallelization in Kaldi": http://kaldi-asr.org/doc/queue.html# =========================================================~
# Select the backend used by run.sh from "local", "stdout", "sge", "slurm", or "ssh"cmd_backend="local"
# Local machine, without any Job scheduling systemif [ "${cmd_backend}" = local ]; then
# The other usage export train_cmd="utils/run.pl" # Used for "*_train.py": "--gpu" is appended optionally by run.sh export cuda_cmd="utils/run.pl" # Used for "*_recog.py" export decode_cmd="utils/run.pl"
# Local machine, without any Job scheduling systemelif [ "${cmd_backend}" = stdout ]; then
# The other usage export train_cmd="utils/stdout.pl" # Used for "*_train.py": "--gpu" is appended optionally by run.sh export cuda_cmd="utils/stdout.pl" # Used for "*_recog.py" export decode_cmd="utils/stdout.pl"
# "qsub" (SGE, Torque, PBS, etc.)elif [ "${cmd_backend}" = sge ]; then # The default setting is written in conf/queue.conf. # You must change "-q g.q" for the "queue" for your environment. # To know the "queue" names, type "qhost -q" # Note that to use "--gpu *", you have to setup "complex_value" for the system scheduler.
export train_cmd="utils/queue.pl" export cuda_cmd="utils/queue.pl" export decode_cmd="utils/queue.pl"
# "sbatch" (Slurm)elif [ "${cmd_backend}" = slurm ]; then # The default setting is written in conf/slurm.conf. # You must change "-p cpu" and "-p gpu" for the "partion" for your environment. # To know the "partion" names, type "sinfo". # You can use "--gpu * " by defualt for slurm and it is interpreted as "--gres gpu:*" # The devices are allocated exclusively using "${CUDA_VISIBLE_DEVICES}".
export train_cmd="utils/slurm.pl" export cuda_cmd="utils/slurm.pl" export decode_cmd="utils/slurm.pl"
elif [ "${cmd_backend}" = ssh ]; then # You have to create ".queue/machines" to specify the host to execute jobs. # e.g. .queue/machines # host1 # host2 # host3 # Assuming you can login them without any password, i.e. You have to set ssh keys.
export train_cmd="utils/ssh.pl" export cuda_cmd="utils/ssh.pl" export decode_cmd="utils/ssh.pl"
else echo "$0: Error: Unknown cmd_backend=${cmd_backend}" 1>&2 return 1fi123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180# This is the configuration file for VCTK dataset.# This configuration is based on HiFiGAN V1, which is# an official configuration. But I found that the optimizer# setting does not work well with my implementation.# So I changed optimizer settings as follows:# - AdamW -> Adam# - betas: [0.8, 0.99] -> betas: [0.5, 0.9]# - Scheduler: ExponentialLR -> MultiStepLR# To match the shift size difference, the upsample scales# is also modified from the original 256 shift setting.
############################################################ FEATURE EXTRACTION SETTING ############################################################sampling_rate: 24000 # Sampling rate.fft_size: 2048 # FFT size.hop_size: 300 # Hop size.win_length: 1200 # Window length. # If set to null, it will be the same as fft_size.window: "hann" # Window function.num_mels: 80 # Number of mel basis.fmin: 80 # Minimum freq in mel basis calculation.fmax: 7600 # Maximum frequency in mel basis calculation.global_gain_scale: 1.0 # Will be multiplied to all of waveform.trim_silence: false # Whether to trim the start and end of silence.trim_threshold_in_db: 20 # Need to tune carefully if the recording is not good.trim_frame_size: 1024 # Frame size in trimming.trim_hop_size: 256 # Hop size in trimming.format: "hdf5" # Feature file format. "npy" or "hdf5" is supported.
############################################################ GENERATOR NETWORK ARCHITECTURE SETTING ############################################################generator_type: HiFiGANGeneratorgenerator_params: in_channels: 80 # Number of input channels. out_channels: 1 # Number of output channels. channels: 512 # Number of initial channels. kernel_size: 7 # Kernel size of initial and final conv layers. upsample_scales: [5, 5, 4, 3] # Upsampling scales. upsample_kernel_sizes: [10, 10, 8, 6] # Kernel size for upsampling layers. resblock_kernel_sizes: [3, 7, 11] # Kernel size for residual blocks. resblock_dilations: # Dilations for residual blocks. - [1, 3, 5] - [1, 3, 5] - [1, 3, 5] use_additional_convs: true # Whether to use additional conv layer in residual blocks. bias: true # Whether to use bias parameter in conv. nonlinear_activation: "LeakyReLU" # Nonlinear activation type. nonlinear_activation_params: # Nonlinear activation paramters. negative_slope: 0.1 use_weight_norm: true # Whether to apply weight normalization.
############################################################ DISCRIMINATOR NETWORK ARCHITECTURE SETTING ############################################################discriminator_type: HiFiGANMultiScaleMultiPeriodDiscriminatordiscriminator_params: scales: 3 # Number of multi-scale discriminator. scale_downsample_pooling: "AvgPool1d" # Pooling operation for scale discriminator. scale_downsample_pooling_params: kernel_size: 4 # Pooling kernel size. stride: 2 # Pooling stride. padding: 2 # Padding size. scale_discriminator_params: in_channels: 1 # Number of input channels. out_channels: 1 # Number of output channels. kernel_sizes: [15, 41, 5, 3] # List of kernel sizes. channels: 128 # Initial number of channels. max_downsample_channels: 1024 # Maximum number of channels in downsampling conv layers. max_groups: 16 # Maximum number of groups in downsampling conv layers. bias: true downsample_scales: [4, 4, 4, 4, 1] # Downsampling scales. nonlinear_activation: "LeakyReLU" # Nonlinear activation. nonlinear_activation_params: negative_slope: 0.1 follow_official_norm: true # Whether to follow the official norm setting. periods: [2, 3, 5, 7, 11] # List of period for multi-period discriminator. period_discriminator_params: in_channels: 1 # Number of input channels. out_channels: 1 # Number of output channels. kernel_sizes: [5, 3] # List of kernel sizes. channels: 32 # Initial number of channels. downsample_scales: [3, 3, 3, 3, 1] # Downsampling scales. max_downsample_channels: 1024 # Maximum number of channels in downsampling conv layers. bias: true # Whether to use bias parameter in conv layer." nonlinear_activation: "LeakyReLU" # Nonlinear activation. nonlinear_activation_params: # Nonlinear activation paramters. negative_slope: 0.1 use_weight_norm: true # Whether to apply weight normalization. use_spectral_norm: false # Whether to apply spectral normalization.
############################################################ STFT LOSS SETTING ############################################################use_stft_loss: false # Whether to use multi-resolution STFT loss.use_mel_loss: true # Whether to use Mel-spectrogram loss.mel_loss_params: fs: 24000 fft_size: 2048 hop_size: 300 win_length: 1200 window: "hann" num_mels: 80 fmin: 0 fmax: 12000 log_base: nullgenerator_adv_loss_params: average_by_discriminators: false # Whether to average loss by #discriminators.discriminator_adv_loss_params: average_by_discriminators: false # Whether to average loss by #discriminators.use_feat_match_loss: truefeat_match_loss_params: average_by_discriminators: false # Whether to average loss by #discriminators. average_by_layers: false # Whether to average loss by #layers in each discriminator. include_final_outputs: false # Whether to include final outputs in feat match loss calculation.
############################################################ ADVERSARIAL LOSS SETTING ############################################################lambda_aux: 45.0 # Loss balancing coefficient for STFT loss.lambda_adv: 1.0 # Loss balancing coefficient for adversarial loss.lambda_feat_match: 2.0 # Loss balancing coefficient for feat match loss..
############################################################ DATA LOADER SETTING ############################################################batch_size: 16 # Batch size.batch_max_steps: 8400 # Length of each audio in batch. Make sure dividable by hop_size.pin_memory: true # Whether to pin memory in Pytorch DataLoader.num_workers: 2 # Number of workers in Pytorch DataLoader.remove_short_samples: false # Whether to remove samples the length of which are less than batch_max_steps.allow_cache: true # Whether to allow cache in dataset. If true, it requires cpu memory.
############################################################ OPTIMIZER & SCHEDULER SETTING ############################################################generator_optimizer_type: Adamgenerator_optimizer_params: lr: 2.0e-4 betas: [0.5, 0.9] weight_decay: 0.0generator_scheduler_type: MultiStepLRgenerator_scheduler_params: gamma: 0.5 milestones: - 200000 - 400000 - 600000 - 800000generator_grad_norm: -1discriminator_optimizer_type: Adamdiscriminator_optimizer_params: lr: 2.0e-4 betas: [0.5, 0.9] weight_decay: 0.0discriminator_scheduler_type: MultiStepLRdiscriminator_scheduler_params: gamma: 0.5 milestones: - 200000 - 400000 - 600000 - 800000discriminator_grad_norm: -1
############################################################ INTERVAL SETTING ############################################################generator_train_start_steps: 1 # Number of steps to start to train discriminator.discriminator_train_start_steps: 0 # Number of steps to start to train discriminator.train_max_steps: 2500000 # Number of training steps.save_interval_steps: 10000 # Interval steps to save checkpoint.eval_interval_steps: 1000 # Interval steps to evaluate the network.log_interval_steps: 100 # Interval steps to record the training log.
############################################################ OTHER SETTING ############################################################num_save_intermediate_results: 4 # Number of results to be saved as intermediate results.123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154# This is the hyperparameter configuration file for MelGAN.# Please make sure this is adjusted for the VCTK dataset. If you want to# apply to the other dataset, you might need to carefully change some parameters.# This configuration requires ~ 6GB memory and will finish within 3 days on Titan V.
# This configuration is based on multi-band MelGAN but the hop size and sampling# rate is different from the paper (16kHz vs 24kHz). The number of iteraions# is now shown in the paper so currently we train 1M iterations (not sure enough# to converge). Compared to multi_band_melgan.v1 config, Adam optimizer without# gradient norm is used, which is based on @dathudeptrai advice.# https://github.com/kan-bayashi/ParallelWaveGAN/issues/143#issuecomment-632539906
# We found that the use of small batch_max_steps has no bad effect for the quality,# so we use 8,100 for batch_max_steps to accelerate the training.
############################################################ FEATURE EXTRACTION SETTING ############################################################sampling_rate: 24000 # Sampling rate.fft_size: 2048 # FFT size.hop_size: 300 # Hop size.win_length: 1200 # Window length. # If set to null, it will be the same as fft_size.window: "hann" # Window function.num_mels: 80 # Number of mel basis.fmin: 80 # Minimum freq in mel basis calculation.fmax: 7600 # Maximum frequency in mel basis calculation.global_gain_scale: 1.0 # Will be multiplied to all of waveform.trim_silence: false # Whether to trim the start and end of silence.trim_threshold_in_db: 60 # Need to tune carefully if the recording is not good.trim_frame_size: 2048 # Frame size in trimming.trim_hop_size: 512 # Hop size in trimming.format: "hdf5" # Feature file format. "npy" or "hdf5" is supported.
############################################################ GENERATOR NETWORK ARCHITECTURE SETTING ############################################################generator_type: "MelGANGenerator" # Generator type.generator_params: in_channels: 80 # Number of input channels. out_channels: 4 # Number of output channels. kernel_size: 7 # Kernel size of initial and final conv layers. channels: 384 # Initial number of channels for conv layers. upsample_scales: [5, 5, 3] # List of Upsampling scales. stack_kernel_size: 3 # Kernel size of dilated conv layers in residual stack. stacks: 4 # Number of stacks in a single residual stack module. use_weight_norm: True # Whether to use weight normalization. use_causal_conv: False # Whether to use causal convolution.
############################################################ DISCRIMINATOR NETWORK ARCHITECTURE SETTING ############################################################discriminator_type: "MelGANMultiScaleDiscriminator" # Discriminator type.discriminator_params: in_channels: 1 # Number of input channels. out_channels: 1 # Number of output channels. scales: 3 # Number of multi-scales. downsample_pooling: "AvgPool1d" # Pooling type for the input downsampling. downsample_pooling_params: # Parameters of the above pooling function. kernel_size: 4 stride: 2 padding: 1 count_include_pad: False kernel_sizes: [5, 3] # List of kernel size. channels: 16 # Number of channels of the initial conv layer. max_downsample_channels: 512 # Maximum number of channels of downsampling layers. downsample_scales: [4, 4, 4] # List of downsampling scales. nonlinear_activation: "LeakyReLU" # Nonlinear activation function. nonlinear_activation_params: # Parameters of nonlinear activation function. negative_slope: 0.2 use_weight_norm: True # Whether to use weight norm.
############################################################ STFT LOSS SETTING ############################################################stft_loss_params: fft_sizes: [1024, 2048, 512] # List of FFT size for STFT-based loss. hop_sizes: [120, 240, 50] # List of hop size for STFT-based loss win_lengths: [600, 1200, 240] # List of window length for STFT-based loss. window: "hann_window" # Window function for STFT-based lossuse_subband_stft_loss: truesubband_stft_loss_params: fft_sizes: [384, 683, 171] # List of FFT size for STFT-based loss. hop_sizes: [30, 60, 10] # List of hop size for STFT-based loss win_lengths: [150, 300, 60] # List of window length for STFT-based loss. window: "hann_window" # Window function for STFT-based loss
############################################################ ADVERSARIAL LOSS SETTING ############################################################use_feat_match_loss: false # Whether to use feature matching loss.lambda_adv: 2.5 # Loss balancing coefficient for adversarial loss.
############################################################ DATA LOADER SETTING ############################################################batch_size: 64 # Batch size.batch_max_steps: 8100 # Length of each audio in batch. Make sure dividable by hop_size.pin_memory: true # Whether to pin memory in Pytorch DataLoader.num_workers: 4 # Number of workers in Pytorch DataLoader.remove_short_samples: true # Whether to remove samples the length of which are less than batch_max_steps.allow_cache: true # Whether to allow cache in dataset. If true, it requires cpu memory.
############################################################ OPTIMIZER & SCHEDULER SETTING ############################################################generator_optimizer_type: "Adam" # Generator's optimizer type.generator_optimizer_params: lr: 1.0e-3 # Generator's learning rate. eps: 1.0e-7 # Generator's epsilon. weight_decay: 0.0 # Generator's weight decay coefficient. amsgrad: truegenerator_grad_norm: -1 # Generator's gradient norm.generator_scheduler_type: "MultiStepLR" # Generator's scheduler type.generator_scheduler_params: gamma: 0.5 # Generator's scheduler gamma. milestones: # At each milestone, lr will be multiplied by gamma. - 100000 - 200000 - 300000 - 400000 - 500000 - 600000discriminator_optimizer_type: "Adam" # Discriminator's optimizer type.discriminator_optimizer_params: lr: 1.0e-3 # Discriminator's learning rate. eps: 1.0e-7 # Discriminator's epsilon. weight_decay: 0.0 # Discriminator's weight decay coefficient. amsgrad: truediscriminator_grad_norm: -1 # Discriminator's gradient norm.discriminator_scheduler_type: "MultiStepLR" # Discriminator's scheduler type.discriminator_scheduler_params: gamma: 0.5 # Discriminator's scheduler gamma. milestones: # At each milestone, lr will be multiplied by gamma. - 100000 - 200000 - 300000 - 400000 - 500000 - 600000
############################################################ INTERVAL SETTING ############################################################discriminator_train_start_steps: 200000 # Number of steps to start to train discriminator.train_max_steps: 1000000 # Number of training steps.save_interval_steps: 50000 # Interval steps to save checkpoint.eval_interval_steps: 1000 # Interval steps to evaluate the network.log_interval_steps: 1000 # Interval steps to record the training log.
############################################################ OTHER SETTING ############################################################num_save_intermediate_results: 4 # Number of results to be saved as intermediate results.123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122# This is the hyperparameter configuration file for Parallel WaveGAN.# Please make sure this is adjusted for the VCTK corpus. If you want to# apply to the other dataset, you might need to carefully change some parameters.# This configuration requires 12 GB GPU memory and takes ~7 days on RTX TITAN.
############################################################ FEATURE EXTRACTION SETTING ############################################################sampling_rate: 24000 # Sampling rate.fft_size: 2048 # FFT size.hop_size: 300 # Hop size.win_length: 1200 # Window length. # If set to null, it will be the same as fft_size.window: "hann" # Window function.num_mels: 80 # Number of mel basis.fmin: 80 # Minimum freq in mel basis calculation.fmax: 7600 # Maximum frequency in mel basis calculation.global_gain_scale: 1.0 # Will be multiplied to all of waveform.trim_silence: false # Whether to trim the start and end of silence.trim_threshold_in_db: 20 # Need to tune carefully if the recording is not good.trim_frame_size: 1024 # Frame size in trimming.trim_hop_size: 256 # Hop size in trimming.format: "hdf5" # Feature file format. "npy" or "hdf5" is supported.
############################################################ GENERATOR NETWORK ARCHITECTURE SETTING ############################################################generator_params: in_channels: 1 # Number of input channels. out_channels: 1 # Number of output channels. kernel_size: 3 # Kernel size of dilated convolution. layers: 30 # Number of residual block layers. stacks: 3 # Number of stacks i.e., dilation cycles. residual_channels: 64 # Number of channels in residual conv. gate_channels: 128 # Number of channels in gated conv. skip_channels: 64 # Number of channels in skip conv. aux_channels: 80 # Number of channels for auxiliary feature conv. # Must be the same as num_mels. aux_context_window: 2 # Context window size for auxiliary feature. # If set to 2, previous 2 and future 2 frames will be considered. dropout: 0.0 # Dropout rate. 0.0 means no dropout applied. use_weight_norm: true # Whether to use weight norm. # If set to true, it will be applied to all of the conv layers. upsample_net: "ConvInUpsampleNetwork" # Upsampling network architecture. upsample_params: # Upsampling network parameters. upsample_scales: [4, 5, 3, 5] # Upsampling scales. Prodcut of these must be the same as hop size.
############################################################ DISCRIMINATOR NETWORK ARCHITECTURE SETTING ############################################################discriminator_params: in_channels: 1 # Number of input channels. out_channels: 1 # Number of output channels. kernel_size: 3 # Number of output channels. layers: 10 # Number of conv layers. conv_channels: 64 # Number of chnn layers. bias: true # Whether to use bias parameter in conv. use_weight_norm: true # Whether to use weight norm. # If set to true, it will be applied to all of the conv layers. nonlinear_activation: "LeakyReLU" # Nonlinear function after each conv. nonlinear_activation_params: # Nonlinear function parameters negative_slope: 0.2 # Alpha in LeakyReLU.
############################################################ STFT LOSS SETTING ############################################################stft_loss_params: fft_sizes: [1024, 2048, 512] # List of FFT size for STFT-based loss. hop_sizes: [120, 240, 50] # List of hop size for STFT-based loss win_lengths: [600, 1200, 240] # List of window length for STFT-based loss. window: "hann_window" # Window function for STFT-based loss
############################################################ ADVERSARIAL LOSS SETTING ############################################################lambda_adv: 4.0 # Loss balancing coefficient.
############################################################ DATA LOADER SETTING ############################################################batch_size: 6 # Batch size.batch_max_steps: 24000 # Length of each audio in batch. Make sure dividable by hop_size.pin_memory: true # Whether to pin memory in Pytorch DataLoader.num_workers: 2 # Number of workers in Pytorch DataLoader.remove_short_samples: true # Whether to remove samples the length of which are less than batch_max_steps.allow_cache: true # Whether to allow cache in dataset. If true, it requires cpu memory.
############################################################ OPTIMIZER & SCHEDULER SETTING ############################################################generator_optimizer_params: lr: 0.0001 # Generator's learning rate. eps: 1.0e-6 # Generator's epsilon. weight_decay: 0.0 # Generator's weight decay coefficient.generator_scheduler_params: step_size: 200000 # Generator's scheduler step size. gamma: 0.5 # Generator's scheduler gamma. # At each step size, lr will be multiplied by this parameter.generator_grad_norm: 10 # Generator's gradient norm.discriminator_optimizer_params: lr: 0.00005 # Discriminator's learning rate. eps: 1.0e-6 # Discriminator's epsilon. weight_decay: 0.0 # Discriminator's weight decay coefficient.discriminator_scheduler_params: step_size: 200000 # Discriminator's scheduler step size. gamma: 0.5 # Discriminator's scheduler gamma. # At each step size, lr will be multiplied by this parameter.discriminator_grad_norm: 1 # Discriminator's gradient norm.
############################################################ INTERVAL SETTING ############################################################discriminator_train_start_steps: 100000 # Number of steps to start to train discriminator.train_max_steps: 1000000 # Number of training steps.save_interval_steps: 5000 # Interval steps to save checkpoint.eval_interval_steps: 1000 # Interval steps to evaluate the network.log_interval_steps: 100 # Interval steps to record the training log.
############################################################ OTHER SETTING ############################################################num_save_intermediate_results: 4 # Number of results to be saved as intermediate results.123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122# This is the hyperparameter configuration file for Parallel WaveGAN.# Please make sure this is adjusted for the VCTK corpus. If you want to# apply to the other dataset, you might need to carefully change some parameters.# This configuration requires 12 GB GPU memory and takes ~3 days on RTX TITAN.
############################################################ FEATURE EXTRACTION SETTING ############################################################sampling_rate: 24000 # Sampling rate.fft_size: 2048 # FFT size.hop_size: 300 # Hop size.win_length: 1200 # Window length. # If set to null, it will be the same as fft_size.window: "hann" # Window function.num_mels: 80 # Number of mel basis.fmin: 80 # Minimum freq in mel basis calculation.fmax: 7600 # Maximum frequency in mel basis calculation.global_gain_scale: 1.0 # Will be multiplied to all of waveform.trim_silence: false # Whether to trim the start and end of silence.trim_threshold_in_db: 20 # Need to tune carefully if the recording is not good.trim_frame_size: 1024 # Frame size in trimming.trim_hop_size: 256 # Hop size in trimming.format: "hdf5" # Feature file format. "npy" or "hdf5" is supported.
############################################################ GENERATOR NETWORK ARCHITECTURE SETTING ############################################################generator_params: in_channels: 1 # Number of input channels. out_channels: 1 # Number of output channels. kernel_size: 3 # Kernel size of dilated convolution. layers: 30 # Number of residual block layers. stacks: 3 # Number of stacks i.e., dilation cycles. residual_channels: 64 # Number of channels in residual conv. gate_channels: 128 # Number of channels in gated conv. skip_channels: 64 # Number of channels in skip conv. aux_channels: 80 # Number of channels for auxiliary feature conv. # Must be the same as num_mels. aux_context_window: 2 # Context window size for auxiliary feature. # If set to 2, previous 2 and future 2 frames will be considered. dropout: 0.0 # Dropout rate. 0.0 means no dropout applied. use_weight_norm: true # Whether to use weight norm. # If set to true, it will be applied to all of the conv layers. upsample_net: "ConvInUpsampleNetwork" # Upsampling network architecture. upsample_params: # Upsampling network parameters. upsample_scales: [4, 5, 3, 5] # Upsampling scales. Prodcut of these must be the same as hop size.
############################################################ DISCRIMINATOR NETWORK ARCHITECTURE SETTING ############################################################discriminator_params: in_channels: 1 # Number of input channels. out_channels: 1 # Number of output channels. kernel_size: 3 # Number of output channels. layers: 10 # Number of conv layers. conv_channels: 64 # Number of chnn layers. bias: true # Whether to use bias parameter in conv. use_weight_norm: true # Whether to use weight norm. # If set to true, it will be applied to all of the conv layers. nonlinear_activation: "LeakyReLU" # Nonlinear function after each conv. nonlinear_activation_params: # Nonlinear function parameters negative_slope: 0.2 # Alpha in LeakyReLU.
############################################################ STFT LOSS SETTING ############################################################stft_loss_params: fft_sizes: [1024, 2048, 512] # List of FFT size for STFT-based loss. hop_sizes: [120, 240, 50] # List of hop size for STFT-based loss win_lengths: [600, 1200, 240] # List of window length for STFT-based loss. window: "hann_window" # Window function for STFT-based loss
############################################################ ADVERSARIAL LOSS SETTING ############################################################lambda_adv: 4.0 # Loss balancing coefficient.
############################################################ DATA LOADER SETTING ############################################################batch_size: 6 # Batch size.batch_max_steps: 24000 # Length of each audio in batch. Make sure dividable by hop_size.pin_memory: true # Whether to pin memory in Pytorch DataLoader.num_workers: 2 # Number of workers in Pytorch DataLoader.remove_short_samples: true # Whether to remove samples the length of which are less than batch_max_steps.allow_cache: true # Whether to allow cache in dataset. If true, it requires cpu memory.
############################################################ OPTIMIZER & SCHEDULER SETTING ############################################################generator_optimizer_params: lr: 0.0001 # Generator's learning rate. eps: 1.0e-6 # Generator's epsilon. weight_decay: 0.0 # Generator's weight decay coefficient.generator_scheduler_params: step_size: 200000 # Generator's scheduler step size. gamma: 0.5 # Generator's scheduler gamma. # At each step size, lr will be multiplied by this parameter.generator_grad_norm: 10 # Generator's gradient norm.discriminator_optimizer_params: lr: 0.00005 # Discriminator's learning rate. eps: 1.0e-6 # Discriminator's epsilon. weight_decay: 0.0 # Discriminator's weight decay coefficient.discriminator_scheduler_params: step_size: 200000 # Discriminator's scheduler step size. gamma: 0.5 # Discriminator's scheduler gamma. # At each step size, lr will be multiplied by this parameter.discriminator_grad_norm: 1 # Discriminator's gradient norm.
############################################################ INTERVAL SETTING ############################################################discriminator_train_start_steps: 100000 # Number of steps to start to train discriminator.train_max_steps: 1000000 # Number of training steps.save_interval_steps: 5000 # Interval steps to save checkpoint.eval_interval_steps: 1000 # Interval steps to evaluate the network.log_interval_steps: 100 # Interval steps to record the training log.
############################################################ OTHER SETTING ############################################################num_save_intermediate_results: 4 # Number of results to be saved as intermediate results.123456789101112# Default configurationcommand sbatch --export=PATH --ntasks-per-node=1option time=* --time $0option mem=* --mem-per-cpu $0option mem=0 # Do not add anything to qsub_optsoption num_threads=* --cpus-per-task $0 --ntasks-per-node=1option num_threads=1 --cpus-per-task 1 --ntasks-per-node=1 # Do not add anything to qsub_optsdefault gpu=0option gpu=0 -p cpuoption gpu=* -p gpu --gres=gpu:$0# note: the --max-jobs-run option is supported as a special case# by slurm.pl and you don't have to handle it in the config file.123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147# This is the configuration file for VCTK dataset.# This configuration is based on StyleMelGAN paper but# uses MSE loss instead of Hinge loss. And I found that# batch_size = 8 is also working good. So maybe if you# want to accelerate the training, you can reduce the# batch size (e.g. 8 or 16). Upsampling scales is modified# to fit the shift size 300 pt.
############################################################ FEATURE EXTRACTION SETTING ############################################################sampling_rate: 24000 # Sampling rate.fft_size: 2048 # FFT size.hop_size: 300 # Hop size.win_length: 1200 # Window length. # If set to null, it will be the same as fft_size.window: "hann" # Window function.num_mels: 80 # Number of mel basis.fmin: 80 # Minimum freq in mel basis calculation.fmax: 7600 # Maximum frequency in mel basis calculation.global_gain_scale: 1.0 # Will be multiplied to all of waveform.trim_silence: false # Whether to trim the start and end of silence.trim_threshold_in_db: 60 # Need to tune carefully if the recording is not good.trim_frame_size: 1024 # Frame size in trimming.trim_hop_size: 256 # Hop size in trimming.format: "hdf5" # Feature file format. " npy " or " hdf5 " is supported.
############################################################ GENERATOR NETWORK ARCHITECTURE SETTING ############################################################generator_type: "StyleMelGANGenerator" # Generator type.generator_params: in_channels: 128 aux_channels: 80 channels: 64 out_channels: 1 kernel_size: 9 dilation: 2 bias: True noise_upsample_scales: [10, 2, 2, 2] noise_upsample_activation: "LeakyReLU" noise_upsample_activation_params: negative_slope: 0.2 upsample_scales: [5, 1, 5, 1, 3, 1, 2, 2, 1] upsample_mode: "nearest" gated_function: "softmax" use_weight_norm: True
############################################################ DISCRIMINATOR NETWORK ARCHITECTURE SETTING ############################################################discriminator_type: "StyleMelGANDiscriminator" # Discriminator type.discriminator_params: repeats: 4 window_sizes: [512, 1024, 2048, 4096] pqmf_params: - [1, None, None, None] - [2, 62, 0.26700, 9.0] - [4, 62, 0.14200, 9.0] - [8, 62, 0.07949, 9.0] discriminator_params: out_channels: 1 kernel_sizes: [5, 3] channels: 16 max_downsample_channels: 512 bias: True downsample_scales: [4, 4, 4, 1] nonlinear_activation: "LeakyReLU" nonlinear_activation_params: negative_slope: 0.2 use_weight_norm: True
############################################################ STFT LOSS SETTING ############################################################stft_loss_params: fft_sizes: [1024, 2048, 512] # List of FFT size for STFT-based loss. hop_sizes: [120, 240, 50] # List of hop size for STFT-based loss win_lengths: [600, 1200, 240] # List of window length for STFT-based loss. window: "hann_window" # Window function for STFT-based losslambda_aux: 1.0 # Loss balancing coefficient for aux loss.
############################################################ ADVERSARIAL LOSS SETTING ############################################################lambda_adv: 1.0 # Loss balancing coefficient for adv loss.generator_adv_loss_params: average_by_discriminators: false # Whether to average loss by #discriminators.discriminator_adv_loss_params: average_by_discriminators: false # Whether to average loss by #discriminators.
############################################################ DATA LOADER SETTING ############################################################batch_size: 32 # Batch size.batch_max_steps: 24000 # Length of each audio in batch. Make sure dividable by hop_size.pin_memory: true # Whether to pin memory in Pytorch DataLoader.num_workers: 2 # Number of workers in Pytorch DataLoader.remove_short_samples: false # Whether to remove samples the length of which are less than batch_max_steps.allow_cache: true # Whether to allow cache in dataset. If true, it requires cpu memory.
############################################################ OPTIMIZER & SCHEDULER SETTING ############################################################generator_optimizer_type: Adamgenerator_optimizer_params: lr: 1.0e-4 betas: [0.5, 0.9] weight_decay: 0.0generator_scheduler_type: MultiStepLRgenerator_scheduler_params: gamma: 0.5 milestones: - 100000 - 300000 - 500000 - 700000 - 900000generator_grad_norm: -1discriminator_optimizer_type: Adamdiscriminator_optimizer_params: lr: 2.0e-4 betas: [0.5, 0.9] weight_decay: 0.0discriminator_scheduler_type: MultiStepLRdiscriminator_scheduler_params: gamma: 0.5 milestones: - 200000 - 400000 - 600000 - 800000discriminator_grad_norm: -1
############################################################ INTERVAL SETTING ############################################################discriminator_train_start_steps: 100000 # Number of steps to start to train discriminator.train_max_steps: 1500000 # Number of training steps.save_interval_steps: 50000 # Interval steps to save checkpoint.eval_interval_steps: 1000 # Interval steps to evaluate the network.log_interval_steps: 100 # Interval steps to record the training log.
############################################################ OTHER SETTING ############################################################num_save_intermediate_results: 4 # Number of results to be saved as intermediate results.12345678910111213141516171819202122232425262728293031323334353637#!/bin/bash
# Copyright 2020 Tomoki Hayashi# MIT License (https://opensource.org/licenses/MIT)
download_dir=$1
# check argumentsif [ $# != 1 ]; then echo "Usage: $0 <download_dir>" exit 1fi
set -euo pipefail
cwd=$(pwd)if [ ! -e "${download_dir}/VCTK-Corpus" ]; then mkdir -p "${download_dir}" cd "${download_dir}" || exit 1; wget http://www.udialogue.org/download/VCTK-Corpus.tar.gz tar xvzf ./VCTK-Corpus.tar.gz rm ./VCTK-Corpus.tar.gz cd "${cwd}" || exit 1; echo "Successfully downloaded data."else echo "Already exists. Skipped."fi
if [ ! -e "${download_dir}/VCTK-Corpus/lab" ]; then cd "${download_dir}" || exit 1; git clone https://github.com/kan-bayashi/VCTKCorpusFullContextLabel.git cp -r VCTKCorpusFullContextLabel/lab ./VCTK-Corpus cd "${cwd}" || exit 1; echo "Successfully downloaded label data."else echo "Already exists. Skipped."fi123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118#!/bin/bash
# Copyright 2020 Tomoki Hayashi# MIT License (https://opensource.org/licenses/MIT)
# shellcheck disable=SC1091. ./path.sh || exit 1;
fs=24000num_dev=10num_eval=10train_set="train_nodev"dev_set="dev"eval_set="eval"shuffle=false
# shellcheck disable=SC1091. utils/parse_options.sh || exit 1;
db_root=$1spk=$2data_dir=$3
# check argumentsif [ $# != 3 ]; then echo "Usage: $0 [Options] <db_root> <spk> <data_dir>" echo "e.g.: $0 downloads/VCTK-Corpus p225 data" echo "" echo "Options:" echo " --fs: target sampling rate (default=24000)." echo " --num_dev: number of development uttreances (default=10)." echo " --num_eval: number of evaluation uttreances (default=10)." echo " --train_set: name of train set (default=train_nodev)." echo " --dev_set: name of dev set (default=dev)." echo " --eval_set: name of eval set (default=eval)." echo " --shuffle: whether to perform shuffle in making dev / eval set (default=false)." exit 1fi
set -euo pipefail
# check spk existence[ ! -e "${db_root}/lab/mono/${spk}" ] && \ echo "${spk} does not exist." >&2 && exit 1;
[ ! -e "${data_dir}/all" ] && mkdir -p "${data_dir}/all"
# set filenamesscp="${data_dir}/all/wav.scp"segments="${data_dir}/all/segments"
# check file existence[ -e "${scp}" ] && rm "${scp}"[ -e "${segments}" ] && rm "${segments}"
# make scp and segmentsfind "${db_root}/wav48/${spk}" -follow -name "*.wav" | sort | while read -r wav; do id=$(basename "${wav}" | sed -e "s/\.[^\.]*$//g") lab=${db_root}/lab/mono/${spk}/${id}.lab
# check lab existence if [ ! -e "${lab}" ]; then echo "${id} does not have a label file. skipped." continue fi
echo "${id} cat ${wav} | sox -t wav - -c 1 -b 16 -t wav - rate ${fs} |" >> "${scp}"
# parse start and end time from HTS-style mono label idx=1 while true; do next_idx=$((idx+1)) next_symbol=$(sed -n "${next_idx}p" "${lab}" | awk '{print $3}') if [ "${next_symbol}" != "pau" ]; then start_nsec=$(sed -n "${idx}p" "${lab}" | awk '{print $2}') break fi idx=${next_idx} done idx=$(wc -l < "${lab}") while true; do prev_idx=$((idx-1)) prev_symbol=$(sed -n "${prev_idx}p" "${lab}" | awk '{print $3}') if [ "${prev_symbol}" != "pau" ]; then end_nsec=$(sed -n "${idx}p" "${lab}" | awk '{print $1}') break fi idx=${prev_idx} done start_sec=$(echo "${start_nsec}*0.0000001" | bc | sed "s/^\./0./") end_sec=$(echo "${end_nsec}*0.0000001" | bc | sed "s/^\./0./") echo "${id} ${id} ${start_sec} ${end_sec}" >> "${segments}"done
# splitnum_all=$(wc -l < "${scp}")num_deveval=$((num_dev + num_eval))num_train=$((num_all - num_deveval))utils/split_data.sh \ --num_first "${num_train}" \ --num_second "${num_deveval}" \ --shuffle "${shuffle}" \ "${data_dir}/all" \ "${data_dir}/${train_set}" \ "${data_dir}/deveval"utils/split_data.sh \ --num_first "${num_dev}" \ --num_second "${num_eval}" \ --shuffle "${shuffle}" \ "${data_dir}/deveval" \ "${data_dir}/${dev_set}" \ "${data_dir}/${eval_set}"
# remove tmp directoriesrm -rf "${data_dir}/all"rm -rf "${data_dir}/deveval"
echo "Successfully prepared data."123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174#!/usr/bin/env python3# -*- coding: utf-8 -*-
# Copyright 2019 Tomoki Hayashi# MIT License (https://opensource.org/licenses/MIT)
"""Decode text with trained VQ-VAE Generator or discrete symbol vocoder."""
import argparseimport loggingimport osimport time
import parallel_wavegan.modelsimport soundfile as sfimport torchimport yamlfrom parallel_wavegan.utils import load_modelfrom tqdm import tqdm
def main(): """Run decoding process.""" parser = argparse.ArgumentParser( description=( "Decode text with trained VQ-VAE decoder " "(See detail in parallel_wavegan/bin/decode.py)." ) ) parser.add_argument( "--text", required=True, type=str, help="kaldi-style text file.", ) parser.add_argument( "--utt2spk", default=None, type=str, help="kaldi-style utt2spk file.", ) parser.add_argument( "--spk2idx", default=None, type=str, help="kaldi-style spk2idx file.", ) parser.add_argument( "--outdir", type=str, required=True, help="directory to save generated speech.", ) parser.add_argument( "--checkpoint", type=str, required=True, help="checkpoint file to be loaded.", ) parser.add_argument( "--config", default=None, type=str, help=( "yaml format configuration file. if not explicitly provided, " "it will be searched in the checkpoint directory. (default=None)" ), ) parser.add_argument( "--verbose", type=int, default=1, help="logging level. higher is more logging. (default=1)", ) args = parser.parse_args()
# set logger if args.verbose > 1: logging.basicConfig( level=logging.DEBUG, format="%(asctime)s (%(module)s:%(lineno)d) %(levelname)s: %(message)s", ) elif args.verbose > 0: logging.basicConfig( level=logging.INFO, format="%(asctime)s (%(module)s:%(lineno)d) %(levelname)s: %(message)s", ) else: logging.basicConfig( level=logging.WARN, format="%(asctime)s (%(module)s:%(lineno)d) %(levelname)s: %(message)s", ) logging.warning("Skip DEBUG/INFO messages")
# check directory existence if not os.path.exists(args.outdir): os.makedirs(args.outdir)
# load config if args.config is None: dirname = os.path.dirname(args.checkpoint) args.config = os.path.join(dirname, "config.yml") with open(args.config) as f: config = yaml.load(f, Loader=yaml.Loader) config.update(vars(args))
# setup model if torch.cuda.is_available(): device = torch.device("cuda") else: device = torch.device("cpu") model = load_model(args.checkpoint, config) logging.info(f"Loaded model parameters from {args.checkpoint}.") model.remove_weight_norm() model = model.eval().to(device) is_vqvae = isinstance(model, parallel_wavegan.models.VQVAE)
# setup dataset with open(args.text) as f: lines = [l_.replace("\n", "") for l_ in f.readlines()] text = {l_.split()[0]: list(map(int, l_.split()[1:])) for l_ in lines}
utt2spk = None if args.utt2spk is not None: assert args.spk2idx is not None with open(args.utt2spk) as f: lines = [l_.replace("\n", "") for l_ in f.readlines()] utt2spk = {l_.split()[0]: str(l_.split()[1]) for l_ in lines} with open(args.spk2idx) as f: lines = [l_.replace("\n", "") for l_ in f.readlines()] spk2idx = {l_.split()[0]: int(l_.split()[1]) for l_ in lines}
# start generation total_rtf = 0.0 with torch.no_grad(), tqdm(text.items(), desc="[decode]") as pbar: for idx, items in enumerate(pbar, 1): utt_id, indices = items z = torch.LongTensor(indices).view(1, -1).to(device) g = None if utt2spk is not None: spk_idx = spk2idx[utt2spk[utt_id]] g = torch.tensor(spk_idx).long().view(1).to(device) if is_vqvae: # VQVAE case start = time.time() y = model.decode(z, None, g).view(-1).cpu().numpy() rtf = (time.time() - start) / (len(y) / config["sampling_rate"]) pbar.set_postfix({"RTF": rtf}) total_rtf += rtf else: # Discrete symbol vocoder case start = time.time() g = int(g.item()) if g is not None else None y = model.inference(z.view(-1, 1), g=g).view(-1).cpu().numpy() rtf = (time.time() - start) / (len(y) / config["sampling_rate"]) pbar.set_postfix({"RTF": rtf}) total_rtf += rtf
# save as PCM 16 bit wav file sf.write( os.path.join(config["outdir"], f"{utt_id}_gen.wav"), y, config["sampling_rate"], "PCM_16", )
# report average RTF logging.info( f"Finished generation of {idx} utterances (RTF = {total_rtf / idx:.03f})." )
if __name__ == "__main__": main()123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249#!/usr/bin/env python3# -*- coding: utf-8 -*-
# Copyright 2019 Tomoki Hayashi# MIT License (https://opensource.org/licenses/MIT)
"""Perform preprocessing and raw feature extraction."""
import argparseimport loggingimport os
import librosaimport numpy as npimport resampyimport soundfile as sfimport yamlfrom parallel_wavegan.datasets import AudioDataset, AudioSCPDatasetfrom parallel_wavegan.utils import write_hdf5from tqdm import tqdm
def main(): """Run preprocessing process.""" parser = argparse.ArgumentParser( description=( "Preprocess audio and then extract features (See detail in" " parallel_wavegan/bin/preprocess.py)." ) ) parser.add_argument( "--wav-scp", "--scp", default=None, type=str, help="kaldi-style wav.scp file. you need to specify either scp or rootdir.", ) parser.add_argument( "--segments", default=None, type=str, help=( "kaldi-style segments file. if use, you must to specify both scp and" " segments." ), ) parser.add_argument( "--text", default=None, type=str, help="kaldi-style text format hubert embedding index.", ) parser.add_argument( "--utt2spk", default=None, type=str, help=( "kaldi-style utt2spk file. If you want to add global conditionning with " "speaker id, you need to specify this argument." ), ) parser.add_argument( "--spk2idx", default=None, type=str, help=( "kaldi-style spk2idx file. If you want to add global conditionning with " "speaker id, you need to specify this argument." ), ) parser.add_argument( "--rootdir", default=None, type=str, help=( "directory including wav files. you need to specify either scp or rootdir." ), ) parser.add_argument( "--dumpdir", type=str, required=True, help="directory to dump feature files.", ) parser.add_argument( "--config", type=str, required=True, help="yaml format configuration file.", ) parser.add_argument( "--verbose", type=int, default=1, help="logging level. higher is more logging. (default=1)", ) args = parser.parse_args()
# set logger if args.verbose > 1: logging.basicConfig( level=logging.DEBUG, format="%(asctime)s (%(module)s:%(lineno)d) %(levelname)s: %(message)s", ) elif args.verbose > 0: logging.basicConfig( level=logging.INFO, format="%(asctime)s (%(module)s:%(lineno)d) %(levelname)s: %(message)s", ) else: logging.basicConfig( level=logging.WARN, format="%(asctime)s (%(module)s:%(lineno)d) %(levelname)s: %(message)s", ) logging.warning("Skip DEBUG/INFO messages")
# load config with open(args.config) as f: config = yaml.load(f, Loader=yaml.Loader) config.update(vars(args))
# check arguments if (args.wav_scp is not None and args.rootdir is not None) or ( args.wav_scp is None and args.rootdir is None ): raise ValueError("Please specify either --rootdir or --wav-scp.")
# get dataset if args.rootdir is not None: dataset = AudioDataset( args.rootdir, "*.wav", audio_load_fn=sf.read, return_utt_id=True, ) else: dataset = AudioSCPDataset( args.wav_scp, segments=args.segments, return_utt_id=True, return_sampling_rate=True, )
# get text with open(args.text) as f: lines = [line.strip() for line in f.readlines()] text = { line.split(maxsplit=1)[0]: line.split(maxsplit=1)[1].split() for line in lines }
# load spk2utt file if args.utt2spk is not None: with open(args.utt2spk) as f: lines = [l.replace("\n", "") for l in f.readlines()] utt2spk = {l.split()[0]: l.split()[1] for l in lines} with open(args.spk2idx) as f: lines = [l.replace("\n", "") for l in f.readlines()] spk2idx = {l.split()[0]: int(l.split()[1]) for l in lines}
# check directly existence if not os.path.exists(args.dumpdir): os.makedirs(args.dumpdir, exist_ok=True)
# process each data for utt_id, (audio, fs) in tqdm(dataset): # check assert len(audio.shape) == 1, f"{utt_id} seems to be multi-channel signal." assert ( np.abs(audio).max() <= 1.0 ), f"{utt_id} seems to be different from 16 bit PCM."
# downsample if fs != config["sampling_rate"]: audio = resampy.resample(audio, fs, config["sampling_rate"], axis=0)
# trim silence if config["trim_silence"]: audio, _ = librosa.effects.trim( audio, top_db=config["trim_threshold_in_db"], frame_length=config["trim_frame_size"], hop_length=config["trim_hop_size"], )
# use hubert index instead of mel mel = np.array(text[utt_id]).astype(np.int64).reshape(-1, 1)
if args.spk2idx is not None: spk = utt2spk[utt_id] if spk in spk2idx: idx = spk2idx[spk] else: logging.warn(f"{spk} is unknown speaker.") max_idx = max(spk2idx.values()) + 1 idx = max_idx
# concatenate with mel idx = np.repeat(np.array(idx).reshape(1, 1), len(mel), axis=0) mel = np.concatenate([mel, idx], axis=1)
# make sure the audio length and feature length are matched logging.info(f"Mod: {len(audio) - len(mel) * config['hop_size']}") if len(mel) * config["hop_size"] <= len(audio): logging.warning( "len(mel) * config['hop_size'] <= len(audio), may be errors" ) mel = mel[: len(audio) // config["hop_size"]] audio = audio[: len(mel) * config["hop_size"]] assert len(mel) * config["hop_size"] == len(audio)
# apply global gain if config["global_gain_scale"] > 0.0: audio *= config["global_gain_scale"] if np.abs(audio).max() >= 1.0: logging.warn( f"{utt_id} causes clipping. " "it is better to re-consider global gain scale." ) continue
# save if config["format"] == "hdf5": write_hdf5( os.path.join(args.dumpdir, f"{utt_id}.h5"), "wave", audio.astype(np.float32), ) write_hdf5( os.path.join(args.dumpdir, f"{utt_id}.h5"), "feats", mel.astype(np.float32), ) elif config["format"] == "npy": np.save( os.path.join(args.dumpdir, f"{utt_id}-wave.npy"), audio.astype(np.float32), allow_pickle=False, ) np.save( os.path.join(args.dumpdir, f"{utt_id}-feats.npy"), mel.astype(np.float32), allow_pickle=False, ) else: raise ValueError("support only hdf5 or npy format.")
if __name__ == "__main__": main()123456789101112131415161718192021222324252627282930313233# cuda relatedexport CUDA_HOME=/usr/local/cuda-11.3export LD_LIBRARY_PATH="${CUDA_HOME}/lib64:${LD_LIBRARY_PATH}"
# path relatedexport PRJ_ROOT="${PWD}/../../.."if [ -e "${PRJ_ROOT}/tools/venv/bin/activate" ]; then # shellcheck disable=SC1090 . "${PRJ_ROOT}/tools/venv/bin/activate"fi
# python relatedexport OMP_NUM_THREADS=1export PYTHONIOENCODING=UTF-8export MPL_BACKEND=Agg
# check installationif ! command -v parallel-wavegan-train > /dev/null; then echo "Error: It seems setup is not finished." >&2 echo "Error: Please setup your environment by following README.md" >&2 return 1fiif ! command -v jq > /dev/null; then echo "Error: It seems jq is not installed." >&2 echo "Error: Please install via \`sudo apt-get install jq\`." >&2 echo "Error: If you do not have sudo, please download from https://stedolan.github.io/jq/download/." >&2 return 1fiif ! command -v yq > /dev/null; then echo "Error: It seems yq is not installed." >&2 echo "Error: Please install via \`pip install yq\`." >&2 return 1fi123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188#!/bin/bash
# Copyright 2020 Tomoki Hayashi# MIT License (https://opensource.org/licenses/MIT)
. ./cmd.sh || exit 1;. ./path.sh || exit 1;
# basic settingsstage=-1 # stage to startstop_stage=100 # stage to stopverbose=1 # verbosity level (lower is less info)n_gpus=1 # number of gpus in trainingn_jobs=16 # number of parallel jobs in feature extraction
# NOTE(kan-bayashi): renamed to conf to avoid conflict in parse_options.shconf=conf/parallel_wavegan.v1.yaml
# speaker settingspks="all" # all or you can choose speakers e.g., "p225 p226 p227 ..."
# directory path settingdownload_dir=downloads # directory to save databasedumpdir=dump # directory to dump features
# training related settingtag="" # tag for directory to save modelresume="" # checkpoint path to resume training # (e.g. <path>/<to>/checkpoint-10000steps.pkl)
# decoding related settingcheckpoint="" # checkpoint path to be used for decoding # if not provided, the latest one will be used # (e.g. <path>/<to>/checkpoint-400000steps.pkl)
# shellcheck disable=SC1091. utils/parse_options.sh || exit 1;
train_set="train_nodev_$(echo "${spks}" | tr " " "_")" # name of training data directorydev_set="dev_$(echo "${spks}" | tr " " "_")" # name of development data directoryeval_set="eval_$(echo "${spks}" | tr " " "_")" # name of evaluation data directory
set -euo pipefail
if [ "${stage}" -le -1 ] && [ "${stop_stage}" -ge -1 ]; then echo "Stage -1: Data download" local/data_download.sh "${download_dir}"fi
if [ "${stage}" -le 0 ] && [ "${stop_stage}" -ge 0 ]; then echo "Stage 0: Data preparation" train_data_dirs="" dev_data_dirs="" eval_data_dirs="" # if set to "all", use all of the speakers in the corpus if [ "${spks}" = "all" ]; then # NOTE(kan-bayashi): p315 will not be used since it lacks txt data spks=$(find "${download_dir}/VCTK-Corpus/wav48" \ -maxdepth 1 -name "p*" -exec basename {} \; | sort | grep -v p315) fi for spk in ${spks}; do local/data_prep.sh \ --fs "$(yq ".sampling_rate" "${conf}")" \ --train_set "train_nodev_${spk}" \ --dev_set "dev_${spk}" \ --eval_set "eval_${spk}" \ "${download_dir}/VCTK-Corpus" "${spk}" data train_data_dirs+=" data/train_nodev_${spk}" dev_data_dirs+=" data/dev_${spk}" eval_data_dirs+=" data/eval_${spk}" done # shellcheck disable=SC2086 utils/combine_data.sh "data/${train_set}" ${train_data_dirs} # shellcheck disable=SC2086 utils/combine_data.sh "data/${dev_set}" ${dev_data_dirs} # shellcheck disable=SC2086 utils/combine_data.sh "data/${eval_set}" ${eval_data_dirs}fi
stats_ext=$(grep -q "hdf5" <(yq ".format" "${conf}") && echo "h5" || echo "npy")if [ "${stage}" -le 1 ] && [ "${stop_stage}" -ge 1 ]; then echo "Stage 1: Feature extraction" # extract raw features pids=() for name in "${train_set}" "${dev_set}" "${eval_set}"; do ( [ ! -e "${dumpdir}/${name}/raw" ] && mkdir -p "${dumpdir}/${name}/raw" echo "Feature extraction start. See the progress via ${dumpdir}/${name}/raw/preprocessing.*.log." utils/make_subset_data.sh "data/${name}" "${n_jobs}" "${dumpdir}/${name}/raw" ${train_cmd} JOB=1:${n_jobs} "${dumpdir}/${name}/raw/preprocessing.JOB.log" \ parallel-wavegan-preprocess \ --config "${conf}" \ --scp "${dumpdir}/${name}/raw/wav.JOB.scp" \ --segments "${dumpdir}/${name}/raw/segments.JOB" \ --dumpdir "${dumpdir}/${name}/raw/dump.JOB" \ --verbose "${verbose}" echo "Successfully finished feature extraction of ${name} set." ) & pids+=($!) done i=0; for pid in "${pids[@]}"; do wait "${pid}" || ((++i)); done [ "${i}" -gt 0 ] && echo "$0: ${i} background jobs are failed." && exit 1; echo "Successfully finished feature extraction."
# calculate statistics for normalization echo "Statistics computation start. See the progress via ${dumpdir}/${train_set}/compute_statistics.log." ${train_cmd} "${dumpdir}/${train_set}/compute_statistics.log" \ parallel-wavegan-compute-statistics \ --config "${conf}" \ --rootdir "${dumpdir}/${train_set}/raw" \ --dumpdir "${dumpdir}/${train_set}" \ --verbose "${verbose}" echo "Successfully finished calculation of statistics."
# normalize and dump them pids=() for name in "${train_set}" "${dev_set}" "${eval_set}"; do ( [ ! -e "${dumpdir}/${name}/norm" ] && mkdir -p "${dumpdir}/${name}/norm" echo "Nomalization start. See the progress via ${dumpdir}/${name}/norm/normalize.*.log." ${train_cmd} JOB=1:${n_jobs} "${dumpdir}/${name}/norm/normalize.JOB.log" \ parallel-wavegan-normalize \ --config "${conf}" \ --stats "${dumpdir}/${train_set}/stats.${stats_ext}" \ --rootdir "${dumpdir}/${name}/raw/dump.JOB" \ --dumpdir "${dumpdir}/${name}/norm/dump.JOB" \ --verbose "${verbose}" echo "Successfully finished normalization of ${name} set." ) & pids+=($!) done i=0; for pid in "${pids[@]}"; do wait "${pid}" || ((++i)); done [ "${i}" -gt 0 ] && echo "$0: ${i} background jobs are failed." && exit 1; echo "Successfully finished normalization."fi
if [ -z "${tag}" ]; then expdir="exp/${train_set}_vctk_$(basename "${conf}" .yaml)"else expdir="exp/${train_set}_vctk_${tag}"fiif [ "${stage}" -le 2 ] && [ "${stop_stage}" -ge 2 ]; then echo "Stage 2: Network training" [ ! -e "${expdir}" ] && mkdir -p "${expdir}" cp "${dumpdir}/${train_set}/stats.${stats_ext}" "${expdir}" if [ "${n_gpus}" -gt 1 ]; then train="python -m parallel_wavegan.distributed.launch --nproc_per_node ${n_gpus} -c parallel-wavegan-train" else train="parallel-wavegan-train" fi echo "Training start. See the progress via ${expdir}/train.log." ${cuda_cmd} --gpu "${n_gpus}" "${expdir}/train.log" \ ${train} \ --config "${conf}" \ --train-dumpdir "${dumpdir}/${train_set}/norm" \ --dev-dumpdir "${dumpdir}/${dev_set}/norm" \ --outdir "${expdir}" \ --resume "${resume}" \ --verbose "${verbose}" echo "Successfully finished training."fi
if [ "${stage}" -le 3 ] && [ "${stop_stage}" -ge 3 ]; then echo "Stage 3: Network decoding" # shellcheck disable=SC2012 [ -z "${checkpoint}" ] && checkpoint="$(ls -dt "${expdir}"/*.pkl | head -1 || true)" outdir="${expdir}/wav/$(basename "${checkpoint}" .pkl)" pids=() for name in "${dev_set}" "${eval_set}"; do ( [ ! -e "${outdir}/${name}" ] && mkdir -p "${outdir}/${name}" [ "${n_gpus}" -gt 1 ] && n_gpus=1 echo "Decoding start. See the progress via ${outdir}/${name}/decode.log." ${cuda_cmd} --gpu "${n_gpus}" "${outdir}/${name}/decode.log" \ parallel-wavegan-decode \ --dumpdir "${dumpdir}/${name}/norm" \ --checkpoint "${checkpoint}" \ --outdir "${outdir}/${name}" \ --verbose "${verbose}" echo "Successfully finished decoding of ${name} set." ) & pids+=($!) done i=0; for pid in "${pids[@]}"; do wait "${pid}" || ((++i)); done [ "${i}" -gt 0 ] && echo "$0: ${i} background jobs are failed." && exit 1; echo "Successfully finished decoding."fiecho "Finished."12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091# ====== About run.pl, queue.pl, slurm.pl, and ssh.pl ======# Usage: <cmd>.pl [options] JOB=1:<nj> <log> <command...># e.g.# run.pl --mem 4G JOB=1:10 echo.JOB.log echo JOB## Options:# --time <time>: Limit the maximum time to execute.# --mem <mem>: Limit the maximum memory usage.# -–max-jobs-run <njob>: Limit the number parallel jobs. This is ignored for non-array jobs.# --num-threads <ngpu>: Specify the number of CPU core.# --gpu <ngpu>: Specify the number of GPU devices.# --config: Change the configuration file from default.## "JOB=1:10" is used for "array jobs" and it can control the number of parallel jobs.# The left string of "=", i.e. "JOB", is replaced by <N>(Nth job) in the command and the log file name,# e.g. "echo JOB" is changed to "echo 3" for the 3rd job and "echo 8" for 8th job respectively.# Note that the number must start with a positive number, so you can't use "JOB=0:10" for example.## run.pl, queue.pl, slurm.pl, and ssh.pl have unified interface, not depending on its backend.# These options are mapping to specific options for each backend and# it is configured by "conf/queue.conf" and "conf/slurm.conf" by default.# If jobs failed, your configuration might be wrong for your environment.### The official documentaion for run.pl, queue.pl, slurm.pl, and ssh.pl:# "Parallelization in Kaldi": http://kaldi-asr.org/doc/queue.html# =========================================================~
# Select the backend used by run.sh from "local", "stdout", "sge", "slurm", or "ssh"cmd_backend="local"
# Local machine, without any Job scheduling systemif [ "${cmd_backend}" = local ]; then
# The other usage export train_cmd="utils/run.pl" # Used for "*_train.py": "--gpu" is appended optionally by run.sh export cuda_cmd="utils/run.pl" # Used for "*_recog.py" export decode_cmd="utils/run.pl"
# Local machine, without any Job scheduling systemelif [ "${cmd_backend}" = stdout ]; then
# The other usage export train_cmd="utils/stdout.pl" # Used for "*_train.py": "--gpu" is appended optionally by run.sh export cuda_cmd="utils/stdout.pl" # Used for "*_recog.py" export decode_cmd="utils/stdout.pl"
# "qsub" (SGE, Torque, PBS, etc.)elif [ "${cmd_backend}" = sge ]; then # The default setting is written in conf/queue.conf. # You must change "-q g.q" for the "queue" for your environment. # To know the "queue" names, type "qhost -q" # Note that to use "--gpu *", you have to setup "complex_value" for the system scheduler.
export train_cmd="utils/queue.pl" export cuda_cmd="utils/queue.pl" export decode_cmd="utils/queue.pl"
# "sbatch" (Slurm)elif [ "${cmd_backend}" = slurm ]; then # The default setting is written in conf/slurm.conf. # You must change "-p cpu" and "-p gpu" for the "partion" for your environment. # To know the "partion" names, type "sinfo". # You can use "--gpu * " by defualt for slurm and it is interpreted as "--gres gpu:*" # The devices are allocated exclusively using "${CUDA_VISIBLE_DEVICES}".
export train_cmd="utils/slurm.pl" export cuda_cmd="utils/slurm.pl" export decode_cmd="utils/slurm.pl"
elif [ "${cmd_backend}" = ssh ]; then # You have to create ".queue/machines" to specify the host to execute jobs. # e.g. .queue/machines # host1 # host2 # host3 # Assuming you can login them without any password, i.e. You have to set ssh keys.
export train_cmd="utils/ssh.pl" export cuda_cmd="utils/ssh.pl" export decode_cmd="utils/ssh.pl"
else echo "$0: Error: Unknown cmd_backend=${cmd_backend}" 1>&2 return 1fi123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130############################################################ THIS IS EXPERIMENTAL CONFIGURATION! BE CAREFUL! ############################################################# This is the hyperparameter configuration file for VQ-VAE MelGAN.# Please make sure this is adjusted for the LJSpeech dataset. If you want to# apply to the other dataset, you might need to carefully change some parameters.# This configuration performs 5M iters and it requires ~4 GB GPU memory and# takes ~8 days on TITAN V.
############################################################ FEATURE EXTRACTION SETTING ############################################################sampling_rate: 24000 # Sampling rate.global_gain_scale: 1.0 # Will be multiplied to all of waveform.trim_silence: true # Whether to trim the start and end of silence.trim_threshold_in_db: 20 # Need to tune carefully if the recording is not good.trim_frame_size: 1024 # Frame size in trimming.trim_hop_size: 256 # Hop size in trimming.use_global_condition: true # Whether to use global conditioning.format: "hdf5" # Feature file format. "npy" or "hdf5" is supported.
############################################################ GENERATOR NETWORK ARCHITECTURE SETTING ############################################################generator_type: "VQVAE" # Generator type.generator_params: in_channels: 1 # Number of input channels. out_channels: 1 # Number of output channels. num_embeds: 512 # Number of embeddings. embed_dim: 256 # Dimension of each emebedding. num_global_embeds: 128 # Number of global embeddings. global_embed_dim: 128 # Dimension of each global embedding. encoder_type: "MelGANDiscriminator" # Encoder type. decoder_type: "MelGANGenerator" # Decoder type. encoder_conf: "out_channels": 256 # Must be the same as embed dim "downsample_scales": [4, 4, 2, 2] "max_downsample_channels": 1024 decoder_conf: "in_channels": 384 # Must be the same as embed dim "upsample_scales": [4, 4, 2, 2] "channels": 512 "stacks": 3
############################################################ DISCRIMINATOR NETWORK ARCHITECTURE SETTING ############################################################discriminator_type: "MelGANMultiScaleDiscriminator" # Discriminator type.discriminator_params: in_channels: 1 # Number of input channels. out_channels: 1 # Number of output channels. scales: 3 # Number of multi-scales. downsample_pooling: "AvgPool1d" # Pooling type for the input downsampling. downsample_pooling_params: # Parameters of the above pooling function. kernel_size: 4 stride: 2 padding: 1 count_include_pad: False kernel_sizes: [5, 3] # List of kernel size. channels: 16 # Number of channels of the initial conv layer. max_downsample_channels: 1024 # Maximum number of channels of downsampling layers. downsample_scales: [4, 4, 4, 4] # List of downsampling scales. nonlinear_activation: "LeakyReLU" # Nonlinear activation function. nonlinear_activation_params: # Parameters of nonlinear activation function. negative_slope: 0.2 use_weight_norm: True # Whether to use weight norm.
############################################################ STFT LOSS SETTING ############################################################stft_loss_params: fft_sizes: [1024, 2048, 512] # List of FFT size for STFT-based loss. hop_sizes: [120, 240, 50] # List of hop size for STFT-based loss win_lengths: [600, 1200, 240] # List of window length for STFT-based loss. window: "hann_window" # Window function for STFT-based loss
############################################################ ADVERSARIAL LOSS SETTING ############################################################use_feat_match_loss: truelambda_commit: 0.25lambda_feat_match: 25.0lambda_adv: 4.0lambda_aux_after_introduce_adv_loss: 1.0
############################################################ DATA LOADER SETTING ############################################################batch_size: 16 # Batch size.batch_max_steps: 8192 # Length of each audio in batch. Make sure dividable by hop_size.pin_memory: true # Whether to pin memory in Pytorch DataLoader.num_workers: 2 # Number of workers in Pytorch DataLoader.remove_short_samples: false # Whether to remove samples the length of which are less than batch_max_steps.allow_cache: true # Whether to allow cache in dataset. If true, it requires cpu memory.
############################################################ OPTIMIZER & SCHEDULER SETTING ############################################################generator_optimizer_params: lr: 0.0001 # Generator's learning rate. eps: 1.0e-6 # Generator's epsilon. weight_decay: 0.0 # Generator's weight decay coefficient.generator_scheduler_params: step_size: 5000000 # Generator's scheduler step size. gamma: 0.5 # Generator's scheduler gamma. # At each step size, lr will be multiplied by this parameter.generator_grad_norm: 10 # Generator's gradient norm.discriminator_optimizer_params: lr: 0.00005 # Discriminator's learning rate. eps: 1.0e-6 # Discriminator's epsilon. weight_decay: 0.0 # Discriminator's weight decay coefficient.discriminator_scheduler_params: step_size: 5000000 # Discriminator's scheduler step size. gamma: 0.5 # Discriminator's scheduler gamma. # At each step size, lr will be multiplied by this parameter.discriminator_grad_norm: 1 # Discriminator's gradient norm.
############################################################ INTERVAL SETTING ############################################################discriminator_train_start_steps: 100000 # Number of steps to start to train discriminator.train_max_steps: 5000000 # Number of training steps.save_interval_steps: 5000 # Interval steps to save checkpoint.eval_interval_steps: 1000 # Interval steps to evaluate the network.log_interval_steps: 100 # Interval steps to record the training log.
############################################################ OTHER SETTING ############################################################num_save_intermediate_results: 4 # Number of results to be saved as intermediate results.123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134############################################################ THIS IS EXPERIMENTAL CONFIGURATION! BE CAREFUL! ############################################################# This is the hyperparameter configuration file for VQ-VAE MelGAN.# Please make sure this is adjusted for the LJSpeech dataset. If you want to# apply to the other dataset, you might need to carefully change some parameters.# This configuration performs 5M iters and it requires ~4 GB GPU memory and# takes ~8 days on TITAN V.
############################################################ FEATURE EXTRACTION SETTING ############################################################sampling_rate: 24000 # Sampling rate.hop_size: 64 # Hop size.global_gain_scale: 1.0 # Will be multiplied to all of waveform.trim_silence: true # Whether to trim the start and end of silence.trim_threshold_in_db: 20 # Need to tune carefully if the recording is not good.trim_frame_size: 1024 # Frame size in trimming.trim_hop_size: 256 # Hop size in trimming.use_global_condition: true # Whether to use global conditioning.use_local_condition: true # Whether to use local conditioning.format: "hdf5" # Feature file format. "npy" or "hdf5" is supported.
############################################################ GENERATOR NETWORK ARCHITECTURE SETTING ############################################################generator_type: "VQVAE" # Generator type.generator_params: in_channels: 1 # Number of input channels. out_channels: 1 # Number of output channels. num_embeds: 512 # Number of embeddings. embed_dim: 256 # Dimension of each emebedding. num_local_embeds: 2 # Number of local embeddings. local_embed_dim: 32 # Dimension of each local embedding. num_global_embeds: 128 # Number of global embeddings. global_embed_dim: 128 # Dimension of each global embedding. encoder_type: "MelGANDiscriminator" # Encoder type. decoder_type: "MelGANGenerator" # Decoder type. encoder_conf: "out_channels": 256 # Must be the same as embed dim "downsample_scales": [4, 4, 2, 2] "max_downsample_channels": 1024 decoder_conf: "in_channels": 416 # Must be the same as embed + local embed + global embed dim "upsample_scales": [4, 4, 2, 2] "channels": 512 "stacks": 3
############################################################ DISCRIMINATOR NETWORK ARCHITECTURE SETTING ############################################################discriminator_type: "MelGANMultiScaleDiscriminator" # Discriminator type.discriminator_params: in_channels: 1 # Number of input channels. out_channels: 1 # Number of output channels. scales: 3 # Number of multi-scales. downsample_pooling: "AvgPool1d" # Pooling type for the input downsampling. downsample_pooling_params: # Parameters of the above pooling function. kernel_size: 4 stride: 2 padding: 1 count_include_pad: False kernel_sizes: [5, 3] # List of kernel size. channels: 16 # Number of channels of the initial conv layer. max_downsample_channels: 1024 # Maximum number of channels of downsampling layers. downsample_scales: [4, 4, 4, 4] # List of downsampling scales. nonlinear_activation: "LeakyReLU" # Nonlinear activation function. nonlinear_activation_params: # Parameters of nonlinear activation function. negative_slope: 0.2 use_weight_norm: True # Whether to use weight norm.
############################################################ STFT LOSS SETTING ############################################################stft_loss_params: fft_sizes: [1024, 2048, 512] # List of FFT size for STFT-based loss. hop_sizes: [120, 240, 50] # List of hop size for STFT-based loss win_lengths: [600, 1200, 240] # List of window length for STFT-based loss. window: "hann_window" # Window function for STFT-based loss
############################################################ ADVERSARIAL LOSS SETTING ############################################################use_feat_match_loss: truelambda_commit: 0.25lambda_feat_match: 25.0lambda_adv: 4.0lambda_aux_after_introduce_adv_loss: 1.0
############################################################ DATA LOADER SETTING ############################################################batch_size: 16 # Batch size.batch_max_steps: 8192 # Length of each audio in batch. Make sure dividable by hop_size.pin_memory: true # Whether to pin memory in Pytorch DataLoader.num_workers: 2 # Number of workers in Pytorch DataLoader.remove_short_samples: false # Whether to remove samples the length of which are less than batch_max_steps.allow_cache: true # Whether to allow cache in dataset. If true, it requires cpu memory.
############################################################ OPTIMIZER & SCHEDULER SETTING ############################################################generator_optimizer_params: lr: 0.0001 # Generator's learning rate. eps: 1.0e-6 # Generator's epsilon. weight_decay: 0.0 # Generator's weight decay coefficient.generator_scheduler_params: step_size: 5000000 # Generator's scheduler step size. gamma: 0.5 # Generator's scheduler gamma. # At each step size, lr will be multiplied by this parameter.generator_grad_norm: 10 # Generator's gradient norm.discriminator_optimizer_params: lr: 0.00005 # Discriminator's learning rate. eps: 1.0e-6 # Discriminator's epsilon. weight_decay: 0.0 # Discriminator's weight decay coefficient.discriminator_scheduler_params: step_size: 5000000 # Discriminator's scheduler step size. gamma: 0.5 # Discriminator's scheduler gamma. # At each step size, lr will be multiplied by this parameter.discriminator_grad_norm: 1 # Discriminator's gradient norm.
############################################################ INTERVAL SETTING ############################################################discriminator_train_start_steps: 100000 # Number of steps to start to train discriminator.train_max_steps: 5000000 # Number of training steps.save_interval_steps: 5000 # Interval steps to save checkpoint.eval_interval_steps: 1000 # Interval steps to evaluate the network.log_interval_steps: 100 # Interval steps to record the training log.
############################################################ OTHER SETTING ############################################################num_save_intermediate_results: 4 # Number of results to be saved as intermediate results.123456789101112# Default configurationcommand sbatch --export=PATH --ntasks-per-node=1option time=* --time $0option mem=* --mem-per-cpu $0option mem=0 # Do not add anything to qsub_optsoption num_threads=* --cpus-per-task $0 --ntasks-per-node=1option num_threads=1 --cpus-per-task 1 --ntasks-per-node=1 # Do not add anything to qsub_optsdefault gpu=0option gpu=0 -p cpuoption gpu=* -p gpu --gres=gpu:$0# note: the --max-jobs-run option is supported as a special case# by slurm.pl and you don't have to handle it in the config file.12345678910111213141516171819202122232425262728293031323334353637#!/bin/bash
# Copyright 2020 Tomoki Hayashi# MIT License (https://opensource.org/licenses/MIT)
download_dir=$1
# check argumentsif [ $# != 1 ]; then echo "Usage: $0 <download_dir>" exit 1fi
set -euo pipefail
cwd=$(pwd)if [ ! -e "${download_dir}/VCTK-Corpus" ]; then mkdir -p "${download_dir}" cd "${download_dir}" || exit 1; wget http://www.udialogue.org/download/VCTK-Corpus.tar.gz tar xvzf ./VCTK-Corpus.tar.gz rm ./VCTK-Corpus.tar.gz cd "${cwd}" || exit 1; echo "Successfully downloaded data."else echo "Already exists. Skipped."fi
if [ ! -e "${download_dir}/VCTK-Corpus/lab" ]; then cd "${download_dir}" || exit 1; git clone https://github.com/kan-bayashi/VCTKCorpusFullContextLabel.git cp -r VCTKCorpusFullContextLabel/lab ./VCTK-Corpus cd "${cwd}" || exit 1; echo "Successfully downloaded label data."else echo "Already exists. Skipped."fi123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121#!/bin/bash
# Copyright 2020 Tomoki Hayashi# MIT License (https://opensource.org/licenses/MIT)
# shellcheck disable=SC1091. ./path.sh || exit 1;
fs=24000num_dev=10num_eval=10train_set="train_nodev"dev_set="dev"eval_set="eval"shuffle=false
# shellcheck disable=SC1091. utils/parse_options.sh || exit 1;
db_root=$1spk=$2data_dir=$3
# check argumentsif [ $# != 3 ]; then echo "Usage: $0 [Options] <db_root> <spk> <data_dir>" echo "e.g.: $0 downloads/VCTK-Corpus p225 data" echo "" echo "Options:" echo " --fs: sampling frequency (default=24000)." echo " --num_dev: number of development uttreances (default=10)." echo " --num_eval: number of evaluation uttreances (default=10)." echo " --train_set: name of train set (default=train_nodev)." echo " --dev_set: name of dev set (default=dev)." echo " --eval_set: name of eval set (default=eval)." echo " --shuffle: whether to perform shuffle in making dev / eval set (default=false)." exit 1fi
set -euo pipefail
# check spk existence[ ! -e "${db_root}/lab/mono/${spk}" ] && \ echo "${spk} does not exist." >&2 && exit 1;
[ ! -e "${data_dir}/all" ] && mkdir -p "${data_dir}/all"
# set filenamesscp="${data_dir}/all/wav.scp"segments="${data_dir}/all/segments"utt2spk="${data_dir}/all/utt2spk"
# check file existence[ -e "${scp}" ] && rm "${scp}"[ -e "${segments}" ] && rm "${segments}"[ -e "${utt2spk}" ] && rm "${utt2spk}"
# make scp, utt2spk, and segmentsfind "${db_root}/wav48/${spk}" -follow -name "*.wav" | sort | while read -r wav; do id=$(basename "${wav}" | sed -e "s/\.[^\.]*$//g") lab=${db_root}/lab/mono/${spk}/${id}.lab
# check lab existence if [ ! -e "${lab}" ]; then echo "${id} has not label file. skipped." continue fi
echo "${id} cat ${wav} | sox -t wav - -c 1 -b 16 -t wav - rate ${fs} |" >> "${scp}" echo "${id} ${spk}" >> "${utt2spk}"
# parse start and end time from HTS-style mono label idx=1 while true; do next_idx=$((idx+1)) next_symbol=$(sed -n "${next_idx}p" "${lab}" | awk '{print $3}') if [ "${next_symbol}" != "pau" ]; then start_nsec=$(sed -n "${idx}p" "${lab}" | awk '{print $2}') break fi idx=${next_idx} done idx=$(wc -l < "${lab}") while true; do prev_idx=$((idx-1)) prev_symbol=$(sed -n "${prev_idx}p" "${lab}" | awk '{print $3}') if [ "${prev_symbol}" != "pau" ]; then end_nsec=$(sed -n "${idx}p" "${lab}" | awk '{print $1}') break fi idx=${prev_idx} done start_sec=$(echo "${start_nsec}*0.0000001" | bc | sed "s/^\./0./") end_sec=$(echo "${end_nsec}*0.0000001" | bc | sed "s/^\./0./") echo "${id} ${id} ${start_sec} ${end_sec}" >> "${segments}"done
# splitnum_all=$(wc -l < "${scp}")num_deveval=$((num_dev + num_eval))num_train=$((num_all - num_deveval))utils/split_data.sh \ --num_first "${num_train}" \ --num_second "${num_deveval}" \ --shuffle "${shuffle}" \ "${data_dir}/all" \ "${data_dir}/${train_set}" \ "${data_dir}/deveval"utils/split_data.sh \ --num_first "${num_dev}" \ --num_second "${num_eval}" \ --shuffle "${shuffle}" \ "${data_dir}/deveval" \ "${data_dir}/${dev_set}" \ "${data_dir}/${eval_set}"
# remove tmp directoriesrm -rf "${data_dir}/all"rm -rf "${data_dir}/deveval"
echo "Successfully prepared data."123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354#!/bin/bash
# Copyright 2020 Tomoki Hayashi# MIT License (https://opensource.org/licenses/MIT)
# shellcheck disable=SC1091. ./path.sh || exit 1;
# shellcheck disable=SC1091. utils/parse_options.sh || exit 1;
db_root=$1data_dir_root=$2
# check argumentsif [ $# != 2 ]; then echo "Usage: $0 <db_root> <data_dir>" echo "e.g.: $0 downloads/VCTK-Corpus data" exit 1fi
set -euo pipefail
for mix_type in min max; do for dset in tr tt cv; do for src_spk in s1 s2; do echo "${mix_type}_${dset}_${src_spk}" # set filenames data_dir=${data_dir_root}/${mix_type}_${dset}_${src_spk} scp="${data_dir}/wav.scp" utt2spk="${data_dir}/utt2spk"
# check file existence [ ! -e "${data_dir}" ] && mkdir -p "${data_dir}" [ -e "${scp}" ] && rm "${scp}" [ -e "${utt2spk}" ] && rm "${utt2spk}"
# make scp, utt2spk, and segments find "${db_root}/${mix_type}/${dset}/${src_spk}" -follow -name "*.wav" | sort | while read -r wav; do id=$(basename "${wav}" | sed -e "s/\.[^\.]*$//g") if [ ${src_spk} = "s1" ]; then spk=$(echo "${id}" | cut -f 1 -d "_") else spk=$(echo "${id}" | cut -f 4 -d "_") fi echo "${id} ${wav}" >> "${scp}" echo "${id} ${spk}" >> "${utt2spk}" done done donedone
echo "Successfully prepared data."123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174#!/usr/bin/env python3# -*- coding: utf-8 -*-
# Copyright 2019 Tomoki Hayashi# MIT License (https://opensource.org/licenses/MIT)
"""Decode text with trained VQ-VAE Generator or discrete symbol vocoder."""
import argparseimport loggingimport osimport time
import parallel_wavegan.modelsimport soundfile as sfimport torchimport yamlfrom parallel_wavegan.utils import load_modelfrom tqdm import tqdm
def main(): """Run decoding process.""" parser = argparse.ArgumentParser( description=( "Decode text with trained VQ-VAE decoder " "(See detail in parallel_wavegan/bin/decode.py)." ) ) parser.add_argument( "--text", required=True, type=str, help="kaldi-style text file.", ) parser.add_argument( "--utt2spk", default=None, type=str, help="kaldi-style utt2spk file.", ) parser.add_argument( "--spk2idx", default=None, type=str, help="kaldi-style spk2idx file.", ) parser.add_argument( "--outdir", type=str, required=True, help="directory to save generated speech.", ) parser.add_argument( "--checkpoint", type=str, required=True, help="checkpoint file to be loaded.", ) parser.add_argument( "--config", default=None, type=str, help=( "yaml format configuration file. if not explicitly provided, " "it will be searched in the checkpoint directory. (default=None)" ), ) parser.add_argument( "--verbose", type=int, default=1, help="logging level. higher is more logging. (default=1)", ) args = parser.parse_args()
# set logger if args.verbose > 1: logging.basicConfig( level=logging.DEBUG, format="%(asctime)s (%(module)s:%(lineno)d) %(levelname)s: %(message)s", ) elif args.verbose > 0: logging.basicConfig( level=logging.INFO, format="%(asctime)s (%(module)s:%(lineno)d) %(levelname)s: %(message)s", ) else: logging.basicConfig( level=logging.WARN, format="%(asctime)s (%(module)s:%(lineno)d) %(levelname)s: %(message)s", ) logging.warning("Skip DEBUG/INFO messages")
# check directory existence if not os.path.exists(args.outdir): os.makedirs(args.outdir)
# load config if args.config is None: dirname = os.path.dirname(args.checkpoint) args.config = os.path.join(dirname, "config.yml") with open(args.config) as f: config = yaml.load(f, Loader=yaml.Loader) config.update(vars(args))
# setup model if torch.cuda.is_available(): device = torch.device("cuda") else: device = torch.device("cpu") model = load_model(args.checkpoint, config) logging.info(f"Loaded model parameters from {args.checkpoint}.") model.remove_weight_norm() model = model.eval().to(device) is_vqvae = isinstance(model, parallel_wavegan.models.VQVAE)
# setup dataset with open(args.text) as f: lines = [l_.replace("\n", "") for l_ in f.readlines()] text = {l_.split()[0]: list(map(int, l_.split()[1:])) for l_ in lines}
utt2spk = None if args.utt2spk is not None: assert args.spk2idx is not None with open(args.utt2spk) as f: lines = [l_.replace("\n", "") for l_ in f.readlines()] utt2spk = {l_.split()[0]: str(l_.split()[1]) for l_ in lines} with open(args.spk2idx) as f: lines = [l_.replace("\n", "") for l_ in f.readlines()] spk2idx = {l_.split()[0]: int(l_.split()[1]) for l_ in lines}
# start generation total_rtf = 0.0 with torch.no_grad(), tqdm(text.items(), desc="[decode]") as pbar: for idx, items in enumerate(pbar, 1): utt_id, indices = items z = torch.LongTensor(indices).view(1, -1).to(device) g = None if utt2spk is not None: spk_idx = spk2idx[utt2spk[utt_id]] g = torch.tensor(spk_idx).long().view(1).to(device) if is_vqvae: # VQVAE case start = time.time() y = model.decode(z, None, g).view(-1).cpu().numpy() rtf = (time.time() - start) / (len(y) / config["sampling_rate"]) pbar.set_postfix({"RTF": rtf}) total_rtf += rtf else: # Discrete symbol vocoder case start = time.time() g = int(g.item()) if g is not None else None y = model.inference(z.view(-1, 1), g=g).view(-1).cpu().numpy() rtf = (time.time() - start) / (len(y) / config["sampling_rate"]) pbar.set_postfix({"RTF": rtf}) total_rtf += rtf
# save as PCM 16 bit wav file sf.write( os.path.join(config["outdir"], f"{utt_id}_gen.wav"), y, config["sampling_rate"], "PCM_16", )
# report average RTF logging.info( f"Finished generation of {idx} utterances (RTF = {total_rtf / idx:.03f})." )
if __name__ == "__main__": main()123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222#!/usr/bin/env python3# -*- coding: utf-8 -*-
# Copyright 2020 Tomoki Hayashi# MIT License (https://opensource.org/licenses/MIT)
"""Setup features for voice conversion."""
import argparseimport loggingimport os
import numpy as npimport yamlfrom parallel_wavegan.datasets import AudioDatasetfrom parallel_wavegan.utils import read_hdf5, write_hdf5from tqdm import tqdm
def main(): """Run preprocessing process.""" parser = argparse.ArgumentParser( description=( "Normalize dumped raw features (See detail in" " parallel_wavegan/bin/normalize.py)." ) ) parser.add_argument( "--rootdir", default=None, type=str, help=( "directory including feature files to be normalized. " "you need to specify either feats-scp or rootdir." ), ) parser.add_argument( "--feats-scp", default=None, type=str, help=( "kaldi-style feats.scp file. " "you need to specify either feats-scp or rootdir." ), ) parser.add_argument( "--dumpdir", type=str, required=True, help="directory to dump feature files." ) parser.add_argument( "--statdir", type=str, default=None, help="direcotry including statistics files.", ) parser.add_argument( "--utt2spk", default=None, type=str, help="kaldi-style utt2spk file." ) parser.add_argument( "--spk2idx", default=None, type=str, help="kaldi-style spk2idx file." ) parser.add_argument( "--config", type=str, required=True, help="yaml format configuration file." ) parser.add_argument( "--verbose", type=int, default=1, help="logging level. higher is more logging. (default=1)", ) args = parser.parse_args()
# set logger if args.verbose > 1: logging.basicConfig( level=logging.DEBUG, format="%(asctime)s (%(module)s:%(lineno)d) %(levelname)s: %(message)s", ) elif args.verbose > 0: logging.basicConfig( level=logging.INFO, format="%(asctime)s (%(module)s:%(lineno)d) %(levelname)s: %(message)s", ) else: logging.basicConfig( level=logging.WARN, format="%(asctime)s (%(module)s:%(lineno)d) %(levelname)s: %(message)s", ) logging.warning("Skip DEBUG/INFO messages")
# load config with open(args.config) as f: config = yaml.load(f, Loader=yaml.Loader) config.update(vars(args))
# check arguments if (args.feats_scp is not None and args.rootdir is not None) or ( args.feats_scp is None and args.rootdir is None ): raise ValueError("Please specify either --rootdir or --feats-scp.")
# check directory existence if not os.path.exists(args.dumpdir): os.makedirs(args.dumpdir)
# load utt2spk and spk2idx with open(args.utt2spk) as f: lines = [l_.replace("\n", "") for l_ in f.readlines()] utt2spk = {l_.split()[0]: l_.split()[1] for l_ in lines} with open(args.spk2idx) as f: lines = [l_.replace("\n", "") for l_ in f.readlines()] spk2idx = {l_.split()[0]: int(l_.split()[1]) for l_ in lines} spks = list(spk2idx.keys())
# get dataset if args.rootdir is not None: local_query = None local_load_fn = None if config["format"] == "hdf5": audio_query = "*.h5" audio_load_fn = lambda x: read_hdf5(x, "wave") # NOQA if config.get("use_local_condition", False): local_query = "*.h5" local_load_fn = lambda x: read_hdf5(x, "local") # NOQA elif config["format"] == "npy": audio_query = "*-wave.npy" audio_load_fn = np.load if config.get("use_local_condition", False): local_query = "*-local.npy" local_load_fn = np.load else: raise ValueError("support only hdf5 or npy format.") dataset = AudioDataset( root_dir=args.rootdir, audio_query=audio_query, audio_load_fn=audio_load_fn, local_query=local_query, local_load_fn=local_load_fn, return_utt_id=True, ) else: raise NotImplementedError("Not supported.") logging.info(f"The number of files = {len(dataset)}.")
# load statistics if config.get("use_local_condition", False): spk2lf0avg = {} for spk in spks: # FIXME: it is better to remove this hard coding if config["format"] == "hdf5": lf0avg = read_hdf5(f"{args.statdir}/stats.h5", f"{spk}/mean")[0] elif config["format"] == "npy": lf0avg = np.load(f"{args.statdir}/stats-${spk}.h5")[0][0] else: raise ValueError("support only hdf5 or npy format.") spk2lf0avg[spk] = lf0avg
# process each file for items in tqdm(dataset): if config.get("use_local_condition", False): utt_id, audio, l_ = items else: utt_id, audio = items source_spk = utt2spk[utt_id]
# replace global and adjust f0 range for target_spk in spks: if target_spk == source_spk: continue
# adjust f0 range if config.get("use_local_condition", False): l_ = l_.copy() target_lf0avg = spk2lf0avg[target_spk] source_lf0avg = spk2lf0avg[source_spk] l_[:, 0] = l_[:, 0] + target_lf0avg - source_lf0avg
# get global g = np.array(spk2idx[target_spk])
# save if config["format"] == "hdf5": write_hdf5( os.path.join(args.dumpdir, f"{utt_id}_to_{target_spk}.h5"), "wave", audio.astype(np.float32), ) write_hdf5( os.path.join(args.dumpdir, f"{utt_id}_to_{target_spk}.h5"), "global", g.reshape(-1), ) if config.get("use_local_condition", False): write_hdf5( os.path.join(args.dumpdir, f"{utt_id}_to_{target_spk}.h5"), "local", l_.astype(np.float32), ) elif config["format"] == "npy": np.save( os.path.join(args.dumpdir, f"{utt_id}_to_{target_spk}-wave.npy"), audio.astype(np.float32), allow_pickle=False, ) np.save( os.path.join(args.dumpdir, f"{utt_id}_to_{target_spk}-global.npy"), g.reshape(-1), allow_pickle=False, ) if config.get("use_local_condition", False): np.save( os.path.join( args.dumpdir, f"{utt_id}_to_{target_spk}-local.npy" ), l_.astype(np.float32), allow_pickle=False, ) else: raise ValueError("support only hdf5 or npy format.")
if __name__ == "__main__": main()123456789101112131415161718192021222324252627282930313233# cuda relatedexport CUDA_HOME=/usr/local/cuda-11.3export LD_LIBRARY_PATH="${CUDA_HOME}/lib64:${LD_LIBRARY_PATH}"
# path relatedexport PRJ_ROOT="${PWD}/../../.."if [ -e "${PRJ_ROOT}/tools/venv/bin/activate" ]; then # shellcheck disable=SC1090 . "${PRJ_ROOT}/tools/venv/bin/activate"fi
# python relatedexport OMP_NUM_THREADS=1export PYTHONIOENCODING=UTF-8export MPL_BACKEND=Agg
# check installationif ! command -v parallel-wavegan-train > /dev/null; then echo "Error: It seems setup is not finished." >&2 echo "Error: Please setup your environment by following README.md" >&2 return 1fiif ! command -v jq > /dev/null; then echo "Error: It seems jq is not installed." >&2 echo "Error: Please install via \`sudo apt-get install jq\`." >&2 echo "Error: If you do not have sudo, please download from https://stedolan.github.io/jq/download/." >&2 return 1fiif ! command -v yq > /dev/null; then echo "Error: It seems yq is not installed." >&2 echo "Error: Please install via \`pip install yq\`." >&2 return 1fi123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295#!/bin/bash
# Copyright 2020 Tomoki Hayashi# MIT License (https://opensource.org/licenses/MIT)
. ./cmd.sh || exit 1;. ./path.sh || exit 1;
# basic settingsstage=-1 # stage to startstop_stage=100 # stage to stopverbose=1 # verbosity level (lower is less info)n_gpus=1 # number of gpus in trainingn_jobs=16 # number of parallel jobs in feature extraction
# NOTE(kan-bayashi): renamed to conf to avoid conflict in parse_options.shconf=conf/conditioned_melgan_vae.v3.yaml
# speaker settingspks="all" # all or you can choose speakers e.g., "p225 p226 p227 ..."
# directory path settingdownload_dir=downloads # directory to save databasedumpdir=dump # directory to dump features
# training related settingtag="" # tag for directory to save modelresume="" # checkpoint path to resume training # (e.g. <path>/<to>/checkpoint-10000steps.pkl)
# decoding related settingcheckpoint="" # checkpoint path to be used for decoding # if not provided, the latest one will be used # (e.g. <path>/<to>/checkpoint-400000steps.pkl)
# shellcheck disable=SC1091. utils/parse_options.sh || exit 1;
train_set="train_nodev_$(echo "${spks}" | tr " " "_")" # name of training data directorydev_set="dev_$(echo "${spks}" | tr " " "_")" # name of development data directoryeval_set="eval_$(echo "${spks}" | tr " " "_")" # name of evaluation data directory
set -euo pipefail
if [ "${stage}" -le -1 ] && [ "${stop_stage}" -ge -1 ]; then echo "Stage -1: Data download" local/data_download.sh "${download_dir}"fi
if [ "${stage}" -le 0 ] && [ "${stop_stage}" -ge 0 ]; then echo "Stage 0: Data preparation" train_data_dirs="" dev_data_dirs="" eval_data_dirs="" # if set to "all", use all of the speakers in the corpus if [ "${spks}" = "all" ]; then # NOTE(kan-bayashi): p315 will not be used since it lacks txt data spks=$(find "${download_dir}/VCTK-Corpus/wav48" \ -maxdepth 1 -name "p*" -exec basename {} \; | sort | grep -v p315) fi for spk in ${spks}; do local/data_prep.sh \ --fs "$(yq ".sampling_rate" "${conf}")" \ --train_set "train_nodev_${spk}" \ --dev_set "dev_${spk}" \ --eval_set "eval_${spk}" \ "${download_dir}/VCTK-Corpus" "${spk}" data train_data_dirs+=" data/train_nodev_${spk}" dev_data_dirs+=" data/dev_${spk}" eval_data_dirs+=" data/eval_${spk}" done # shellcheck disable=SC2086 utils/combine_data.sh "data/${train_set}" ${train_data_dirs} # shellcheck disable=SC2086 utils/combine_data.sh "data/${dev_set}" ${dev_data_dirs} # shellcheck disable=SC2086 utils/combine_data.sh "data/${eval_set}" ${eval_data_dirs}
# make spk2idx cut -f 2 -d " " "data/${train_set}/utt2spk" | sort | uniq | \ awk '{print $1 " " NR -1}' > "data/${train_set}/spk2idx"fi
stats_ext=$(grep -q "hdf5" <(yq ".format" "${conf}") && echo "h5" || echo "npy")if [ "${stage}" -le 1 ] && [ "${stop_stage}" -ge 1 ]; then echo "Stage 1: Feature extraction" # extract raw features pids=() for name in "${train_set}" "${dev_set}" "${eval_set}"; do ( [ ! -e "${dumpdir}/${name}/raw" ] && mkdir -p "${dumpdir}/${name}/raw" echo "Feature extraction start. See the progress via ${dumpdir}/${name}/raw/preprocessing.*.log." utils/make_subset_data.sh "data/${name}" "${n_jobs}" "${dumpdir}/${name}/raw" if [ "$(yq ".use_local_condition" "${conf}")" = "true" ]; then opts="--extract-f0 --skip-mel-ext" else opts="--skip-mel-ext" fi ${train_cmd} JOB=1:${n_jobs} "${dumpdir}/${name}/raw/preprocessing.JOB.log" \ parallel-wavegan-preprocess \ --config "${conf}" \ --scp "${dumpdir}/${name}/raw/wav.JOB.scp" \ --segments "${dumpdir}/${name}/raw/segments.JOB" \ --utt2spk "${dumpdir}/${name}/raw/utt2spk.JOB" \ --spk2idx "data/${train_set}/spk2idx" \ --dumpdir "${dumpdir}/${name}/raw/dump.JOB" \ --verbose "${verbose}" \ ${opts} echo "Successfully finished feature extraction of ${name} set." ) & pids+=($!) done i=0; for pid in "${pids[@]}"; do wait "${pid}" || ((++i)); done [ "${i}" -gt 0 ] && echo "$0: ${i} background jobs are failed." && exit 1; echo "Successfully finished feature extraction."
if [ "$(yq ".use_local_condition" "${conf}")" = "true" ]; then # calculate statistics for normalization echo "Statistics computation start. See the progress via ${dumpdir}/${train_set}/compute_statistics.log." ${train_cmd} "${dumpdir}/${train_set}/compute_statistics.log" \ parallel-wavegan-compute-statistics \ --config "${conf}" \ --rootdir "${dumpdir}/${train_set}/raw" \ --dumpdir "${dumpdir}/${train_set}" \ --target-feats "local" \ --verbose "${verbose}" echo "Successfully finished calculation of statistics."
# normalize and dump them pids=() for name in "${train_set}" "${dev_set}" "${eval_set}"; do ( [ ! -e "${dumpdir}/${name}/norm" ] && mkdir -p "${dumpdir}/${name}/norm" echo "Nomalization start. See the progress via ${dumpdir}/${name}/norm/normalize.*.log." ${train_cmd} JOB=1:${n_jobs} "${dumpdir}/${name}/norm/normalize.JOB.log" \ parallel-wavegan-normalize \ --config "${conf}" \ --stats "${dumpdir}/${train_set}/stats.${stats_ext}" \ --rootdir "${dumpdir}/${name}/raw/dump.JOB" \ --dumpdir "${dumpdir}/${name}/norm/dump.JOB" \ --target-feats "local" \ --verbose "${verbose}" echo "Successfully finished normalization of ${name} set." ) & pids+=($!) done i=0; for pid in "${pids[@]}"; do wait "${pid}" || ((++i)); done [ "${i}" -gt 0 ] && echo "$0: ${i} background jobs are failed." && exit 1; echo "Successfully finished normalization." fifi
if [ -z "${tag}" ]; then expdir="exp/${train_set}_vctk_$(basename "${conf}" .yaml)"else expdir="exp/${train_set}_vctk_${tag}"fiif [ "${stage}" -le 2 ] && [ "${stop_stage}" -ge 2 ]; then echo "Stage 2: Network training" [ ! -e "${expdir}" ] && mkdir -p "${expdir}" if [ "${n_gpus}" -gt 1 ]; then train="python -m parallel_wavegan.distributed.launch --nproc_per_node ${n_gpus} -c parallel-wavegan-train" else train="parallel-wavegan-train" fi if [ "$(yq ".use_local_condition" "${conf}")" = "true" ]; then cp "${dumpdir}/${train_set}/stats.${stats_ext}" "${expdir}" train_dumpdir="${dumpdir}/${train_set}/norm" dev_dumpdir="${dumpdir}/${dev_set}/norm" else train_dumpdir="${dumpdir}/${train_set}/raw" dev_dumpdir="${dumpdir}/${dev_set}/raw" fi echo "Training start. See the progress via ${expdir}/train.log." ${cuda_cmd} --gpu "${n_gpus}" "${expdir}/train.log" \ ${train} \ --config "${conf}" \ --train-dumpdir "${train_dumpdir}" \ --dev-dumpdir "${dev_dumpdir}" \ --outdir "${expdir}" \ --resume "${resume}" \ --verbose "${verbose}" echo "Successfully finished training."fi
if [ "${stage}" -le 3 ] && [ "${stop_stage}" -ge 3 ]; then echo "Stage 3: Network decoding" # shellcheck disable=SC2012 [ -z "${checkpoint}" ] && checkpoint="$(ls -dt "${expdir}"/*.pkl | head -1 || true)" outdir="${expdir}/wav/$(basename "${checkpoint}" .pkl)" pids=() for name in "${dev_set}" "${eval_set}"; do ( [ ! -e "${outdir}/${name}" ] && mkdir -p "${outdir}/${name}" # shellcheck disable=SC2030,SC2031 [ "${n_gpus}" -gt 1 ] && n_gpus=1 echo "Decoding start. See the progress via ${outdir}/${name}/decode.log." if [ "$(yq ".use_local_condition" "${conf}")" = "true" ]; then decode_dumpdir="${dumpdir}/${name}/norm" else decode_dumpdir="${dumpdir}/${name}/raw" fi ${cuda_cmd} --gpu "${n_gpus}" "${outdir}/${name}/decode.log" \ parallel-wavegan-decode \ --dumpdir "${decode_dumpdir}" \ --checkpoint "${checkpoint}" \ --outdir "${outdir}/${name}" \ --verbose "${verbose}" echo "Successfully finished decoding of ${name} set." ) & pids+=($!) done i=0; for pid in "${pids[@]}"; do wait "${pid}" || ((++i)); done [ "${i}" -gt 0 ] && echo "$0: ${i} background jobs are failed." && exit 1; echo "Successfully finished decoding."fi
if [ "${stage}" -le 4 ] && [ "${stop_stage}" -ge 4 ]; then echo "Stage 4: Voice conversion preparation" if [ "$(yq ".use_local_condition" "${conf}")" = "true" ]; then # calculate each speaker statistics for f0 transformation echo "Statistics computation start. See the progress via ${dumpdir}/${train_set}/compute_statistics_for_vc.log." ${train_cmd} "${dumpdir}/${train_set}/compute_statistics_for_vc.log" \ parallel-wavegan-compute-statistics \ --config "${conf}" \ --rootdir "${dumpdir}/${train_set}/norm" \ --dumpdir "${dumpdir}/${train_set}" \ --target-feats "local" \ --utt2spk "data/${train_set}/utt2spk" \ --verbose "${verbose}" echo "Successfully finished calculation of statistics." fi
pids=() for name in "${dev_set}" "${eval_set}"; do ( if [ "$(yq ".use_local_condition" "${conf}")" = "true" ]; then vc_rootdir="${dumpdir}/${name}/norm" vc_dumpdir="${dumpdir}/${name}/norm_vc" else vc_rootdir="${dumpdir}/${name}/raw" vc_dumpdir="${dumpdir}/${name}/raw_vc" fi echo "Setup for voice conversion start. See the progress via ${vc_dumpdir}/setup_for_vc.*.log." [ ! -e "${vc_dumpdir}" ] && mkdir -p "${vc_dumpdir}" ${train_cmd} JOB=1:${n_jobs} "${vc_dumpdir}/setup_for_vc.JOB.log" \ local/setup_for_vc.py \ --config "${conf}" \ --rootdir "${vc_rootdir}/dump.JOB" \ --dumpdir "${vc_dumpdir}/dump.JOB" \ --statdir "${dumpdir}/${train_set}" \ --utt2spk "data/${name}/utt2spk" \ --spk2idx "data/${train_set}/spk2idx" \ --verbose "${verbose}" echo "Successfully finished steup of ${name} set for voice conversion." ) & pids+=($!) done i=0; for pid in "${pids[@]}"; do wait "${pid}" || ((++i)); done [ "${i}" -gt 0 ] && echo "$0: ${i} background jobs are failed." && exit 1; echo "Successfully finished setup for voice conversion."fi
if [ "${stage}" -le 5 ] && [ "${stop_stage}" -ge 5 ]; then echo "Stage 5: Network decoding for voice conversion" # shellcheck disable=SC2012 [ -z "${checkpoint}" ] && checkpoint="$(ls -dt "${expdir}"/*.pkl | head -1 || true)" outdir="${expdir}/wav/$(basename "${checkpoint}" .pkl)" pids=() for name in "${dev_set}" "${eval_set}"; do ( [ ! -e "${outdir}/${name}" ] && mkdir -p "${outdir}/${name}" # shellcheck disable=SC2030,SC2031 [ "${n_gpus}" -gt 1 ] && n_gpus=1 echo "Decoding start. See the progress via ${outdir}/${name}/decode_vc.log." if [ "$(yq ".use_local_condition" "${conf}")" = "true" ]; then vc_decode_dumpdir="${dumpdir}/${name}/norm_vc" else vc_decode_dumpdir="${dumpdir}/${name}/raw_vc" fi ${cuda_cmd} JOB=1:${n_jobs} --max-jobs-run 1 --gpu "${n_gpus}" "${outdir}/${name}/decode_vc.JOB.log" \ parallel-wavegan-decode \ --dumpdir "${vc_decode_dumpdir}/dump.JOB" \ --checkpoint "${checkpoint}" \ --outdir "${outdir}/${name}/wav.JOB" \ --verbose "${verbose}" echo "Successfully finished decoding of ${name} set for voice conversion." ) & pids+=($!) done i=0; for pid in "${pids[@]}"; do wait "${pid}" || ((++i)); done [ "${i}" -gt 0 ] && echo "$0: ${i} background jobs are failed." && exit 1; echo "Successfully finished decoding for voice conversion."fiecho "Finished."12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091# ====== About run.pl, queue.pl, slurm.pl, and ssh.pl ======# Usage: <cmd>.pl [options] JOB=1:<nj> <log> <command...># e.g.# run.pl --mem 4G JOB=1:10 echo.JOB.log echo JOB## Options:# --time <time>: Limit the maximum time to execute.# --mem <mem>: Limit the maximum memory usage.# -–max-jobs-run <njob>: Limit the number parallel jobs. This is ignored for non-array jobs.# --num-threads <ngpu>: Specify the number of CPU core.# --gpu <ngpu>: Specify the number of GPU devices.# --config: Change the configuration file from default.## "JOB=1:10" is used for "array jobs" and it can control the number of parallel jobs.# The left string of "=", i.e. "JOB", is replaced by <N>(Nth job) in the command and the log file name,# e.g. "echo JOB" is changed to "echo 3" for the 3rd job and "echo 8" for 8th job respectively.# Note that the number must start with a positive number, so you can't use "JOB=0:10" for example.## run.pl, queue.pl, slurm.pl, and ssh.pl have unified interface, not depending on its backend.# These options are mapping to specific options for each backend and# it is configured by "conf/queue.conf" and "conf/slurm.conf" by default.# If jobs failed, your configuration might be wrong for your environment.### The official documentaion for run.pl, queue.pl, slurm.pl, and ssh.pl:# "Parallelization in Kaldi": http://kaldi-asr.org/doc/queue.html# =========================================================~
# Select the backend used by run.sh from "local", "stdout", "sge", "slurm", or "ssh"cmd_backend="stdout"
# Local machine, without any Job scheduling systemif [ "${cmd_backend}" = local ]; then
# The other usage export train_cmd="utils/run.pl" # Used for "*_train.py": "--gpu" is appended optionally by run.sh export cuda_cmd="utils/run.pl" # Used for "*_recog.py" export decode_cmd="utils/run.pl"
# Local machine, without any Job scheduling systemelif [ "${cmd_backend}" = stdout ]; then
# The other usage export train_cmd="utils/stdout.pl" # Used for "*_train.py": "--gpu" is appended optionally by run.sh export cuda_cmd="utils/stdout.pl" # Used for "*_recog.py" export decode_cmd="utils/stdout.pl"
# "qsub" (SGE, Torque, PBS, etc.)elif [ "${cmd_backend}" = sge ]; then # The default setting is written in conf/queue.conf. # You must change "-q g.q" for the "queue" for your environment. # To know the "queue" names, type "qhost -q" # Note that to use "--gpu *", you have to setup "complex_value" for the system scheduler.
export train_cmd="utils/queue.pl" export cuda_cmd="utils/queue.pl" export decode_cmd="utils/queue.pl"
# "sbatch" (Slurm)elif [ "${cmd_backend}" = slurm ]; then # The default setting is written in conf/slurm.conf. # You must change "-p cpu" and "-p gpu" for the "partion" for your environment. # To know the "partion" names, type "sinfo". # You can use "--gpu * " by defualt for slurm and it is interpreted as "--gres gpu:*" # The devices are allocated exclusively using "${CUDA_VISIBLE_DEVICES}".
export train_cmd="utils/slurm.pl" export cuda_cmd="utils/slurm.pl" export decode_cmd="utils/slurm.pl"
elif [ "${cmd_backend}" = ssh ]; then # You have to create ".queue/machines" to specify the host to execute jobs. # e.g. .queue/machines # host1 # host2 # host3 # Assuming you can login them without any password, i.e. You have to set ssh keys.
export train_cmd="utils/ssh.pl" export cuda_cmd="utils/ssh.pl" export decode_cmd="utils/ssh.pl"
else echo "$0: Error: Unknown cmd_backend=${cmd_backend}" 1>&2 return 1fi123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152# This is the configuration file for yesno dataset.# Note that this configuration is just for debugging.
############################################################ FEATURE EXTRACTION SETTING ############################################################sampling_rate: 8000 # Sampling rate.fft_size: 1024 # FFT size.hop_size: 256 # Hop size.win_length: null # Window length. # If set to null, it will be the same as fft_size.window: "hann" # Window function.num_mels: 80 # Number of mel basis.fmin: 80 # Minimum freq in mel basis calculation.fmax: 3800 # Maximum frequency in mel basis calculation.global_gain_scale: 1.0 # Will be multiplied to all of waveform.trim_silence: true # Whether to trim the start and end of silence.trim_threshold_in_db: 20 # Need to tune carefully if the recording is not good.trim_frame_size: 1024 # Frame size in trimming.trim_hop_size: 256 # Hop size in trimming.format: "hdf5" # Feature file format. "npy" or "hdf5" is supported.
############################################################ GENERATOR NETWORK ARCHITECTURE SETTING ############################################################generator_type: HiFiGANGeneratorgenerator_params: in_channels: 80 # Number of input channels. out_channels: 1 # Number of output channels. channels: 32 # Number of initial channels. kernel_size: 7 # Kernel size of initial and final conv layers. upsample_scales: [8, 8, 2, 2] # Upsampling scales. upsample_kernel_sizes: [16, 16, 4, 4] # Kernel size for upsampling layers. resblock_kernel_sizes: [3, 7, 11] # Kernel size for residual blocks. resblock_dilations: # Dilations for residual blocks. - [1, 3, 5] - [1, 3, 5] - [1, 3, 5] use_additional_convs: true # Whether to use additional conv layer in residual blocks. bias: true # Whether to use bias parameter in conv. nonlinear_activation: "LeakyReLU" # Nonlinear activation type. nonlinear_activation_params: # Nonlinear activation paramters. negative_slope: 0.1 use_weight_norm: true # Whether to apply weight normalization.
############################################################ DISCRIMINATOR NETWORK ARCHITECTURE SETTING ############################################################discriminator_type: HiFiGANMultiScaleMultiPeriodDiscriminatordiscriminator_params: scales: 2 # Number of multi-scale discriminator. scale_downsample_pooling: "AvgPool1d" # Pooling operation for scale discriminator. scale_downsample_pooling_params: kernel_size: 4 # Pooling kernel size. stride: 2 # Pooling stride. padding: 2 # Padding size. scale_discriminator_params: in_channels: 1 # Number of input channels. out_channels: 1 # Number of output channels. kernel_sizes: [15, 41, 5, 3] # List of kernel sizes. channels: 16 # Initial number of channels. max_downsample_channels: 32 # Maximum number of channels in downsampling conv layers. max_groups: 16 # Maximum number of groups in downsampling conv layers. bias: true downsample_scales: [4, 4, 4, 4] # Downsampling scales. nonlinear_activation: "LeakyReLU" # Nonlinear activation. nonlinear_activation_params: negative_slope: 0.1 follow_official_norm: true # Whether to follow the official norm setting. periods: [2, 3] # List of period for multi-period discriminator. period_discriminator_params: in_channels: 1 # Number of input channels. out_channels: 1 # Number of output channels. kernel_sizes: [5, 3] # List of kernel sizes. channels: 32 # Initial number of channels. downsample_scales: [4, 4, 4, 4] # Downsampling scales. max_downsample_channels: 32 # Maximum number of channels in downsampling conv layers. bias: true # Whether to use bias parameter in conv layer." nonlinear_activation: "LeakyReLU" # Nonlinear activation. nonlinear_activation_params: # Nonlinear activation paramters. negative_slope: 0.1 use_weight_norm: true # Whether to apply weight normalization. use_spectral_norm: false # Whether to apply spectral normalization.
############################################################ STFT LOSS SETTING ############################################################use_stft_loss: falseuse_mel_loss: truegenerator_adv_loss_params: average_by_discriminators: false # Whether to average loss by #discriminators.discriminator_adv_loss_params: average_by_discriminators: false # Whether to average loss by #discriminators.use_feat_match_loss: truefeat_match_loss_params: average_by_discriminators: false # Whether to average loss by # discriminators. average_by_layers: false # Whether to average loss by # layers in each discriminator. include_final_outputs: true # Whether to include final outputs in feat match loss calculation.
############################################################ ADVERSARIAL LOSS SETTING ############################################################lambda_aux: 45.0 # Loss balancing coefficient for STFT loss.lambda_adv: 1.0 # Loss balancing coefficient for adversarial loss.lambda_feat_match: 2.0 # Loss balancing coefficient for feat match loss..
############################################################ DATA LOADER SETTING ############################################################batch_size: 2 # Batch size.batch_max_steps: 4096 # Length of each audio in batch. Make sure dividable by hop_size.pin_memory: true # Whether to pin memory in Pytorch DataLoader.num_workers: 2 # Number of workers in Pytorch DataLoader.remove_short_samples: false # Whether to remove samples the length of which are less than batch_max_steps.allow_cache: true # Whether to allow cache in dataset. If true, it requires cpu memory.
############################################################ OPTIMIZER & SCHEDULER SETTING ############################################################generator_optimizer_type: AdamWgenerator_optimizer_params: lr: 0.0002 # Generator's learning rate. betas: [0.8, 0.99] # Generator's optimizer beta weight_decay: 0.0 # Generator's weight decay coefficient.generator_scheduler_type: ExponentialLRgenerator_scheduler_params: gamma: 0.999 # Generator's scheduler gamma.generator_grad_norm: -1 # Generator's gradient norm.discriminator_optimizer_type: AdamWdiscriminator_optimizer_params: lr: 0.0002 # Discriminator's learning rate. betas: [0.8, 0.99] # Discriminator's optimizer beta weight_decay: 0.0 # Discriminator's weight decay coefficient.discriminator_scheduler_type: ExponentialLRdiscriminator_scheduler_params: gamma: 0.999 # Discriminator's scheduler gamma.discriminator_grad_norm: -1 # Discriminator's gradient norm.
############################################################ INTERVAL SETTING ############################################################generator_train_start_steps: 5 # Number of steps to start to train discriminator.discriminator_train_start_steps: 0 # Number of steps to start to train discriminator.train_max_steps: 10 # Number of training steps.save_interval_steps: 5 # Interval steps to save checkpoint.eval_interval_steps: 5 # Interval steps to evaluate the network.log_interval_steps: 5 # Interval steps to record the training log.
############################################################ OTHER SETTING ############################################################num_save_intermediate_results: 4 # Number of results to be saved as intermediate results.123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112# This is the configuration file for yesno dataset.# Note that this configuration is just for debugging.
############################################################ FEATURE EXTRACTION SETTING ############################################################sampling_rate: 8000 # Sampling rate.fft_size: 1024 # FFT size.hop_size: 256 # Hop size.win_length: null # Window length. # If set to null, it will be the same as fft_size.window: "hann" # Window function.num_mels: 80 # Number of mel basis.fmin: 80 # Minimum freq in mel basis calculation.fmax: 4000 # Maximum frequency in mel basis calculation.global_gain_scale: 1.0 # Will be multiplied to all of waveform.trim_silence: true # Whether to trim the start and end of silence.trim_threshold_in_db: 60 # Need to tune carefully if the recording is not good.trim_frame_size: 1024 # Frame size in trimming.trim_hop_size: 256 # Hop size in trimming.format: "hdf5" # Feature file format. "npy" or "hdf5" is supported.
############################################################ GENERATOR NETWORK ARCHITECTURE SETTING ############################################################generator_type: "MelGANGenerator" # Generator type.generator_params: in_channels: 80 # Number of input channels. out_channels: 1 # Number of output channels. kernel_size: 7 # Kernel size of initial and final conv layers. channels: 256 # Initial number of channels for conv layers. upsample_scales: [8, 8, 2, 2] # List of Upsampling scales. stack_kernel_size: 3 # Kernel size of dilated conv layers in residual stack. stacks: 1 # Number of stacks in a single residual stack module. use_weight_norm: True # Whether to use weight normalization. use_causal_conv: False # Whether to use causal convolution.
############################################################ DISCRIMINATOR NETWORK ARCHITECTURE SETTING ############################################################discriminator_params: in_channels: 1 # Number of input channels. out_channels: 1 # Number of output channels. kernel_size: 3 # Number of output channels. layers: 10 # Number of conv layers. conv_channels: 32 # Number of chnn layers. bias: true # Whether to use bias parameter in conv. use_weight_norm: true # Whether to use weight norm. # If set to true, it will be applied to all of the conv layers. nonlinear_activation: "LeakyReLU" # Nonlinear function after each conv. nonlinear_activation_params: # Nonlinear function parameters negative_slope: 0.2 # Alpha in LeakyReLU.
############################################################ STFT LOSS SETTING ############################################################stft_loss_params: fft_sizes: [1024, 2048, 512] # List of FFT size for STFT-based loss. hop_sizes: [120, 240, 50] # List of hop size for STFT-based loss win_lengths: [600, 1200, 240] # List of window length for STFT-based loss. window: "hann_window" # Window function for STFT-based loss
############################################################ ADVERSARIAL LOSS SETTING ############################################################lambda_adv: 4.0 # Loss balancing coefficient.
############################################################ DATA LOADER SETTING ############################################################batch_size: 2 # Batch size.batch_max_steps: 4096 # Length of each audio in batch. Make sure dividable by hop_size.pin_memory: true # Whether to pin memory in Pytorch DataLoader.num_workers: 2 # Number of workers in Pytorch DataLoader.remove_short_samples: false # Whether to remove samples the length of which are less than batch_max_steps.allow_cache: true # Whether to allow cache in dataset. If true, it requires cpu memory.
############################################################ OPTIMIZER & SCHEDULER SETTING ############################################################generator_optimizer_params: lr: 0.0001 # Generator's learning rate. eps: 1.0e-6 # Generator's epsilon. weight_decay: 0.0 # Generator's weight decay coefficient.generator_scheduler_params: step_size: 200000 # Generator's scheduler step size. gamma: 0.5 # Generator's scheduler gamma. # At each step size, lr will be multiplied by this parameter.generator_grad_norm: 10 # Generator's gradient norm.discriminator_optimizer_params: lr: 0.00005 # Discriminator's learning rate. eps: 1.0e-6 # Discriminator's epsilon. weight_decay: 0.0 # Discriminator's weight decay coefficient.discriminator_scheduler_params: step_size: 200000 # Discriminator's scheduler step size. gamma: 0.5 # Discriminator's scheduler gamma. # At each step size, lr will be multiplied by this parameter.discriminator_grad_norm: 1 # Discriminator's gradient norm.
############################################################ INTERVAL SETTING ############################################################discriminator_train_start_steps: 5 # Number of steps to start to train discriminator.train_max_steps: 10 # Number of training steps.save_interval_steps: 5 # Interval steps to save checkpoint.eval_interval_steps: 5 # Interval steps to evaluate the network.log_interval_steps: 5 # Interval steps to record the training log.
############################################################ OTHER SETTING ############################################################num_save_intermediate_results: 4 # Number of results to be saved as intermediate results.123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121# This is the configuration file for yesno dataset.# Note that this configuration is just for debugging.
############################################################ FEATURE EXTRACTION SETTING ############################################################sampling_rate: 8000 # Sampling rate.fft_size: 1024 # FFT size.hop_size: 256 # Hop size.win_length: null # Window length. # If set to null, it will be the same as fft_size.window: "hann" # Window function.num_mels: 80 # Number of mel basis.fmin: 0 # Minimum freq in mel basis calculation.fmax: 4000 # Maximum frequency in mel basis calculation.global_gain_scale: 0.8 # Will be multiplied to all of waveform.trim_silence: false # Whether to trim the start and end of silence.trim_threshold_in_db: 60 # Need to tune carefully if the recording is not good.trim_frame_size: 1024 # Frame size in trimming.trim_hop_size: 256 # Hop size in trimming.format: "hdf5" # Feature file format. " npy " or " hdf5 " is supported.
############################################################ GENERATOR NETWORK ARCHITECTURE SETTING ############################################################generator_type: "MelGANGenerator" # Generator type.generator_params: in_channels: 80 # Number of input channels. out_channels: 1 # Number of output channels. kernel_size: 7 # Kernel size of initial and final conv layers. channels: 256 # Initial number of channels for conv layers. upsample_scales: [8, 8, 2, 2] # List of Upsampling scales. stack_kernel_size: 3 # Kernel size of dilated conv layers in residual stack. stacks: 1 # Number of stacks in a single residual stack module. use_weight_norm: True # Whether to use weight normalization. use_causal_conv: False # Whether to use causal convolution.
############################################################ DISCRIMINATOR NETWORK ARCHITECTURE SETTING ############################################################discriminator_type: "MelGANMultiScaleDiscriminator" # Discriminator type.discriminator_params: in_channels: 1 # Number of input channels. out_channels: 1 # Number of output channels. scales: 3 # Number of multi-scales. downsample_pooling: "AvgPool1d" # Pooling type for the input downsampling. downsample_pooling_params: # Parameters of the above pooling function. kernel_size: 4 stride: 2 padding: 1 count_include_pad: False kernel_sizes: [5, 3] # List of kernel size. channels: 16 # Number of channels of the initial conv layer. max_downsample_channels: 64 # Maximum number of channels of downsampling layers. downsample_scales: [4, 4, 4, 4] # List of downsampling scales. nonlinear_activation: "LeakyReLU" # Nonlinear activation function. nonlinear_activation_params: # Parameters of nonlinear activation function. negative_slope: 0.2 use_weight_norm: True # Whether to use weight norm.
############################################################ STFT LOSS SETTING ############################################################stft_loss_params: fft_sizes: [1024, 2048, 512] # List of FFT size for STFT-based loss. hop_sizes: [120, 240, 50] # List of hop size for STFT-based loss win_lengths: [600, 1200, 240] # List of window length for STFT-based loss. window: "hann_window" # Window function for STFT-based loss
############################################################ ADVERSARIAL LOSS SETTING ############################################################use_feat_match_loss: true # Whether to use feature matching loss.lambda_feat_match: 25.0 # Loss balancing coefficient for feature matching loss.lambda_adv: 4.0 # Loss balancing coefficient.
############################################################ DATA LOADER SETTING ############################################################batch_size: 2 # Batch size.batch_max_steps: 4096 # Length of each audio in batch. Make sure dividable by hop_size.pin_memory: true # Whether to pin memory in Pytorch DataLoader.num_workers: 2 # Number of workers in Pytorch DataLoader.remove_short_samples: false # Whether to remove samples the length of which are less than batch_max_steps.allow_cache: true # Whether to allow cache in dataset. If true, it requires cpu memory.
############################################################ OPTIMIZER & SCHEDULER SETTING ############################################################generator_optimizer_params: lr: 0.0001 # Generator's learning rate. eps: 1.0e-6 # Generator's epsilon. weight_decay: 0.0 # Generator's weight decay coefficient.generator_scheduler_params: step_size: 200000 # Generator's scheduler step size. gamma: 0.5 # Generator's scheduler gamma. # At each step size, lr will be multiplied by this parameter.generator_grad_norm: 10 # Generator's gradient norm.discriminator_optimizer_params: lr: 0.00005 # Discriminator's learning rate. eps: 1.0e-6 # Discriminator's epsilon. weight_decay: 0.0 # Discriminator's weight decay coefficient.discriminator_scheduler_params: step_size: 200000 # Discriminator's scheduler step size. gamma: 0.5 # Discriminator's scheduler gamma. # At each step size, lr will be multiplied by this parameter.discriminator_grad_norm: 1 # Discriminator's gradient norm.
############################################################ INTERVAL SETTING ############################################################discriminator_train_start_steps: 5 # Number of steps to start to train discriminator.train_max_steps: 10 # Number of training steps.save_interval_steps: 5 # Interval steps to save checkpoint.eval_interval_steps: 5 # Interval steps to evaluate the network.log_interval_steps: 5 # Interval steps to record the training log.
############################################################ OTHER SETTING ############################################################num_save_intermediate_results: 4 # Number of results to be saved as intermediate results.123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126# This is the configuration file for yesno dataset.# Note that this configuration is just for debugging.
############################################################ FEATURE EXTRACTION SETTING ############################################################sampling_rate: 8000 # Sampling rate.fft_size: 1024 # FFT size.hop_size: 200 # Hop size.win_length: null # Window length. # If set to null, it will be the same as fft_size.window: "hann" # Window function.num_mels: 80 # Number of mel basis.fmin: 0 # Minimum freq in mel basis calculation.fmax: 4000 # Maximum frequency in mel basis calculation.global_gain_scale: 0.8 # Will be multiplied to all of waveform.trim_silence: false # Whether to trim the start and end of silence.trim_threshold_in_db: 60 # Need to tune carefully if the recording is not good.trim_frame_size: 1024 # Frame size in trimming.trim_hop_size: 256 # Hop size in trimming.format: "hdf5" # Feature file format. " npy " or " hdf5 " is supported.
############################################################ GENERATOR NETWORK ARCHITECTURE SETTING ############################################################generator_type: "MelGANGenerator" # Generator type.generator_params: in_channels: 80 # Number of input channels. out_channels: 4 # Number of output channels. kernel_size: 7 # Kernel size of initial and final conv layers. channels: 256 # Initial number of channels for conv layers. upsample_scales: [2, 5, 5] # List of Upsampling scales. stack_kernel_size: 3 # Kernel size of dilated conv layers in residual stack. stacks: 1 # Number of stacks in a single residual stack module. use_weight_norm: True # Whether to use weight normalization. use_causal_conv: False # Whether to use causal convolution.
############################################################ DISCRIMINATOR NETWORK ARCHITECTURE SETTING ############################################################discriminator_type: "MelGANMultiScaleDiscriminator" # Discriminator type.discriminator_params: in_channels: 1 # Number of input channels. out_channels: 1 # Number of output channels. scales: 3 # Number of multi-scales. downsample_pooling: "AvgPool1d" # Pooling type for the input downsampling. downsample_pooling_params: # Parameters of the above pooling function. kernel_size: 4 stride: 2 padding: 1 count_include_pad: False kernel_sizes: [5, 3] # List of kernel size. channels: 16 # Number of channels of the initial conv layer. max_downsample_channels: 64 # Maximum number of channels of downsampling layers. downsample_scales: [4, 4, 4] # List of downsampling scales. nonlinear_activation: "LeakyReLU" # Nonlinear activation function. nonlinear_activation_params: # Parameters of nonlinear activation function. negative_slope: 0.2 use_weight_norm: True # Whether to use weight norm.
############################################################ STFT LOSS SETTING ############################################################stft_loss_params: fft_sizes: [1024, 2048, 512] # List of FFT size for STFT-based loss. hop_sizes: [120, 240, 50] # List of hop size for STFT-based loss win_lengths: [600, 1200, 240] # List of window length for STFT-based loss. window: "hann_window" # Window function for STFT-based lossuse_subband_stft_loss: truesubband_stft_loss_params: fft_sizes: [384, 683, 171] # List of FFT size for STFT-based loss. hop_sizes: [30, 60, 10] # List of hop size for STFT-based loss win_lengths: [150, 300, 60] # List of window length for STFT-based loss. window: "hann_window" # Window function for STFT-based loss
############################################################ ADVERSARIAL LOSS SETTING ############################################################use_feat_match_loss: false # Whether to use feature matching loss.lambda_adv: 2.5 # Loss balancing coefficient.
############################################################ DATA LOADER SETTING ############################################################batch_size: 2 # Batch size.batch_max_steps: 4000 # Length of each audio in batch. Make sure dividable by hop_size.pin_memory: true # Whether to pin memory in Pytorch DataLoader.num_workers: 2 # Number of workers in Pytorch DataLoader.remove_short_samples: false # Whether to remove samples the length of which are less than batch_max_steps.allow_cache: true # Whether to allow cache in dataset. If true, it requires cpu memory.
############################################################ OPTIMIZER & SCHEDULER SETTING ############################################################generator_optimizer_params: lr: 0.0001 # Generator's learning rate. eps: 1.0e-6 # Generator's epsilon. weight_decay: 0.0 # Generator's weight decay coefficient.generator_scheduler_params: step_size: 200000 # Generator's scheduler step size. gamma: 0.5 # Generator's scheduler gamma. # At each step size, lr will be multiplied by this parameter.generator_grad_norm: 10 # Generator's gradient norm.discriminator_optimizer_params: lr: 0.00005 # Discriminator's learning rate. eps: 1.0e-6 # Discriminator's epsilon. weight_decay: 0.0 # Discriminator's weight decay coefficient.discriminator_scheduler_params: step_size: 200000 # Discriminator's scheduler step size. gamma: 0.5 # Discriminator's scheduler gamma. # At each step size, lr will be multiplied by this parameter.discriminator_grad_norm: 1 # Discriminator's gradient norm.
############################################################ INTERVAL SETTING ############################################################discriminator_train_start_steps: 5 # Number of steps to start to train discriminator.train_max_steps: 10 # Number of training steps.save_interval_steps: 5 # Interval steps to save checkpoint.eval_interval_steps: 5 # Interval steps to evaluate the network.log_interval_steps: 5 # Interval steps to record the training log.
############################################################ OTHER SETTING ############################################################num_save_intermediate_results: 4 # Number of results to be saved as intermediate results.123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121# This is the configuration file for yesno dataset.# Note that this configuration is just for debugging.
############################################################ FEATURE EXTRACTION SETTING ############################################################sampling_rate: 8000 # Sampling rate.sampling_rate_for_feats: 4000 # Sampling rate for features.fft_size: 1024 # FFT size.hop_size: 256 # Hop size.win_length: null # Window length. # If set to null, it will be the same as fft_size.window: "hann" # Window function.num_mels: 80 # Number of mel basis.fmin: 80 # Minimum freq in mel basis calculation.fmax: 2000 # Maximum frequency in mel basis calculation.global_gain_scale: 1.0 # Will be multiplied to all of waveform.trim_silence: true # Whether to trim the start and end of silence.trim_threshold_in_db: 20 # Need to tune carefully if the recording is not good.trim_frame_size: 1024 # Frame size in trimming.trim_hop_size: 256 # Hop size in trimming.format: "hdf5" # Feature file format. "npy" or "hdf5" is supported.
############################################################ GENERATOR NETWORK ARCHITECTURE SETTING ############################################################generator_params: in_channels: 1 # Number of input channels. out_channels: 1 # Number of output channels. kernel_size: 3 # Kernel size of dilated convolution. layers: 20 # Number of residual block layers. stacks: 2 # Number of stacks i.e., dilation cycles. residual_channels: 16 # Number of channels in residual conv. gate_channels: 32 # Number of channels in gated conv. skip_channels: 16 # Number of channels in skip conv. aux_channels: 80 # Number of channels for auxiliary feature conv. # Must be the same as num_mels. aux_context_window: 1 # Context window size for auxiliary feature. # If set to 2, previous 2 and future 2 frames will be considered. dropout: 0.0 # Dropout rate. 0.0 means no dropout applied. use_weight_norm: true # Whether to use weight norm. # If set to true, it will be applied to all of the conv layers. upsample_net: "ConvInUpsampleNetwork" # Upsampling network architecture. upsample_params: # Upsampling network parameters. upsample_scales: [4, 4, 4, 4] # Upsampling scales. Prodcut of these must be the same as hop size.
############################################################ DISCRIMINATOR NETWORK ARCHITECTURE SETTING ############################################################discriminator_params: in_channels: 1 # Number of input channels. out_channels: 1 # Number of output channels. kernel_size: 3 # Number of output channels. layers: 10 # Number of conv layers. conv_channels: 16 # Number of chnn layers. bias: true # Whether to use bias parameter in conv. use_weight_norm: true # Whether to use weight norm. # If set to true, it will be applied to all of the conv layers. nonlinear_activation: "LeakyReLU" # Nonlinear function after each conv. nonlinear_activation_params: # Nonlinear function parameters negative_slope: 0.2 # Alpha in LeakyReLU.
############################################################ STFT LOSS SETTING ############################################################stft_loss_params: fft_sizes: [1024, 2048, 512] # List of FFT size for STFT-based loss. hop_sizes: [120, 240, 50] # List of hop size for STFT-based loss win_lengths: [600, 1200, 240] # List of window length for STFT-based loss. window: "hann_window" # Window function for STFT-based loss
############################################################ ADVERSARIAL LOSS SETTING ############################################################lambda_adv: 4.0 # Loss balancing coefficient.
############################################################ DATA LOADER SETTING ############################################################batch_size: 2 # Batch size.batch_max_steps: 4096 # Length of each audio in batch. Make sure dividable by hop_size.pin_memory: true # Whether to pin memory in Pytorch DataLoader.num_workers: 2 # Number of workers in Pytorch DataLoader.remove_short_samples: false # Whether to remove samples the length of which are less than batch_max_steps.allow_cache: true # Whether to allow cache in dataset. If true, it requires cpu memory.
############################################################ OPTIMIZER & SCHEDULER SETTING ############################################################generator_optimizer_params: lr: 0.0001 # Generator's learning rate. eps: 1.0e-6 # Generator's epsilon. weight_decay: 0.0 # Generator's weight decay coefficient.generator_scheduler_params: step_size: 200000 # Generator's scheduler step size. gamma: 0.5 # Generator's scheduler gamma. # At each step size, lr will be multiplied by this parameter.generator_grad_norm: 10 # Generator's gradient norm.discriminator_optimizer_params: lr: 0.00005 # Discriminator's learning rate. eps: 1.0e-6 # Discriminator's epsilon. weight_decay: 0.0 # Discriminator's weight decay coefficient.discriminator_scheduler_params: step_size: 200000 # Discriminator's scheduler step size. gamma: 0.5 # Discriminator's scheduler gamma. # At each step size, lr will be multiplied by this parameter.discriminator_grad_norm: 1 # Discriminator's gradient norm.
############################################################ INTERVAL SETTING ############################################################discriminator_train_start_steps: 5 # Number of steps to start to train discriminator.train_max_steps: 10 # Number of training steps.save_interval_steps: 5 # Interval steps to save checkpoint.eval_interval_steps: 5 # Interval steps to evaluate the network.log_interval_steps: 5 # Interval steps to record the training log.
############################################################ OTHER SETTING ############################################################num_save_intermediate_results: 4 # Number of results to be saved as intermediate results.123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121# This is the configuration file for yesno dataset.# Note that this configuration is just for debugging.
############################################################ FEATURE EXTRACTION SETTING ############################################################sampling_rate: 8000 # Sampling rate.fft_size: 1024 # FFT size.hop_size: 256 # Hop size.win_length: null # Window length. # If set to null, it will be the same as fft_size.window: "hann" # Window function.num_mels: 80 # Number of mel basis.fmin: 80 # Minimum freq in mel basis calculation.fmax: 3800 # Maximum frequency in mel basis calculation.log_base: null # Log base.global_gain_scale: 1.0 # Will be multiplied to all of waveform.trim_silence: true # Whether to trim the start and end of silence.trim_threshold_in_db: 20 # Need to tune carefully if the recording is not good.trim_frame_size: 1024 # Frame size in trimming.trim_hop_size: 256 # Hop size in trimming.format: "npy" # Feature file format. "npy" or "hdf5" is supported.
############################################################ GENERATOR NETWORK ARCHITECTURE SETTING ############################################################generator_params: in_channels: 1 # Number of input channels. out_channels: 1 # Number of output channels. kernel_size: 3 # Kernel size of dilated convolution. layers: 20 # Number of residual block layers. stacks: 2 # Number of stacks i.e., dilation cycles. residual_channels: 16 # Number of channels in residual conv. gate_channels: 32 # Number of channels in gated conv. skip_channels: 16 # Number of channels in skip conv. aux_channels: 80 # Number of channels for auxiliary feature conv. # Must be the same as num_mels. aux_context_window: 1 # Context window size for auxiliary feature. # If set to 2, previous 2 and future 2 frames will be considered. dropout: 0.0 # Dropout rate. 0.0 means no dropout applied. use_weight_norm: true # Whether to use weight norm. # If set to true, it will be applied to all of the conv layers. upsample_net: "ConvInUpsampleNetwork" # Upsampling network architecture. upsample_params: # Upsampling network parameters. upsample_scales: [4, 4, 4, 4] # Upsampling scales. Prodcut of these must be the same as hop size.
############################################################ DISCRIMINATOR NETWORK ARCHITECTURE SETTING ############################################################discriminator_params: in_channels: 1 # Number of input channels. out_channels: 1 # Number of output channels. kernel_size: 3 # Number of output channels. layers: 10 # Number of conv layers. conv_channels: 16 # Number of chnn layers. bias: true # Whether to use bias parameter in conv. use_weight_norm: true # Whether to use weight norm. # If set to true, it will be applied to all of the conv layers. nonlinear_activation: "LeakyReLU" # Nonlinear function after each conv. nonlinear_activation_params: # Nonlinear function parameters negative_slope: 0.2 # Alpha in LeakyReLU.
############################################################ STFT LOSS SETTING ############################################################stft_loss_params: fft_sizes: [1024, 2048, 512] # List of FFT size for STFT-based loss. hop_sizes: [120, 240, 50] # List of hop size for STFT-based loss win_lengths: [600, 1200, 240] # List of window length for STFT-based loss. window: "hann_window" # Window function for STFT-based loss
############################################################ ADVERSARIAL LOSS SETTING ############################################################lambda_adv: 4.0 # Loss balancing coefficient.
############################################################ DATA LOADER SETTING ############################################################batch_size: 2 # Batch size.batch_max_steps: 4096 # Length of each audio in batch. Make sure dividable by hop_size.pin_memory: true # Whether to pin memory in Pytorch DataLoader.num_workers: 2 # Number of workers in Pytorch DataLoader.remove_short_samples: false # Whether to remove samples the length of which are less than batch_max_steps.allow_cache: true # Whether to allow cache in dataset. If true, it requires cpu memory.
############################################################ OPTIMIZER & SCHEDULER SETTING ############################################################generator_optimizer_params: lr: 0.0001 # Generator's learning rate. eps: 1.0e-6 # Generator's epsilon. weight_decay: 0.0 # Generator's weight decay coefficient.generator_scheduler_params: step_size: 200000 # Generator's scheduler step size. gamma: 0.5 # Generator's scheduler gamma. # At each step size, lr will be multiplied by this parameter.generator_grad_norm: 10 # Generator's gradient norm.discriminator_optimizer_params: lr: 0.00005 # Discriminator's learning rate. eps: 1.0e-6 # Discriminator's epsilon. weight_decay: 0.0 # Discriminator's weight decay coefficient.discriminator_scheduler_params: step_size: 200000 # Discriminator's scheduler step size. gamma: 0.5 # Discriminator's scheduler gamma. # At each step size, lr will be multiplied by this parameter.discriminator_grad_norm: 1 # Discriminator's gradient norm.
############################################################ INTERVAL SETTING ############################################################discriminator_train_start_steps: 5 # Number of steps to start to train discriminator.train_max_steps: 10 # Number of training steps.save_interval_steps: 5 # Interval steps to save checkpoint.eval_interval_steps: 5 # Interval steps to evaluate the network.log_interval_steps: 5 # Interval steps to record the training log.
############################################################ OTHER SETTING ############################################################num_save_intermediate_results: 4 # Number of results to be saved as intermediate results.123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120# This is the configuration file for yesno dataset.# Note that this configuration is just for debugging.
############################################################ FEATURE EXTRACTION SETTING ############################################################sampling_rate: 8000 # Sampling rate.fft_size: 1024 # FFT size.hop_size: 256 # Hop size.win_length: null # Window length. # If set to null, it will be the same as fft_size.window: "hann" # Window function.num_mels: 80 # Number of mel basis.fmin: 80 # Minimum freq in mel basis calculation.fmax: 3800 # Maximum frequency in mel basis calculation.global_gain_scale: 1.0 # Will be multiplied to all of waveform.trim_silence: true # Whether to trim the start and end of silence.trim_threshold_in_db: 20 # Need to tune carefully if the recording is not good.trim_frame_size: 1024 # Frame size in trimming.trim_hop_size: 256 # Hop size in trimming.format: "hdf5" # Feature file format. "npy" or "hdf5" is supported.
############################################################ GENERATOR NETWORK ARCHITECTURE SETTING ############################################################generator_params: in_channels: 1 # Number of input channels. out_channels: 1 # Number of output channels. kernel_size: 3 # Kernel size of dilated convolution. layers: 20 # Number of residual block layers. stacks: 2 # Number of stacks i.e., dilation cycles. residual_channels: 16 # Number of channels in residual conv. gate_channels: 32 # Number of channels in gated conv. skip_channels: 16 # Number of channels in skip conv. aux_channels: 80 # Number of channels for auxiliary feature conv. # Must be the same as num_mels. aux_context_window: 1 # Context window size for auxiliary feature. # If set to 2, previous 2 and future 2 frames will be considered. dropout: 0.0 # Dropout rate. 0.0 means no dropout applied. use_weight_norm: true # Whether to use weight norm. # If set to true, it will be applied to all of the conv layers. upsample_net: "ConvInUpsampleNetwork" # Upsampling network architecture. upsample_params: # Upsampling network parameters. upsample_scales: [4, 4, 4, 4] # Upsampling scales. Prodcut of these must be the same as hop size.
############################################################ DISCRIMINATOR NETWORK ARCHITECTURE SETTING ############################################################discriminator_params: in_channels: 1 # Number of input channels. out_channels: 1 # Number of output channels. kernel_size: 3 # Number of output channels. layers: 10 # Number of conv layers. conv_channels: 16 # Number of chnn layers. bias: true # Whether to use bias parameter in conv. use_weight_norm: true # Whether to use weight norm. # If set to true, it will be applied to all of the conv layers. nonlinear_activation: "LeakyReLU" # Nonlinear function after each conv. nonlinear_activation_params: # Nonlinear function parameters negative_slope: 0.2 # Alpha in LeakyReLU.
############################################################ STFT LOSS SETTING ############################################################stft_loss_params: fft_sizes: [1024, 2048, 512] # List of FFT size for STFT-based loss. hop_sizes: [120, 240, 50] # List of hop size for STFT-based loss win_lengths: [600, 1200, 240] # List of window length for STFT-based loss. window: "hann_window" # Window function for STFT-based loss
############################################################ ADVERSARIAL LOSS SETTING ############################################################lambda_adv: 4.0 # Loss balancing coefficient.
############################################################ DATA LOADER SETTING ############################################################batch_size: 2 # Batch size.batch_max_steps: 4096 # Length of each audio in batch. Make sure dividable by hop_size.pin_memory: true # Whether to pin memory in Pytorch DataLoader.num_workers: 2 # Number of workers in Pytorch DataLoader.remove_short_samples: false # Whether to remove samples the length of which are less than batch_max_steps.allow_cache: true # Whether to allow cache in dataset. If true, it requires cpu memory.
############################################################ OPTIMIZER & SCHEDULER SETTING ############################################################generator_optimizer_params: lr: 0.0001 # Generator's learning rate. eps: 1.0e-6 # Generator's epsilon. weight_decay: 0.0 # Generator's weight decay coefficient.generator_scheduler_params: step_size: 200000 # Generator's scheduler step size. gamma: 0.5 # Generator's scheduler gamma. # At each step size, lr will be multiplied by this parameter.generator_grad_norm: 10 # Generator's gradient norm.discriminator_optimizer_params: lr: 0.00005 # Discriminator's learning rate. eps: 1.0e-6 # Discriminator's epsilon. weight_decay: 0.0 # Discriminator's weight decay coefficient.discriminator_scheduler_params: step_size: 200000 # Discriminator's scheduler step size. gamma: 0.5 # Discriminator's scheduler gamma. # At each step size, lr will be multiplied by this parameter.discriminator_grad_norm: 1 # Discriminator's gradient norm.
############################################################ INTERVAL SETTING ############################################################discriminator_train_start_steps: 5 # Number of steps to start to train discriminator.train_max_steps: 10 # Number of training steps.save_interval_steps: 5 # Interval steps to save checkpoint.eval_interval_steps: 5 # Interval steps to evaluate the network.log_interval_steps: 5 # Interval steps to record the training log.
############################################################ OTHER SETTING ############################################################num_save_intermediate_results: 4 # Number of results to be saved as intermediate results.123456789101112# Default configurationcommand sbatch --export=PATH --ntasks-per-node=1option time=* --time $0option mem=* --mem-per-cpu $0option mem=0 # Do not add anything to qsub_optsoption num_threads=* --cpus-per-task $0 --ntasks-per-node=1option num_threads=1 --cpus-per-task 1 --ntasks-per-node=1 # Do not add anything to qsub_optsdefault gpu=0option gpu=0 -p cpuoption gpu=* -p gpu --gres=gpu:$0# note: the --max-jobs-run option is supported as a special case# by slurm.pl and you don't have to handle it in the config file.123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135# This is the configuration file for yesno dataset.# Note that this configuration is just for debugging.
############################################################ FEATURE EXTRACTION SETTING ############################################################sampling_rate: 8000 # Sampling rate.fft_size: 1024 # FFT size.hop_size: 256 # Hop size.win_length: null # Window length. # If set to null, it will be the same as fft_size.window: "hann" # Window function.num_mels: 80 # Number of mel basis.fmin: 0 # Minimum freq in mel basis calculation.fmax: 4000 # Maximum frequency in mel basis calculation.global_gain_scale: 0.8 # Will be multiplied to all of waveform.trim_silence: false # Whether to trim the start and end of silence.trim_threshold_in_db: 60 # Need to tune carefully if the recording is not good.trim_frame_size: 1024 # Frame size in trimming.trim_hop_size: 256 # Hop size in trimming.format: "hdf5" # Feature file format. " npy " or " hdf5 " is supported.
############################################################ GENERATOR NETWORK ARCHITECTURE SETTING ############################################################generator_type: "StyleMelGANGenerator" # Generator type.generator_params: in_channels: 128 aux_channels: 80 channels: 64 out_channels: 1 kernel_size: 9 dilation: 2 bias: True noise_upsample_scales: [4, 2, 2, 2] noise_upsample_activation: "LeakyReLU" noise_upsample_activation_params: negative_slope: 0.2 upsample_scales: [2, 2, 2, 2, 2, 2, 2, 2, 1] upsample_mode: "nearest" gated_function: "softmax" use_weight_norm: True
############################################################ DISCRIMINATOR NETWORK ARCHITECTURE SETTING ############################################################discriminator_type: "StyleMelGANDiscriminator" # Discriminator type.discriminator_params: repeats: 4 window_sizes: [512, 1024, 2048, 4096] pqmf_params: - [1, None, None, None] - [2, 62, 0.26700, 9.0] - [4, 62, 0.14200, 9.0] - [8, 62, 0.07949, 9.0] discriminator_params: out_channels: 1 kernel_sizes: [5, 3] channels: 16 max_downsample_channels: 512 bias: True downsample_scales: [4, 4, 4, 1] nonlinear_activation: "LeakyReLU" nonlinear_activation_params: negative_slope: 0.2 use_weight_norm: True
############################################################ STFT LOSS SETTING ############################################################stft_loss_params: fft_sizes: [1024, 2048, 512] # List of FFT size for STFT-based loss. hop_sizes: [120, 240, 50] # List of hop size for STFT-based loss win_lengths: [600, 1200, 240] # List of window length for STFT-based loss. window: "hann_window" # Window function for STFT-based losslambda_aux: 1.0 # Loss balancing coefficient for aux loss.
############################################################ ADVERSARIAL LOSS SETTING ############################################################lambda_adv: 1.0 # Loss balancing coefficient for adv loss.generator_adv_loss_params: average_by_discriminators: false # Whether to average loss by #discriminators. loss_type: hinge # Loss function type ("mse" or "hinge").discriminator_adv_loss_params: average_by_discriminators: false # Whether to average loss by #discriminators. loss_type: hinge # Loss function type ("mse" or "hinge").
############################################################ DATA LOADER SETTING ############################################################batch_size: 2 # Batch size.batch_max_steps: 8192 # Length of each audio in batch. Make sure dividable by hop_size.pin_memory: true # Whether to pin memory in Pytorch DataLoader.num_workers: 2 # Number of workers in Pytorch DataLoader.remove_short_samples: false # Whether to remove samples the length of which are less than batch_max_steps.allow_cache: true # Whether to allow cache in dataset. If true, it requires cpu memory.
############################################################ OPTIMIZER & SCHEDULER SETTING ############################################################generator_optimizer_type: Adamgenerator_optimizer_params: lr: 0.0001 # Generator's learning rate. betas: [0.5, 0.9] weight_decay: 0.0 # Generator's weight decay coefficient.generator_scheduler_params: step_size: 200000 # Generator's scheduler step size. gamma: 0.5 # Generator's scheduler gamma. # At each step size, lr will be multiplied by this parameter.generator_grad_norm: -1 # Generator's gradient norm.discriminator_optimizer_type: Adamdiscriminator_optimizer_params: lr: 0.00005 # Discriminator's learning rate. betas: [0.5, 0.9] weight_decay: 0.0 # Discriminator's weight decay coefficient.discriminator_scheduler_params: step_size: 200000 # Discriminator's scheduler step size. gamma: 0.5 # Discriminator's scheduler gamma. # At each step size, lr will be multiplied by this parameter.discriminator_grad_norm: -1 # Discriminator's gradient norm.
############################################################ INTERVAL SETTING ############################################################discriminator_train_start_steps: 5 # Number of steps to start to train discriminator.train_max_steps: 10 # Number of training steps.save_interval_steps: 5 # Interval steps to save checkpoint.eval_interval_steps: 5 # Interval steps to evaluate the network.log_interval_steps: 5 # Interval steps to record the training log.
############################################################ OTHER SETTING ############################################################num_save_intermediate_results: 4 # Number of results to be saved as intermediate results.123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155# This is the configuration file for yesno dataset.# Note that this configuration is just for debugging.
############################################################ FEATURE EXTRACTION SETTING ############################################################sampling_rate: 8000 # Sampling rate.fft_size: 1024 # FFT size.hop_size: 256 # Hop size.win_length: null # Window length. # If set to null, it will be the same as fft_size.window: "hann" # Window function.num_mels: 80 # Number of mel basis.fmin: 80 # Minimum freq in mel basis calculation.fmax: 3800 # Maximum frequency in mel basis calculation.global_gain_scale: 1.0 # Will be multiplied to all of waveform.trim_silence: true # Whether to trim the start and end of silence.trim_threshold_in_db: 20 # Need to tune carefully if the recording is not good.trim_frame_size: 1024 # Frame size in trimming.trim_hop_size: 256 # Hop size in trimming.format: "hdf5" # Feature file format. "npy" or "hdf5" is supported.
############################################################ GENERATOR NETWORK ARCHITECTURE SETTING ############################################################generator_type: UHiFiGANGeneratorgenerator_params: in_channels: 80 # Number of input channels. out_channels: 1 # Number of output channels. channels: 32 # Number of initial channels. kernel_size: 7 # Kernel size of initial and final conv layers. downsample_scales: [2, 2, 8, 8] # Downsampling scales. downsample_kernel_sizes: [4, 4, 16, 16] # Kernel size for downsampling layers. upsample_scales: [8, 8, 2, 2] # Upsampling scales. upsample_kernel_sizes: [16, 16, 4, 4] # Kernel size for upsampling layers. resblock_kernel_sizes: [3, 7, 11] # Kernel size for residual blocks. resblock_dilations: # Dilations for residual blocks. - [1, 3, 5] - [1, 3, 5] - [1, 3, 5] dropout: 0.1 # Probability of dropout. use_additional_convs: true # Whether to use additional conv layer in residual blocks. bias: true # Whether to use bias parameter in conv. nonlinear_activation: "LeakyReLU" # Nonlinear activation type. nonlinear_activation_params: # Nonlinear activation paramters. negative_slope: 0.1 use_weight_norm: true # Whether to apply weight normalization.
############################################################ DISCRIMINATOR NETWORK ARCHITECTURE SETTING ############################################################discriminator_type: HiFiGANMultiScaleMultiPeriodDiscriminatordiscriminator_params: scales: 2 # Number of multi-scale discriminator. scale_downsample_pooling: "AvgPool1d" # Pooling operation for scale discriminator. scale_downsample_pooling_params: kernel_size: 4 # Pooling kernel size. stride: 2 # Pooling stride. padding: 2 # Padding size. scale_discriminator_params: in_channels: 1 # Number of input channels. out_channels: 1 # Number of output channels. kernel_sizes: [15, 41, 5, 3] # List of kernel sizes. channels: 16 # Initial number of channels. max_downsample_channels: 32 # Maximum number of channels in downsampling conv layers. max_groups: 16 # Maximum number of groups in downsampling conv layers. bias: true downsample_scales: [4, 4, 4, 4] # Downsampling scales. nonlinear_activation: "LeakyReLU" # Nonlinear activation. nonlinear_activation_params: negative_slope: 0.1 follow_official_norm: true # Whether to follow the official norm setting. periods: [2, 3] # List of period for multi-period discriminator. period_discriminator_params: in_channels: 1 # Number of input channels. out_channels: 1 # Number of output channels. kernel_sizes: [5, 3] # List of kernel sizes. channels: 32 # Initial number of channels. downsample_scales: [4, 4, 4, 4] # Downsampling scales. max_downsample_channels: 32 # Maximum number of channels in downsampling conv layers. bias: true # Whether to use bias parameter in conv layer." nonlinear_activation: "LeakyReLU" # Nonlinear activation. nonlinear_activation_params: # Nonlinear activation paramters. negative_slope: 0.1 use_weight_norm: true # Whether to apply weight normalization. use_spectral_norm: false # Whether to apply spectral normalization.
############################################################ STFT LOSS SETTING ############################################################use_stft_loss: falseuse_mel_loss: truegenerator_adv_loss_params: average_by_discriminators: false # Whether to average loss by #discriminators.discriminator_adv_loss_params: average_by_discriminators: false # Whether to average loss by #discriminators.use_feat_match_loss: truefeat_match_loss_params: average_by_discriminators: false # Whether to average loss by # discriminators. average_by_layers: false # Whether to average loss by # layers in each discriminator. include_final_outputs: true # Whether to include final outputs in feat match loss calculation.
############################################################ ADVERSARIAL LOSS SETTING ############################################################lambda_aux: 45.0 # Loss balancing coefficient for STFT loss.lambda_adv: 1.0 # Loss balancing coefficient for adversarial loss.lambda_feat_match: 2.0 # Loss balancing coefficient for feat match loss..
############################################################ DATA LOADER SETTING ############################################################batch_size: 2 # Batch size.batch_max_steps: 4096 # Length of each audio in batch. Make sure dividable by hop_size.pin_memory: true # Whether to pin memory in Pytorch DataLoader.num_workers: 2 # Number of workers in Pytorch DataLoader.remove_short_samples: false # Whether to remove samples the length of which are less than batch_max_steps.allow_cache: true # Whether to allow cache in dataset. If true, it requires cpu memory.
############################################################ OPTIMIZER & SCHEDULER SETTING ############################################################generator_optimizer_type: AdamWgenerator_optimizer_params: lr: 0.0002 # Generator's learning rate. betas: [0.8, 0.99] # Generator's optimizer beta weight_decay: 0.0 # Generator's weight decay coefficient.generator_scheduler_type: ExponentialLRgenerator_scheduler_params: gamma: 0.999 # Generator's scheduler gamma.generator_grad_norm: -1 # Generator's gradient norm.discriminator_optimizer_type: AdamWdiscriminator_optimizer_params: lr: 0.0002 # Discriminator's learning rate. betas: [0.8, 0.99] # Discriminator's optimizer beta weight_decay: 0.0 # Discriminator's weight decay coefficient.discriminator_scheduler_type: ExponentialLRdiscriminator_scheduler_params: gamma: 0.999 # Discriminator's scheduler gamma.discriminator_grad_norm: -1 # Discriminator's gradient norm.
############################################################ INTERVAL SETTING ############################################################generator_train_start_steps: 5 # Number of steps to start to train discriminator.discriminator_train_start_steps: 0 # Number of steps to start to train discriminator.train_max_steps: 10 # Number of training steps.save_interval_steps: 5 # Interval steps to save checkpoint.eval_interval_steps: 5 # Interval steps to evaluate the network.log_interval_steps: 5 # Interval steps to record the training log.
############################################################ OTHER SETTING ############################################################num_save_intermediate_results: 4 # Number of results to be saved as intermediate results.12345678910111213141516171819202122232425262728#!/bin/bash
# Copyright 2019 Tomoki Hayashi# MIT License (https://opensource.org/licenses/MIT)
download_dir=$1
# check argumentsif [ $# != 1 ]; then echo "Usage: $0 <download_dir>" exit 1fi
set -euo pipefail
cwd=$(pwd)if [ ! -e "${download_dir}/LJSpeech-1.1" ]; then mkdir -p "${download_dir}" cd "${download_dir}" wget http://www.openslr.org/resources/1/waves_yesno.tar.gz tar -xvzf waves_yesno.tar.gz rm ./waves_yesno/README* rm waves_yesno.tar.gz cd "${cwd}" echo "Successfully downloaded data."else echo "Already exists. Skipped."fi12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788#!/bin/bash
# Copyright 2019 Tomoki Hayashi# MIT License (https://opensource.org/licenses/MIT)
# shellcheck disable=SC1091. ./path.sh || exit 1;
num_dev=10num_eval=10train_set="train_nodev"dev_set="dev"eval_set="eval"shuffle=falseuse_fake_segments=false
# shellcheck disable=SC1091. utils/parse_options.sh || exit 1;
db_root=$1data_dir=$2
# check argumentsif [ $# != 2 ]; then echo "Usage: $0 [Options] <db_root> <data_dir>" echo "e.g.: $0 downloads/waves_yesno data" echo "" echo "Options:" echo " --num_dev: number of development uttreances (default=10)." echo " --num_eval: number of evaluation uttreances (default=10)." echo " --train_set: name of train set (default=train_nodev)." echo " --dev_set: name of dev set (default=dev)." echo " --eval_set: name of eval set (default=eval)." echo " --shuffle: whether to perform shuffle in making dev / eval set (default=false)." echo " --use_fake_segments: whether to use fake segments (default=false)." exit 1fi
set -euo pipefail
[ ! -e "${data_dir}/all" ] && mkdir -p "${data_dir}/all"
# set filenamesscp="${data_dir}/all/wav.scp"segments="${data_dir}/all/segments"
# check file existence[ -e "${scp}" ] && rm "${scp}"[ -e "${segments}" ] && rm "${segments}"
# make all scpfind "${db_root}" -follow -name "*.wav" | sort | while read -r filename; do id=$(basename "${filename}" | sed -e "s/\.[^\.]*$//g") echo "${id} ${filename}" >> "${scp}" # NOTE(kan-bayashi): for integration test if "${use_fake_segments}"; then echo "${id}_1 ${id} 0.0 $(soxi -D "${filename}")" >> "${data_dir}/all/segments" echo "${id}_2 ${id} 0.0 $(soxi -D "${filename}")" >> "${data_dir}/all/segments" fidone
# splitnum_all=$(wc -l < "${scp}")if "${use_fake_segments}"; then num_all=$(wc -l < "${segments}")finum_deveval=$((num_dev + num_eval))num_train=$((num_all - num_deveval))utils/split_data.sh \ --num_first "${num_train}" \ --num_second "${num_deveval}" \ --shuffle "${shuffle}" \ "${data_dir}/all" \ "${data_dir}/${train_set}" \ "${data_dir}/deveval"utils/split_data.sh \ --num_first "${num_dev}" \ --num_second "${num_eval}" \ --shuffle "${shuffle}" \ "${data_dir}/deveval" \ "${data_dir}/${dev_set}" \ "${data_dir}/${eval_set}"
# remove tmp directoriesrm -rf "${data_dir}/all"rm -rf "${data_dir}/deveval"
echo "Successfully prepared data."123456789101112131415161718192021222324252627282930313233# cuda relatedexport CUDA_HOME=/usr/local/cuda-11.3export LD_LIBRARY_PATH="${CUDA_HOME}/lib64:${LD_LIBRARY_PATH}"
# path relatedexport PRJ_ROOT="${PWD}/../../.."if [ -e "${PRJ_ROOT}/tools/venv/bin/activate" ]; then # shellcheck disable=SC1090 . "${PRJ_ROOT}/tools/venv/bin/activate"fi
# python relatedexport OMP_NUM_THREADS=1export PYTHONIOENCODING=UTF-8export MPL_BACKEND=Agg
# check installationif ! command -v parallel-wavegan-train > /dev/null; then echo "Error: It seems setup is not finished." >&2 echo "Error: Please setup your environment by following README.md" >&2 return 1fiif ! command -v jq > /dev/null; then echo "Error: It seems jq is not installed." >&2 echo "Error: Please install via \`sudo apt-get install jq\`." >&2 echo "Error: If you do not have sudo, please download from https://stedolan.github.io/jq/download/." >&2 return 1fiif ! command -v yq > /dev/null; then echo "Error: It seems yq is not installed." >&2 echo "Error: Please install via \`pip install yq\`." >&2 return 1fi123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178#!/bin/bash
# Copyright 2019 Tomoki Hayashi# MIT License (https://opensource.org/licenses/MIT)
. ./cmd.sh || exit 1;. ./path.sh || exit 1;
# basic settingsstage=-1 # stage to startstop_stage=100 # stage to stopverbose=1 # verbosity level (lower is less info)n_gpus=0 # number of gpus in trainingn_jobs=2 # number of parallel jobs in feature extraction
# NOTE(kan-bayashi): renamed to conf to avoid conflict in parse_options.shconf=conf/parallel_wavegan.v1.debug.yaml
# directory path settingdownload_dir=downloads # direcotry to save downloaded filesdumpdir=dump # directory to dump features
# data settinguse_fake_segments=false # for testing
# training related settingtag="" # tag for directory to save modelresume="" # checkpoint path to resume training # (e.g. <path>/<to>/checkpoint-10000steps.pkl)
# decoding related settingcheckpoint="" # checkpoint path to be used for decoding # if not provided, the latest one will be used # (e.g. <path>/<to>/checkpoint-400000steps.pkl)
# shellcheck disable=SC1091. utils/parse_options.sh || exit 1;
train_set="train_nodev" # name of training data directorydev_set="dev" # name of development data direcotryeval_set="eval" # name of evaluation data direcotry
set -euo pipefail
if [ "${stage}" -le -1 ] && [ "${stop_stage}" -ge -1 ]; then echo "Stage -1: Data download" local/data_download.sh "${download_dir}"fi
if [ "${stage}" -le 0 ] && [ "${stop_stage}" -ge 0 ]; then echo "Stage 0: Data preparation" local/data_prep.sh \ --use_fake_segments "${use_fake_segments}" \ --train_set "${train_set}" \ --dev_set "${dev_set}" \ --eval_set "${eval_set}" \ "${download_dir}/waves_yesno" datafi
stats_ext=$(grep -q "hdf5" <(yq ".format" "${conf}") && echo "h5" || echo "npy")if [ "${stage}" -le 1 ] && [ "${stop_stage}" -ge 1 ]; then echo "Stage 1: Feature extraction" # extract raw features pids=() for name in "${train_set}" "${dev_set}" "${eval_set}"; do ( [ ! -e "${dumpdir}/${name}/raw" ] && mkdir -p "${dumpdir}/${name}/raw" echo "Feature extraction start. See the progress via ${dumpdir}/${name}/raw/preprocessing.*.log." utils/make_subset_data.sh "data/${name}" "${n_jobs}" "${dumpdir}/${name}/raw" ${train_cmd} JOB=1:${n_jobs} "${dumpdir}/${name}/raw/preprocessing.JOB.log" \ parallel-wavegan-preprocess \ --config "${conf}" \ --scp "${dumpdir}/${name}/raw/wav.JOB.scp" \ --dumpdir "${dumpdir}/${name}/raw/dump.JOB" \ --verbose "${verbose}" echo "Successfully finished feature extraction of ${name} set." ) & pids+=($!) done i=0; for pid in "${pids[@]}"; do wait "${pid}" || ((++i)); done [ "${i}" -gt 0 ] && echo "$0: ${i} background jobs are failed." && exit 1; echo "Successfully finished feature extraction."
# calculate statistics for normalization echo "Statistics computation start. See the progress via ${dumpdir}/${train_set}/compute_statistics.log." ${train_cmd} "${dumpdir}/${train_set}/compute_statistics.log" \ parallel-wavegan-compute-statistics \ --config "${conf}" \ --rootdir "${dumpdir}/${train_set}/raw" \ --dumpdir "${dumpdir}/${train_set}" \ --verbose "${verbose}" echo "Successfully finished calculation of statistics."
# normalize and dump them pids=() for name in "${train_set}" "${dev_set}" "${eval_set}"; do ( [ ! -e "${dumpdir}/${name}/norm" ] && mkdir -p "${dumpdir}/${name}/norm" echo "Nomalization start. See the progress via ${dumpdir}/${name}/norm/normalize.*.log." ${train_cmd} JOB=1:${n_jobs} "${dumpdir}/${name}/norm/normalize.JOB.log" \ parallel-wavegan-normalize \ --config "${conf}" \ --stats "${dumpdir}/${train_set}/stats.${stats_ext}" \ --rootdir "${dumpdir}/${name}/raw/dump.JOB" \ --dumpdir "${dumpdir}/${name}/norm/dump.JOB" \ --verbose "${verbose}" echo "Successfully finished normalization of ${name} set." ) & pids+=($!) done i=0; for pid in "${pids[@]}"; do wait "${pid}" || ((++i)); done [ "${i}" -gt 0 ] && echo "$0: ${i} background jobs are failed." && exit 1; echo "Successfully finished normalization."fi
if [ -z "${tag}" ]; then expdir="exp/${train_set}_yesno_$(basename "${conf}" .yaml)"else expdir="exp/${train_set}_yesno_${tag}"fiif [ "${stage}" -le 2 ] && [ "${stop_stage}" -ge 2 ]; then echo "Stage 2: Network training" [ ! -e "${expdir}" ] && mkdir -p "${expdir}" cp "${dumpdir}/${train_set}/stats.${stats_ext}" "${expdir}" if [ "${n_gpus}" -gt 1 ]; then train="python -m parallel_wavegan.distributed.launch --nproc_per_node ${n_gpus} -c parallel-wavegan-train" else train="parallel-wavegan-train" fi echo "Training start. See the progress via ${expdir}/train.log." ${cuda_cmd} --gpu "${n_gpus}" "${expdir}/train.log" \ ${train} \ --config "${conf}" \ --train-dumpdir "${dumpdir}/${train_set}/norm" \ --dev-dumpdir "${dumpdir}/${dev_set}/norm" \ --outdir "${expdir}" \ --resume "${resume}" \ --verbose "${verbose}" echo "Successfully finished training."fi
if [ "${stage}" -le 3 ] && [ "${stop_stage}" -ge 3 ]; then echo "Stage 3: Network decoding" # shellcheck disable=SC2012 [ -z "${checkpoint}" ] && checkpoint="$(ls -dt "${expdir}"/*.pkl | head -1 || true)" outdir="${expdir}/wav/$(basename "${checkpoint}" .pkl)" pids=() for name in "${dev_set}" "${eval_set}"; do ( [ ! -e "${outdir}/${name}" ] && mkdir -p "${outdir}/${name}" [ "${n_gpus}" -gt 1 ] && n_gpus=1 echo "Decoding start. See the progress via ${outdir}/${name}/decode.log." ${cuda_cmd} --gpu "${n_gpus}" "${outdir}/${name}/decode.log" \ parallel-wavegan-decode \ --dumpdir "${dumpdir}/${name}/norm" \ --checkpoint "${checkpoint}" \ --outdir "${outdir}/${name}" \ --verbose "${verbose}" echo "Successfully finished decoding of ${name} set."
# NOTE(kan-bayashi): Extra decoding for debugging echo "Decoding start. See the progress via ${outdir}/${name}/decode.log." ${cuda_cmd} --gpu "${n_gpus}" "${outdir}/${name}/decode.log" \ parallel-wavegan-decode \ --normalize-before \ --dumpdir "${dumpdir}/${name}/raw" \ --checkpoint "${checkpoint}" \ --outdir "${outdir}/${name}" \ --verbose "${verbose}" echo "Successfully finished decoding of ${name} set." ) & pids+=($!) done i=0; for pid in "${pids[@]}"; do wait "${pid}" || ((++i)); done [ "${i}" -gt 0 ] && echo "$0: ${i} background jobs are failed." && exit 1; echo "Successfully finished decoding."fiecho "Finished."12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091# ====== About run.pl, queue.pl, slurm.pl, and ssh.pl ======# Usage: <cmd>.pl [options] JOB=1:<nj> <log> <command...># e.g.# run.pl --mem 4G JOB=1:10 echo.JOB.log echo JOB## Options:# --time <time>: Limit the maximum time to execute.# --mem <mem>: Limit the maximum memory usage.# -–max-jobs-run <njob>: Limit the number parallel jobs. This is ignored for non-array jobs.# --num-threads <ngpu>: Specify the number of CPU core.# --gpu <ngpu>: Specify the number of GPU devices.# --config: Change the configuration file from default.## "JOB=1:10" is used for "array jobs" and it can control the number of parallel jobs.# The left string of "=", i.e. "JOB", is replaced by <N>(Nth job) in the command and the log file name,# e.g. "echo JOB" is changed to "echo 3" for the 3rd job and "echo 8" for 8th job respectively.# Note that the number must start with a positive number, so you can't use "JOB=0:10" for example.## run.pl, queue.pl, slurm.pl, and ssh.pl have unified interface, not depending on its backend.# These options are mapping to specific options for each backend and# it is configured by "conf/queue.conf" and "conf/slurm.conf" by default.# If jobs failed, your configuration might be wrong for your environment.### The official documentaion for run.pl, queue.pl, slurm.pl, and ssh.pl:# "Parallelization in Kaldi": http://kaldi-asr.org/doc/queue.html# =========================================================~
# Select the backend used by run.sh from "local", "stdout", "sge", "slurm", or "ssh"cmd_backend="stdout"
# Local machine, without any Job scheduling systemif [ "${cmd_backend}" = local ]; then
# The other usage export train_cmd="utils/run.pl" # Used for "*_train.py": "--gpu" is appended optionally by run.sh export cuda_cmd="utils/run.pl" # Used for "*_recog.py" export decode_cmd="utils/run.pl"
# Local machine, without any Job scheduling systemelif [ "${cmd_backend}" = stdout ]; then
# The other usage export train_cmd="utils/stdout.pl" # Used for "*_train.py": "--gpu" is appended optionally by run.sh export cuda_cmd="utils/stdout.pl" # Used for "*_recog.py" export decode_cmd="utils/stdout.pl"
# "qsub" (SGE, Torque, PBS, etc.)elif [ "${cmd_backend}" = sge ]; then # The default setting is written in conf/queue.conf. # You must change "-q g.q" for the "queue" for your environment. # To know the "queue" names, type "qhost -q" # Note that to use "--gpu *", you have to setup "complex_value" for the system scheduler.
export train_cmd="utils/queue.pl" export cuda_cmd="utils/queue.pl" export decode_cmd="utils/queue.pl"
# "sbatch" (Slurm)elif [ "${cmd_backend}" = slurm ]; then # The default setting is written in conf/slurm.conf. # You must change "-p cpu" and "-p gpu" for the "partion" for your environment. # To know the "partion" names, type "sinfo". # You can use "--gpu * " by defualt for slurm and it is interpreted as "--gres gpu:*" # The devices are allocated exclusively using "${CUDA_VISIBLE_DEVICES}".
export train_cmd="utils/slurm.pl" export cuda_cmd="utils/slurm.pl" export decode_cmd="utils/slurm.pl"
elif [ "${cmd_backend}" = ssh ]; then # You have to create ".queue/machines" to specify the host to execute jobs. # e.g. .queue/machines # host1 # host2 # host3 # Assuming you can login them without any password, i.e. You have to set ssh keys.
export train_cmd="utils/ssh.pl" export cuda_cmd="utils/ssh.pl" export decode_cmd="utils/ssh.pl"
else echo "$0: Error: Unknown cmd_backend=${cmd_backend}" 1>&2 return 1fiaudio/shiftyspeech/speech_synthesis/vocoders/ParallelWaveGAN/egs/template_single_spk/voc1/local/data_prep.shDeleted-87
audio/shiftyspeech/speech_synthesis/vocoders/ParallelWaveGAN/egs/template_single_spk/voc1/path.shDeleted-33
audio/shiftyspeech/speech_synthesis/vocoders/ParallelWaveGAN/egs/template_single_spk/voc1/run.shDeleted-188
audio/shiftyspeech/speech_synthesis/vocoders/ParallelWaveGAN/egs/vctk/hubert_voc1/cmd.shDeleted-91
audio/shiftyspeech/speech_synthesis/vocoders/ParallelWaveGAN/egs/vctk/hubert_voc1/conf/hifigan_hubert.v1.yamlDeleted-176
audio/shiftyspeech/speech_synthesis/vocoders/ParallelWaveGAN/egs/vctk/hubert_voc1/conf/hifigan_hubert_24k.v1.yamlDeleted-176
audio/shiftyspeech/speech_synthesis/vocoders/ParallelWaveGAN/egs/vctk/hubert_voc1/conf/slurm.confDeleted-12
audio/shiftyspeech/speech_synthesis/vocoders/ParallelWaveGAN/egs/vctk/hubert_voc1/conf/style_melgan_hubert.v1.yamlDeleted-145
audio/shiftyspeech/speech_synthesis/vocoders/ParallelWaveGAN/egs/vctk/hubert_voc1/path.shDeleted-33
audio/shiftyspeech/speech_synthesis/vocoders/ParallelWaveGAN/egs/vctk/hubert_voc1/run.shDeleted-151
audio/shiftyspeech/speech_synthesis/vocoders/ParallelWaveGAN/egs/vctk/voc1/cmd.shDeleted-91
audio/shiftyspeech/speech_synthesis/vocoders/ParallelWaveGAN/egs/vctk/voc1/conf/hifigan.v1.yamlDeleted-180
audio/shiftyspeech/speech_synthesis/vocoders/ParallelWaveGAN/egs/vctk/voc1/conf/multi_band_melgan.v2.yamlDeleted-154
audio/shiftyspeech/speech_synthesis/vocoders/ParallelWaveGAN/egs/vctk/voc1/conf/parallel_wavegan.v1.long.yamlDeleted-122
audio/shiftyspeech/speech_synthesis/vocoders/ParallelWaveGAN/egs/vctk/voc1/conf/parallel_wavegan.v1.yamlDeleted-122
audio/shiftyspeech/speech_synthesis/vocoders/ParallelWaveGAN/egs/vctk/voc1/conf/slurm.confDeleted-12
audio/shiftyspeech/speech_synthesis/vocoders/ParallelWaveGAN/egs/vctk/voc1/conf/style_melgan.v1.yamlDeleted-147
audio/shiftyspeech/speech_synthesis/vocoders/ParallelWaveGAN/egs/vctk/voc1/local/data_download.shDeleted-37
audio/shiftyspeech/speech_synthesis/vocoders/ParallelWaveGAN/egs/vctk/voc1/local/data_prep.shDeleted-118
audio/shiftyspeech/speech_synthesis/vocoders/ParallelWaveGAN/egs/vctk/voc1/local/decode_from_text.pyDeleted-174
audio/shiftyspeech/speech_synthesis/vocoders/ParallelWaveGAN/egs/vctk/voc1/local/preprocess_hubert.pyDeleted-249
audio/shiftyspeech/speech_synthesis/vocoders/ParallelWaveGAN/egs/vctk/voc1/path.shDeleted-33
audio/shiftyspeech/speech_synthesis/vocoders/ParallelWaveGAN/egs/vctk/voc1/run.shDeleted-188
audio/shiftyspeech/speech_synthesis/vocoders/ParallelWaveGAN/egs/vctk/vq1/cmd.shDeleted-91
audio/shiftyspeech/speech_synthesis/vocoders/ParallelWaveGAN/egs/vctk/vq1/conf/conditioned_melgan_vae.v3.yamlDeleted-130
audio/shiftyspeech/speech_synthesis/vocoders/ParallelWaveGAN/egs/vctk/vq1/conf/local_conditioned_melgan_vae.v3.yamlDeleted-134
audio/shiftyspeech/speech_synthesis/vocoders/ParallelWaveGAN/egs/vctk/vq1/conf/slurm.confDeleted-12
audio/shiftyspeech/speech_synthesis/vocoders/ParallelWaveGAN/egs/vctk/vq1/local/data_download.shDeleted-37
audio/shiftyspeech/speech_synthesis/vocoders/ParallelWaveGAN/egs/vctk/vq1/local/data_prep.shDeleted-121
audio/shiftyspeech/speech_synthesis/vocoders/ParallelWaveGAN/egs/vctk/vq1/local/data_prep_2mix.shDeleted-54
audio/shiftyspeech/speech_synthesis/vocoders/ParallelWaveGAN/egs/vctk/vq1/local/decode_from_text.pyDeleted-174
audio/shiftyspeech/speech_synthesis/vocoders/ParallelWaveGAN/egs/vctk/vq1/local/setup_for_vc.pyDeleted-222
audio/shiftyspeech/speech_synthesis/vocoders/ParallelWaveGAN/egs/vctk/vq1/path.shDeleted-33
audio/shiftyspeech/speech_synthesis/vocoders/ParallelWaveGAN/egs/vctk/vq1/run.shDeleted-295
audio/shiftyspeech/speech_synthesis/vocoders/ParallelWaveGAN/egs/yesno/voc1/cmd.shDeleted-91
audio/shiftyspeech/speech_synthesis/vocoders/ParallelWaveGAN/egs/yesno/voc1/conf/hifigan.v1.debug.yamlDeleted-152
audio/shiftyspeech/speech_synthesis/vocoders/ParallelWaveGAN/egs/yesno/voc1/conf/melgan.v1.debug.yamlDeleted-112
audio/shiftyspeech/speech_synthesis/vocoders/ParallelWaveGAN/egs/yesno/voc1/conf/melgan.v3.debug.yamlDeleted-121
audio/shiftyspeech/speech_synthesis/vocoders/ParallelWaveGAN/egs/yesno/voc1/conf/multi_band_melgan.v1.debug.yamlDeleted-126
audio/shiftyspeech/speech_synthesis/vocoders/ParallelWaveGAN/egs/yesno/voc1/conf/parallel_wavegan.v1.debug.diff_fs.yamlDeleted-121
audio/shiftyspeech/speech_synthesis/vocoders/ParallelWaveGAN/egs/yesno/voc1/conf/parallel_wavegan.v1.debug.npy.yamlDeleted-121
audio/shiftyspeech/speech_synthesis/vocoders/ParallelWaveGAN/egs/yesno/voc1/conf/parallel_wavegan.v1.debug.yamlDeleted-120
audio/shiftyspeech/speech_synthesis/vocoders/ParallelWaveGAN/egs/yesno/voc1/conf/slurm.confDeleted-12
audio/shiftyspeech/speech_synthesis/vocoders/ParallelWaveGAN/egs/yesno/voc1/conf/style_melgan.v1.debug.yamlDeleted-135
audio/shiftyspeech/speech_synthesis/vocoders/ParallelWaveGAN/egs/yesno/voc1/conf/uhifigan.v1.debug.yamlDeleted-155
audio/shiftyspeech/speech_synthesis/vocoders/ParallelWaveGAN/egs/yesno/voc1/local/data_download.shDeleted-28
audio/shiftyspeech/speech_synthesis/vocoders/ParallelWaveGAN/egs/yesno/voc1/local/data_prep.shDeleted-88
audio/shiftyspeech/speech_synthesis/vocoders/ParallelWaveGAN/egs/yesno/voc1/path.shDeleted-33
audio/shiftyspeech/speech_synthesis/vocoders/ParallelWaveGAN/egs/yesno/voc1/run.shDeleted-178
audio/shiftyspeech/speech_synthesis/vocoders/ParallelWaveGAN/egs/yesno/vq1/cmd.shDeleted-91