simplify matching function

This commit is contained in:
shahules786 2022-09-30 19:03:06 +05:30
parent 7466999078
commit 35bd3951ff
2 changed files with 18 additions and 7 deletions

View File

@ -109,8 +109,11 @@ class EnhancerDataset(TaskDataset):
batch size of each batch batch size of each batch
num_workers : int num_workers : int
num workers to be used while training num workers to be used while training
matching_function : matching_function : str
custom function for dataset processing. maching functions - (one_to_one,one_to_many). Default set to None.
use one_to_one mapping for datasets with one noisy file for each clean file
use one_to_many mapping for multiple noisy files for each clean file
""" """

View File

@ -4,6 +4,8 @@ from re import S
import numpy as np import numpy as np
from scipy.io import wavfile from scipy.io import wavfile
MATCHING_FNS = ("one_to_one","one_to_many")
class ProcessorFunctions: class ProcessorFunctions:
@staticmethod @staticmethod
@ -73,12 +75,18 @@ class Fileprocessor:
matching_function=None matching_function=None
): ):
if name.lower() == "vctk": if matching_function is None:
return cls(clean_dir,noisy_dir, ProcessorFunctions.one_to_one) if name.lower() == "vctk":
elif name.lower() == "dns-2020": return cls(clean_dir,noisy_dir, ProcessorFunctions.one_to_one)
return cls(clean_dir,noisy_dir, ProcessorFunctions.one_to_many) elif name.lower() == "dns-2020":
return cls(clean_dir,noisy_dir, ProcessorFunctions.one_to_many)
else: else:
return cls(clean_dir,noisy_dir, matching_function) if matching_function not in MATCHING_FNS:
raise ValueError(F"Invalid matching function! Avaialble options are {MATCHING_FNS}")
else:
return cls(clean_dir,noisy_dir, getattr(ProcessorFunctions,matching_function))
def prepare_matching_dict(self): def prepare_matching_dict(self):