|
|
|
|
|
|
|
|
|
|
|
|
|
exp_dir=$(cd `dirname $0`; pwd) |
|
work_dir=$(dirname $(dirname $(dirname $(dirname $exp_dir)))) |
|
|
|
export WORK_DIR=$work_dir |
|
export PYTHONPATH=$work_dir |
|
export PYTHONIOENCODING=UTF-8 |
|
|
|
|
|
options=$(getopt -o c:n:s --long gpu:,config:,name:,stage:,checkpoint:,resume_type:,main_process_port:,infer_mode:,infer_datasets:,infer_feature_dir:,infer_audio_dir:,infer_expt_dir:,infer_output_dir: -- "$@") |
|
eval set -- "$options" |
|
|
|
while true; do |
|
case $1 in |
|
|
|
-c | --config) shift; exp_config=$1 ; shift ;; |
|
|
|
-n | --name) shift; exp_name=$1 ; shift ;; |
|
|
|
-s | --stage) shift; running_stage=$1 ; shift ;; |
|
|
|
--gpu) shift; gpu=$1 ; shift ;; |
|
|
|
|
|
--checkpoint) shift; checkpoint=$1 ; shift ;; |
|
|
|
--resume_type) shift; resume_type=$1 ; shift ;; |
|
|
|
--main_process_port) shift; main_process_port=$1 ; shift ;; |
|
|
|
|
|
--infer_mode) shift; infer_mode=$1 ; shift ;; |
|
|
|
--infer_datasets) shift; infer_datasets=$1 ; shift ;; |
|
|
|
--infer_feature_dir) shift; infer_feature_dir=$1 ; shift ;; |
|
|
|
--infer_audio_dir) shift; infer_audio_dir=$1 ; shift ;; |
|
|
|
--infer_expt_dir) shift; infer_expt_dir=$1 ; shift ;; |
|
|
|
--infer_output_dir) shift; infer_output_dir=$1 ; shift ;; |
|
|
|
--) shift ; break ;; |
|
*) echo "Invalid option: $1" exit 1 ;; |
|
esac |
|
done |
|
|
|
|
|
|
|
if [ -z "$running_stage" ]; then |
|
echo "[Error] Please specify the running stage" |
|
exit 1 |
|
fi |
|
|
|
if [ -z "$exp_config" ]; then |
|
exp_config="${exp_dir}"/exp_config.json |
|
fi |
|
echo "Exprimental Configuration File: $exp_config" |
|
|
|
if [ -z "$gpu" ]; then |
|
gpu="0" |
|
fi |
|
|
|
if [ -z "$main_process_port" ]; then |
|
main_process_port=29500 |
|
fi |
|
echo "Main Process Port: $main_process_port" |
|
|
|
|
|
if [ $running_stage -eq 1 ]; then |
|
CUDA_VISIBLE_DEVICES=$gpu python "${work_dir}"/bins/vocoder/preprocess.py \ |
|
--config $exp_config \ |
|
--num_workers 8 |
|
fi |
|
|
|
|
|
if [ $running_stage -eq 2 ]; then |
|
if [ -z "$exp_name" ]; then |
|
echo "[Error] Please specify the experiments name" |
|
exit 1 |
|
fi |
|
echo "Exprimental Name: $exp_name" |
|
|
|
CUDA_VISIBLE_DEVICES=$gpu accelerate launch \ |
|
--main_process_port "$main_process_port" \ |
|
"${work_dir}"/bins/vocoder/train.py \ |
|
--config "$exp_config" \ |
|
--exp_name "$exp_name" \ |
|
--log_level info \ |
|
--checkpoint "$checkpoint" \ |
|
--resume_type "$resume_type" |
|
fi |
|
|
|
|
|
if [ $running_stage -eq 3 ]; then |
|
if [ -z "$infer_expt_dir" ]; then |
|
echo "[Error] Please specify the experimental directionary. The value is like [Your path to save logs and checkpoints]/[YourExptName]" |
|
exit 1 |
|
fi |
|
|
|
if [ -z "$infer_output_dir" ]; then |
|
infer_output_dir="$infer_expt_dir/result" |
|
fi |
|
|
|
if [ $infer_mode = "infer_from_dataset" ]; then |
|
CUDA_VISIBLE_DEVICES=$gpu accelerate launch "$work_dir"/bins/vocoder/inference.py \ |
|
--config $exp_config \ |
|
--infer_mode $infer_mode \ |
|
--infer_datasets $infer_datasets \ |
|
--vocoder_dir $infer_expt_dir \ |
|
--output_dir $infer_output_dir \ |
|
--log_level debug |
|
fi |
|
|
|
if [ $infer_mode = "infer_from_feature" ]; then |
|
CUDA_VISIBLE_DEVICES=$gpu accelerate launch "$work_dir"/bins/vocoder/inference.py \ |
|
--config $exp_config \ |
|
--infer_mode $infer_mode \ |
|
--feature_folder $infer_feature_dir \ |
|
--vocoder_dir $infer_expt_dir \ |
|
--output_dir $infer_output_dir \ |
|
--log_level debug |
|
fi |
|
|
|
if [ $infer_mode = "infer_from_audio" ]; then |
|
CUDA_VISIBLE_DEVICES=$gpu accelerate launch "$work_dir"/bins/vocoder/inference.py \ |
|
--config $exp_config \ |
|
--infer_mode $infer_mode \ |
|
--audio_folder $infer_audio_dir \ |
|
--vocoder_dir $infer_expt_dir \ |
|
--output_dir $infer_output_dir \ |
|
--log_level debug |
|
fi |
|
|
|
fi |