File size: 3,567 Bytes
f7498a7
 
 
 
 
 
 
 
19f775a
 
 
 
 
 
f7498a7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19f775a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
d1b8469
19f775a
 
 
 
d1b8469
f7498a7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#!/bin/bash
# Copyright 2024 Alibaba Inc. All Rights Reserved.


data_url=www.openslr.org/resources/60
data_dir=data
pretrained_model_dir=./pretrained_models/CosyVoice2-0.5B

# if [ ${stage} -le -1 ] && [ ${stop_stage} -ge -1 ]; then
#   echo "Data Download"
#   for part in test-clean; do
#     local/download_and_untar.sh ${data_dir} ${data_url} ${part}
#   done
# fi

# if [ ${stage} -le 0 ] && [ ${stop_stage} -ge 0 ]; then
#   echo "Data preparation, prepare wav.scp/text/utt2spk/spk2utt"
#   for x in train-clean-100 train-clean-360 train-other-500 dev-clean dev-other test-clean test-other; do
#     mkdir -p data/$x
#     python local/prepare_data.py --src_dir $data_dir/LibriTTS/$x --des_dir data/$x
#   done
# fi

# if [ ${stage} -le 1 ] && [ ${stop_stage} -ge 1 ]; then
#   echo "Extract campplus speaker embedding, you will get spk2embedding.pt and utt2embedding.pt in data/$x dir"
#   for x in train-clean-100 train-clean-360 train-other-500 dev-clean dev-other test-clean test-other; do
#     tools/extract_embedding.py --dir data/$x \
#       --onnx_path $pretrained_model_dir/campplus.onnx
#   done
# fi

# if [ ${stage} -le 2 ] && [ ${stop_stage} -ge 2 ]; then
#   echo "Extract discrete speech token, you will get utt2speech_token.pt in data/$x dir"
#   for x in train-clean-100 train-clean-360 train-other-500 dev-clean dev-other test-clean test-other; do
#     tools/extract_speech_token.py --dir data/$x \
#       --onnx_path $pretrained_model_dir/speech_tokenizer_v2.onnx
#   done
# fi

# if [ ${stage} -le 3 ] && [ ${stop_stage} -ge 3 ]; then
#   echo "Prepare required parquet format data, you should have prepared wav.scp/text/utt2spk/spk2utt/utt2embedding.pt/spk2embedding.pt/utt2speech_token.pt"
#   for x in train-clean-100 train-clean-360 train-other-500 dev-clean dev-other test-clean test-other; do
#     mkdir -p data/$x/parquet
#     tools/make_parquet_list.py --num_utts_per_parquet 1000 \
#       --num_processes 10 \
#       --src_dir data/$x \
#       --des_dir data/$x/parquet
#   done
# fi

# train llm
export CUDA_VISIBLE_DEVICES="0"
num_gpus=$(echo $CUDA_VISIBLE_DEVICES | awk -F "," '{print NF}')
job_id=1986
dist_backend="nccl"
num_workers=2
prefetch=100
train_engine=torch_ddp
model=flow

torchrun --nnodes=1 --nproc_per_node=$num_gpus --rdzv_id=$job_id --rdzv_backend="c10d" --rdzv_endpoint="localhost:1234" \
  train.py \
  --train_engine $train_engine \
  --config config.yaml \
  --train_data data/data.list \
  --cv_data data/data.list \
  --qwen_pretrain_path $pretrained_model_dir/CosyVoice-BlankEN \
  --model $model \
  --model_dir /data/checkpoint/$model/ \
  --num_workers ${num_workers} \
  --prefetch ${prefetch} \
  --pin_memory \
  --use_amp \
  --checkpoint /data/checkpoint/flow/epoch_88_step_14001.pt
# # average model
# average_num=5
# if [ ${stage} -le 6 ] && [ ${stop_stage} -ge 6 ]; then
#   for model in llm flow hifigan; do
#     decode_checkpoint=`pwd`/exp/cosyvoice/$model/$train_engine/${model}.pt
#     echo "do model average and final checkpoint is $decode_checkpoint"
#     python cosyvoice/bin/average_model.py \
#       --dst_model $decode_checkpoint \
#       --src_path `pwd`/exp/cosyvoice/$model/$train_engine  \
#       --num ${average_num} \
#       --val_best
#   done
# fi

# if [ ${stage} -le 7 ] && [ ${stop_stage} -ge 7 ]; then
#   echo "Export your model for inference speedup. Remember copy your llm or flow model to model_dir"
#   python cosyvoice/bin/export_jit.py --model_dir $pretrained_model_dir
#   python cosyvoice/bin/export_onnx.py --model_dir $pretrained_model_dir
# fi