From f79b6decc9e1cfe7c03d3df4dd673c07d45752d7 Mon Sep 17 00:00:00 2001 From: speech_asr Date: Tue, 14 Feb 2023 14:43:25 +0800 Subject: [PATCH] add wav/text mismatch process --- funasr/tasks/abs_task.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/funasr/tasks/abs_task.py b/funasr/tasks/abs_task.py index 4e79c63a0..c4566a80a 100644 --- a/funasr/tasks/abs_task.py +++ b/funasr/tasks/abs_task.py @@ -68,7 +68,7 @@ from funasr.utils.types import str2bool from funasr.utils.types import str2triple_str from funasr.utils.types import str_or_int from funasr.utils.types import str_or_none -from funasr.utils.wav_utils import calc_shape, generate_data_list +from funasr.utils.wav_utils import calc_shape, generate_data_list, filter_wav_text from funasr.utils.yaml_no_alias_safe_dump import yaml_no_alias_safe_dump try: @@ -1148,6 +1148,14 @@ class AbsTask(ABC): if args.batch_bins is not None: args.batch_bins = args.batch_bins * args.ngpu + # filter samples if wav.scp and text are mismatch + if (args.train_shape_file is None and args.dataset_type == "small") or args.train_data_file is None and args.dataset_type == "large": + if not args.simple_ddp or distributed_option.dist_rank == 0: + filter_wav_text(args.data_dir, args.train_set) + filter_wav_text(args.data_dir, args.dev_set) + if args.simple_ddp: + dist.barrier() + if args.train_shape_file is None and args.dataset_type == "small": if not args.simple_ddp or distributed_option.dist_rank == 0: calc_shape(args.data_dir, args.train_set, args.frontend_conf, args.speech_length_min, args.speech_length_max)