Skip to content

Commit

Permalink
support cpu, test=asr
Browse files Browse the repository at this point in the history
  • Loading branch information
root committed May 9, 2022
1 parent 8640410 commit 9f389a7
Show file tree
Hide file tree
Showing 16 changed files with 81 additions and 9 deletions.
5 changes: 3 additions & 2 deletions demos/audio_searching/src/operations/load.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ def get_audios(path):
"""
supported_formats = [".wav", ".mp3", ".ogg", ".flac", ".m4a"]
return [
item for sublist in [[os.path.join(dir, file) for file in files]
for dir, _, files in list(os.walk(path))]
item
for sublist in [[os.path.join(dir, file) for file in files]
for dir, _, files in list(os.walk(path))]
for item in sublist if os.path.splitext(item)[1] in supported_formats
]

Expand Down
9 changes: 9 additions & 0 deletions examples/aishell/asr0/local/train.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,20 @@ if [ ${seed} != 0 ]; then
export FLAGS_cudnn_deterministic=True
fi

if [ ${ngpu} == 0 ]; then
python3 -u ${BIN_DIR}/train.py \
--ngpu ${ngpu} \
--config ${config_path} \
--output exp/${ckpt_name} \
--model_type ${model_type} \
--seed ${seed}
else
python3 -m paddle.distributed.launch --gpus=${CUDA_VISIBLE_DEVICES} ${BIN_DIR}/train.py \
--config ${config_path} \
--output exp/${ckpt_name} \
--model_type ${model_type} \
--seed ${seed}
fi

if [ ${seed} != 0 ]; then
unset FLAGS_cudnn_deterministic
Expand Down
2 changes: 1 addition & 1 deletion examples/aishell/asr0/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
set -e
source path.sh

gpus=0,1,2,3
gpus=1,2,3
stage=0
stop_stage=100
conf_path=conf/deepspeech2.yaml #conf/deepspeech2.yaml or conf/deepspeech2_online.yaml
Expand Down
11 changes: 11 additions & 0 deletions examples/aishell/asr1/local/train.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,24 @@ ckpt_name=$2

mkdir -p exp

if [ ${ngpu} == 0 ]; then
python3 -u ${BIN_DIR}/train.py \
--ngpu ${ngpu} \
--seed ${seed} \
--config ${config_path} \
--output exp/${ckpt_name} \
--profiler-options "${profiler_options}" \
--benchmark-batch-size ${benchmark_batch_size} \
--benchmark-max-step ${benchmark_max_step}
else
python3 -m paddle.distributed.launch --gpus=${CUDA_VISIBLE_DEVICES} ${BIN_DIR}/train.py \
--seed ${seed} \
--config ${config_path} \
--output exp/${ckpt_name} \
--profiler-options "${profiler_options}" \
--benchmark-batch-size ${benchmark_batch_size} \
--benchmark-max-step ${benchmark_max_step}
fi


if [ ${seed} != 0 ]; then
Expand Down
8 changes: 8 additions & 0 deletions examples/callcenter/asr1/local/train.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,18 @@ if [ ${seed} != 0 ]; then
export FLAGS_cudnn_deterministic=True
fi

if [ ${ngpu} == 0 ]; then
python3 -u ${BIN_DIR}/train.py \
--ngpu ${ngpu} \
--config ${config_path} \
--output exp/${ckpt_name} \
--seed ${seed}
else
python3 -m paddle.distributed.launch --gpus=${CUDA_VISIBLE_DEVICES} ${BIN_DIR}/train.py \
--config ${config_path} \
--output exp/${ckpt_name} \
--seed ${seed}
fi

if [ ${seed} != 0 ]; then
unset FLAGS_cudnn_deterministic
Expand Down
9 changes: 9 additions & 0 deletions examples/librispeech/asr0/local/train.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,20 @@ if [ ${seed} != 0 ]; then
export FLAGS_cudnn_deterministic=True
fi

if [ ${ngpu} == 0 ]; then
python3 -u ${BIN_DIR}/train.py \
--ngpu ${ngpu} \
--config ${config_path} \
--output exp/${ckpt_name} \
--model_type ${model_type} \
--seed ${seed}
else
python3 -m paddle.distributed.launch --gpus=${CUDA_VISIBLE_DEVICES} ${BIN_DIR}/train.py \
--config ${config_path} \
--output exp/${ckpt_name} \
--model_type ${model_type} \
--seed ${seed}
fi

if [ ${seed} != 0 ]; then
unset FLAGS_cudnn_deterministic
Expand Down
8 changes: 8 additions & 0 deletions examples/librispeech/asr1/local/train.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,18 @@ fi
# export FLAGS_cudnn_exhaustive_search=true
# export FLAGS_conv_workspace_size_limit=4000

if [ ${ngpu} == 0 ]; then
python3 -u ${BIN_DIR}/train.py \
--ngpu ${ngpu} \
--config ${config_path} \
--output exp/${ckpt_name} \
--seed ${seed}
else
python3 -m paddle.distributed.launch --gpus=${CUDA_VISIBLE_DEVICES} ${BIN_DIR}/train.py \
--config ${config_path} \
--output exp/${ckpt_name} \
--seed ${seed}
fi

if [ ${seed} != 0 ]; then
unset FLAGS_cudnn_deterministic
Expand Down
9 changes: 9 additions & 0 deletions examples/librispeech/asr2/local/train.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,20 @@ if [ ${seed} != 0 ]; then
export FLAGS_cudnn_deterministic=True
fi

if [ ${ngpu} == 0 ]; then
python3 -u ${BIN_DIR}/train.py \
--ngpu ${ngpu} \
--model-name u2_kaldi \
--config ${config_path} \
--output exp/${ckpt_name} \
--seed ${seed}
else
python3 -m paddle.distributed.launch --gpus=${CUDA_VISIBLE_DEVICES} ${BIN_DIR}/train.py \
--model-name u2_kaldi \
--config ${config_path} \
--output exp/${ckpt_name} \
--seed ${seed}
fi

if [ ${seed} != 0 ]; then
unset FLAGS_cudnn_deterministic
Expand Down
10 changes: 10 additions & 0 deletions examples/tiny/asr0/local/train.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,22 @@ model_type=$3

mkdir -p exp

if [ ${ngpu} == 0 ]; then
python3 -u ${BIN_DIR}/train.py \
--ngpu ${ngpu} \
--config ${config_path} \
--output exp/${ckpt_name} \
--model_type ${model_type} \
--profiler-options "${profiler_options}" \
--seed ${seed}
else
python3 -m paddle.distributed.launch --gpus=${CUDA_VISIBLE_DEVICES} ${BIN_DIR}/train.py \
--config ${config_path} \
--output exp/${ckpt_name} \
--model_type ${model_type} \
--profiler-options "${profiler_options}" \
--seed ${seed}
fi

if [ ${seed} != 0 ]; then
unset FLAGS_cudnn_deterministic
Expand Down
11 changes: 11 additions & 0 deletions examples/tiny/asr1/local/train.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,24 @@ ckpt_name=$2

mkdir -p exp

if [ ${ngpu} == 0 ]; then
python3 -u ${BIN_DIR}/train.py \
--ngpu ${ngpu} \
--seed ${seed} \
--config ${config_path} \
--output exp/${ckpt_name} \
--profiler-options "${profiler_options}" \
--benchmark-batch-size ${benchmark_batch_size} \
--benchmark-max-step ${benchmark_max_step}
else
python3 -m paddle.distributed.launch --gpus=${CUDA_VISIBLE_DEVICES} ${BIN_DIR}/train.py \
--seed ${seed} \
--config ${config_path} \
--output exp/${ckpt_name} \
--profiler-options "${profiler_options}" \
--benchmark-batch-size ${benchmark_batch_size} \
--benchmark-max-step ${benchmark_max_step}
fi


if [ ${seed} != 0 ]; then
Expand Down
1 change: 0 additions & 1 deletion paddlespeech/s2t/exps/deepspeech2/bin/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
"""Trainer for DeepSpeech2 model."""
from paddle import distributed as dist
from yacs.config import CfgNode

from paddlespeech.s2t.exps.deepspeech2.model import DeepSpeech2Trainer as Trainer
Expand Down
1 change: 0 additions & 1 deletion paddlespeech/s2t/exps/u2/bin/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import cProfile
import os

from paddle import distributed as dist
from yacs.config import CfgNode

from paddlespeech.s2t.exps.u2.model import U2Trainer as Trainer
Expand Down
1 change: 0 additions & 1 deletion paddlespeech/s2t/exps/u2_kaldi/bin/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import cProfile
import os

from paddle import distributed as dist
from yacs.config import CfgNode

from paddlespeech.s2t.training.cli import default_argument_parser
Expand Down
1 change: 0 additions & 1 deletion paddlespeech/s2t/exps/u2_st/bin/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import cProfile
import os

from paddle import distributed as dist
from yacs.config import CfgNode

from paddlespeech.s2t.exps.u2_st.model import U2STTrainer as Trainer
Expand Down
2 changes: 1 addition & 1 deletion paddlespeech/s2t/io/sampler.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def _batch_shuffle(indices, batch_size, epoch, clipped=False):
"""
rng = np.random.RandomState(epoch)
shift_len = rng.randint(0, batch_size - 1)
batch_indices = list(zip(* [iter(indices[shift_len:])] * batch_size))
batch_indices = list(zip(*[iter(indices[shift_len:])] * batch_size))
rng.shuffle(batch_indices)
batch_indices = [item for batch in batch_indices for item in batch]
assert clipped is False
Expand Down
2 changes: 1 addition & 1 deletion paddlespeech/t2s/modules/transformer/repeat.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@ def repeat(N, fn):
Returns:
MultiSequential: Repeated model instance.
"""
return MultiSequential(* [fn(n) for n in range(N)])
return MultiSequential(*[fn(n) for n in range(N)])

0 comments on commit 9f389a7

Please sign in to comment.