zhaomingwork
2023-11-08 2e36e738ca39afc8d02f3d11013bd12f937cc874
funasr/datasets/large_datasets/dataset.py
@@ -108,7 +108,7 @@
                    ark_reader = ReadHelper('ark:{}'.format(data_file))
                    reader_list.append(ark_reader)
                elif data_type == "text" or data_type == "sound" or data_type == 'text_hotword':
                    text_reader = open(data_file, "r")
                    text_reader = open(data_file, "r", encoding="utf-8")
                    reader_list.append(text_reader)
                elif data_type == "none":
                    continue
@@ -205,7 +205,7 @@
    # pre_prob = conf.get("pre_prob", 0)  # unused yet
    if pre_hwfile is not None:
        pre_hwlist = []
        with open(pre_hwfile, 'r') as fin:
        with open(pre_hwfile, 'r', encoding="utf-8") as fin:
            for line in fin.readlines():
                pre_hwlist.append(line.strip())
    else:
@@ -229,15 +229,15 @@
                           mode=mode, 
                           )
    filter_conf = conf.get('filter_conf', {})
    filter_fn = partial(filter, **filter_conf)
    dataset = FilterIterDataPipe(dataset, fn=filter_fn)
    if "text" in data_names:
        vocab = {'vocab': dict, 'seg_dict': seg_dict, 'punc_dict': punc_dict, 'bpe_tokenizer': bpe_tokenizer, 'hw_config': hw_config}
        tokenize_fn = partial(tokenize, **vocab)
        dataset = MapperIterDataPipe(dataset, fn=tokenize_fn)
    filter_conf = conf.get('filter_conf', {})
    filter_fn = partial(filter, **filter_conf)
    dataset = FilterIterDataPipe(dataset, fn=filter_fn)
    if shuffle:
        buffer_conf = conf.get('shuffle_conf', {})
        buffer_size = buffer_conf['shuffle_size']