mirror of
https://github.com/k2-fsa/icefall.git
synced 2025-08-08 09:32:20 +00:00
* init * isort formatted * minor updates * Create shared * Update prepare_tokens_vctk.py * Update prepare_tokens_vctk.py * Update prepare_tokens_vctk.py * Update prepare.sh * updated * Update train.py * Update train.py * Update tts_datamodule.py * Update train.py * Update train.py * Update train.py * Update train.py * Update train.py * Update train.py * fixed formatting issue * Update infer.py * removed redundant files * Create monotonic_align * removed redundant files * created symlinks * Update prepare.sh * minor adjustments * Create requirements_tts.txt * Update requirements_tts.txt added version constraints * Update infer.py * Update infer.py * Update infer.py * updated docs * Update export-onnx.py * Update export-onnx.py * Update test_onnx.py * updated requirements.txt * Update test_onnx.py * Update test_onnx.py * docs updated * docs fixed * minor updates
126 lines
4.1 KiB
Bash
Executable File
126 lines
4.1 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
# fix segmentation fault reported in https://github.com/k2-fsa/icefall/issues/674
|
|
export PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python
|
|
|
|
set -eou pipefail
|
|
|
|
stage=0
|
|
stop_stage=100
|
|
|
|
dl_dir=$PWD/download
|
|
|
|
. shared/parse_options.sh || exit 1
|
|
|
|
# All files generated by this script are saved in "data".
|
|
# You can safely remove "data" and rerun this script to regenerate it.
|
|
mkdir -p data
|
|
|
|
log() {
|
|
# This function is from espnet
|
|
local fname=${BASH_SOURCE[1]##*/}
|
|
echo -e "$(date '+%Y-%m-%d %H:%M:%S') (${fname}:${BASH_LINENO[0]}:${FUNCNAME[1]}) $*"
|
|
}
|
|
|
|
log "dl_dir: $dl_dir"
|
|
|
|
if [ $stage -le -1 ] && [ $stop_stage -ge -1 ]; then
|
|
log "Stage -1: build monotonic_align lib"
|
|
if [ ! -d vits/monotonic_align/build ]; then
|
|
cd vits/monotonic_align
|
|
python setup.py build_ext --inplace
|
|
cd ../../
|
|
else
|
|
log "monotonic_align lib already built"
|
|
fi
|
|
fi
|
|
|
|
if [ $stage -le 0 ] && [ $stop_stage -ge 0 ]; then
|
|
log "Stage 0: Download data"
|
|
|
|
# The directory $dl_dir/LJSpeech-1.1 will contain:
|
|
# - wavs, which contains the audio files
|
|
# - metadata.csv, which provides the transcript text for each audio clip
|
|
|
|
# If you have pre-downloaded it to /path/to/LJSpeech-1.1, you can create a symlink
|
|
#
|
|
# ln -sfv /path/to/LJSpeech-1.1 $dl_dir/LJSpeech-1.1
|
|
#
|
|
if [ ! -d $dl_dir/LJSpeech-1.1 ]; then
|
|
lhotse download ljspeech $dl_dir
|
|
fi
|
|
fi
|
|
|
|
if [ $stage -le 1 ] && [ $stop_stage -ge 1 ]; then
|
|
log "Stage 1: Prepare LJSpeech manifest"
|
|
# We assume that you have downloaded the LJSpeech corpus
|
|
# to $dl_dir/LJSpeech
|
|
mkdir -p data/manifests
|
|
if [ ! -e data/manifests/.ljspeech.done ]; then
|
|
lhotse prepare ljspeech $dl_dir/LJSpeech-1.1 data/manifests
|
|
touch data/manifests/.ljspeech.done
|
|
fi
|
|
fi
|
|
|
|
if [ $stage -le 2 ] && [ $stop_stage -ge 2 ]; then
|
|
log "Stage 2: Compute spectrogram for LJSpeech"
|
|
mkdir -p data/spectrogram
|
|
if [ ! -e data/spectrogram/.ljspeech.done ]; then
|
|
./local/compute_spectrogram_ljspeech.py
|
|
touch data/spectrogram/.ljspeech.done
|
|
fi
|
|
|
|
if [ ! -e data/spectrogram/.ljspeech-validated.done ]; then
|
|
log "Validating data/spectrogram for LJSpeech"
|
|
python3 ./local/validate_manifest.py \
|
|
data/spectrogram/ljspeech_cuts_all.jsonl.gz
|
|
touch data/spectrogram/.ljspeech-validated.done
|
|
fi
|
|
fi
|
|
|
|
if [ $stage -le 3 ] && [ $stop_stage -ge 3 ]; then
|
|
log "Stage 3: Prepare phoneme tokens for LJSpeech"
|
|
if [ ! -e data/spectrogram/.ljspeech_with_token.done ]; then
|
|
./local/prepare_tokens_ljspeech.py
|
|
mv data/spectrogram/ljspeech_cuts_with_tokens_all.jsonl.gz \
|
|
data/spectrogram/ljspeech_cuts_all.jsonl.gz
|
|
touch data/spectrogram/.ljspeech_with_token.done
|
|
fi
|
|
fi
|
|
|
|
if [ $stage -le 4 ] && [ $stop_stage -ge 4 ]; then
|
|
log "Stage 4: Split the LJSpeech cuts into train, valid and test sets"
|
|
if [ ! -e data/spectrogram/.ljspeech_split.done ]; then
|
|
lhotse subset --last 600 \
|
|
data/spectrogram/ljspeech_cuts_all.jsonl.gz \
|
|
data/spectrogram/ljspeech_cuts_validtest.jsonl.gz
|
|
lhotse subset --first 100 \
|
|
data/spectrogram/ljspeech_cuts_validtest.jsonl.gz \
|
|
data/spectrogram/ljspeech_cuts_valid.jsonl.gz
|
|
lhotse subset --last 500 \
|
|
data/spectrogram/ljspeech_cuts_validtest.jsonl.gz \
|
|
data/spectrogram/ljspeech_cuts_test.jsonl.gz
|
|
|
|
rm data/spectrogram/ljspeech_cuts_validtest.jsonl.gz
|
|
|
|
n=$(( $(gunzip -c data/spectrogram/ljspeech_cuts_all.jsonl.gz | wc -l) - 600 ))
|
|
lhotse subset --first $n \
|
|
data/spectrogram/ljspeech_cuts_all.jsonl.gz \
|
|
data/spectrogram/ljspeech_cuts_train.jsonl.gz
|
|
touch data/spectrogram/.ljspeech_split.done
|
|
fi
|
|
fi
|
|
|
|
if [ $stage -le 5 ] && [ $stop_stage -ge 5 ]; then
|
|
log "Stage 5: Generate token file"
|
|
# We assume you have installed g2p_en and espnet_tts_frontend.
|
|
# If not, please install them with:
|
|
# - g2p_en: `pip install g2p_en`, refer to https://github.com/Kyubyong/g2p
|
|
# - espnet_tts_frontend, `pip install espnet_tts_frontend`, refer to https://github.com/espnet/espnet_tts_frontend/
|
|
if [ ! -e data/tokens.txt ]; then
|
|
./local/prepare_token_file.py \
|
|
--manifest-file data/spectrogram/ljspeech_cuts_train.jsonl.gz \
|
|
--tokens data/tokens.txt
|
|
fi
|
|
fi
|