From fce4e1d1b48f23cd8332e60afce3df8d6209a6a7 Mon Sep 17 00:00:00 2001 From: gaochangfeng <54253717+gaochangfeng@users.noreply.github.com> Date: 星期四, 11 四月 2024 14:59:22 +0800 Subject: [PATCH] SenseVoice对富文本解码的参数 (#1608) --- funasr/datasets/large_datasets/datapipes/filter.py | 24 ++++++++++++++++++++++++ 1 files changed, 24 insertions(+), 0 deletions(-) diff --git a/funasr/datasets/large_datasets/datapipes/filter.py b/funasr/datasets/large_datasets/datapipes/filter.py new file mode 100644 index 0000000..6fe7153 --- /dev/null +++ b/funasr/datasets/large_datasets/datapipes/filter.py @@ -0,0 +1,24 @@ +from torch.utils.data import IterableDataset + +def default_fn(data): + return data + + +class FilterIterDataPipe(IterableDataset): + + def __init__(self, + datapipe, + fn=default_fn): + self.datapipe = datapipe + self.fn = fn + + def set_epoch(self, epoch): + self.datapipe.set_epoch(epoch) + + def __iter__(self): + assert callable(self.fn) + for data in self.datapipe: + if self.fn(data): + yield data + else: + continue -- Gitblit v1.9.1