rmv sr filtering
This commit is contained in:
parent
192b8ffa7b
commit
fccbd88ba2
|
|
@ -66,15 +66,13 @@ class TaskDataset(pl.LightningDataModule):
|
||||||
train_clean = os.path.join(self.root_dir,self.files.train_clean)
|
train_clean = os.path.join(self.root_dir,self.files.train_clean)
|
||||||
train_noisy = os.path.join(self.root_dir,self.files.train_noisy)
|
train_noisy = os.path.join(self.root_dir,self.files.train_noisy)
|
||||||
fp = Fileprocessor.from_name(self.name,train_clean,
|
fp = Fileprocessor.from_name(self.name,train_clean,
|
||||||
train_noisy,self.sampling_rate,
|
train_noisy, self.matching_function)
|
||||||
self.matching_function)
|
|
||||||
self.train_data = fp.prepare_matching_dict()
|
self.train_data = fp.prepare_matching_dict()
|
||||||
|
|
||||||
val_clean = os.path.join(self.root_dir,self.files.test_clean)
|
val_clean = os.path.join(self.root_dir,self.files.test_clean)
|
||||||
val_noisy = os.path.join(self.root_dir,self.files.test_noisy)
|
val_noisy = os.path.join(self.root_dir,self.files.test_noisy)
|
||||||
fp = Fileprocessor.from_name(self.name,val_clean,
|
fp = Fileprocessor.from_name(self.name,val_clean,
|
||||||
val_noisy,self.sampling_rate,
|
val_noisy, self.matching_function)
|
||||||
self.matching_function)
|
|
||||||
val_data = fp.prepare_matching_dict()
|
val_data = fp.prepare_matching_dict()
|
||||||
|
|
||||||
for item in val_data:
|
for item in val_data:
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,13 @@
|
||||||
import glob
|
import glob
|
||||||
import os
|
import os
|
||||||
|
from re import S
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from scipy.io import wavfile
|
from scipy.io import wavfile
|
||||||
|
|
||||||
class ProcessorFunctions:
|
class ProcessorFunctions:
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def match_vtck(clean_path,noisy_path,sr):
|
def match_vtck(clean_path,noisy_path):
|
||||||
|
|
||||||
matching_wavfiles = list()
|
matching_wavfiles = list()
|
||||||
clean_filenames = [file.split('/')[-1] for file in glob.glob(os.path.join(clean_path,"*.wav"))]
|
clean_filenames = [file.split('/')[-1] for file in glob.glob(os.path.join(clean_path,"*.wav"))]
|
||||||
|
|
@ -18,16 +19,15 @@ class ProcessorFunctions:
|
||||||
sr_clean, clean_file = wavfile.read(os.path.join(clean_path,file_name))
|
sr_clean, clean_file = wavfile.read(os.path.join(clean_path,file_name))
|
||||||
sr_noisy, noisy_file = wavfile.read(os.path.join(noisy_path,file_name))
|
sr_noisy, noisy_file = wavfile.read(os.path.join(noisy_path,file_name))
|
||||||
if ((clean_file.shape[-1]==noisy_file.shape[-1]) and
|
if ((clean_file.shape[-1]==noisy_file.shape[-1]) and
|
||||||
(sr_clean==sr) and
|
(sr_clean==sr_noisy)):
|
||||||
(sr_noisy==sr)):
|
|
||||||
matching_wavfiles.append(
|
matching_wavfiles.append(
|
||||||
{"clean":os.path.join(clean_path,file_name),"noisy":os.path.join(noisy_path,file_name),
|
{"clean":os.path.join(clean_path,file_name),"noisy":os.path.join(noisy_path,file_name),
|
||||||
"duration":clean_file.shape[-1]/sr}
|
"duration":clean_file.shape[-1]/sr_clean}
|
||||||
)
|
)
|
||||||
return matching_wavfiles
|
return matching_wavfiles
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def match_dns2020(clean_path,noisy_path,sr):
|
def match_dns2020(clean_path,noisy_path):
|
||||||
|
|
||||||
matching_wavfiles = dict()
|
matching_wavfiles = dict()
|
||||||
clean_filenames = [file.split('/')[-1] for file in glob.glob(os.path.join(clean_path,"*.wav"))]
|
clean_filenames = [file.split('/')[-1] for file in glob.glob(os.path.join(clean_path,"*.wav"))]
|
||||||
|
|
@ -38,11 +38,10 @@ class ProcessorFunctions:
|
||||||
sr_clean, clean_file = wavfile.read(os.path.join(clean_path,clean_file))
|
sr_clean, clean_file = wavfile.read(os.path.join(clean_path,clean_file))
|
||||||
sr_noisy, noisy_file = wavfile.read(noisy_file)
|
sr_noisy, noisy_file = wavfile.read(noisy_file)
|
||||||
if ((clean_file.shape[-1]==noisy_file.shape[-1]) and
|
if ((clean_file.shape[-1]==noisy_file.shape[-1]) and
|
||||||
(sr_clean==sr) and
|
(sr_clean==sr_noisy)):
|
||||||
(sr_noisy==sr)):
|
|
||||||
matching_wavfiles.update(
|
matching_wavfiles.update(
|
||||||
{"clean":os.path.join(clean_path,clean_file),"noisy":noisy_file,
|
{"clean":os.path.join(clean_path,clean_file),"noisy":noisy_file,
|
||||||
"duration":clean_file.shape[-1]/sr}
|
"duration":clean_file.shape[-1]/sr_clean}
|
||||||
)
|
)
|
||||||
|
|
||||||
return matching_wavfiles
|
return matching_wavfiles
|
||||||
|
|
@ -54,12 +53,10 @@ class Fileprocessor:
|
||||||
self,
|
self,
|
||||||
clean_dir,
|
clean_dir,
|
||||||
noisy_dir,
|
noisy_dir,
|
||||||
sr = 16000,
|
|
||||||
matching_function = None
|
matching_function = None
|
||||||
):
|
):
|
||||||
self.clean_dir = clean_dir
|
self.clean_dir = clean_dir
|
||||||
self.noisy_dir = noisy_dir
|
self.noisy_dir = noisy_dir
|
||||||
self.sr = sr
|
|
||||||
self.matching_function = matching_function
|
self.matching_function = matching_function
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
|
@ -67,23 +64,22 @@ class Fileprocessor:
|
||||||
name:str,
|
name:str,
|
||||||
clean_dir,
|
clean_dir,
|
||||||
noisy_dir,
|
noisy_dir,
|
||||||
sr,
|
|
||||||
matching_function=None
|
matching_function=None
|
||||||
):
|
):
|
||||||
|
|
||||||
if name.lower() == "vctk":
|
if name.lower() == "vctk":
|
||||||
return cls(clean_dir,noisy_dir,sr, ProcessorFunctions.match_vtck)
|
return cls(clean_dir,noisy_dir, ProcessorFunctions.match_vtck)
|
||||||
elif name.lower() == "dns-2020":
|
elif name.lower() == "dns-2020":
|
||||||
return cls(clean_dir,noisy_dir,sr, ProcessorFunctions.match_dns2020)
|
return cls(clean_dir,noisy_dir, ProcessorFunctions.match_dns2020)
|
||||||
else:
|
else:
|
||||||
return cls(clean_dir,noisy_dir,sr, matching_function)
|
return cls(clean_dir,noisy_dir, matching_function)
|
||||||
|
|
||||||
def prepare_matching_dict(self):
|
def prepare_matching_dict(self):
|
||||||
|
|
||||||
if self.matching_function is None:
|
if self.matching_function is None:
|
||||||
raise ValueError("Not a valid matching function")
|
raise ValueError("Not a valid matching function")
|
||||||
|
|
||||||
return self.matching_function(self.clean_dir,self.noisy_dir,self.sr)
|
return self.matching_function(self.clean_dir,self.noisy_dir)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue