MCPcopy
hub / github.com/TensorSpeech/TensorFlowTTS / __init__

Method __init__

tensorflow_tts/datasets/mel_dataset.py:30–62  ·  view source on GitHub ↗

Initialize dataset. Args: root_dir (str): Root directory including dumped files. mel_query (str): Query to find feature files in root_dir. mel_load_fn (func): Function to load feature file. mel_length_threshold (int): Threshold to remove short

(
        self,
        root_dir,
        mel_query="*-raw-feats.h5",
        mel_load_fn=np.load,
        mel_length_threshold=0,
    )

Source from the content-addressed store, hash-verified

28 """Tensorflow compatible mel dataset."""
29
30 def __init__(
31 self,
32 root_dir,
33 mel_query="*-raw-feats.h5",
34 mel_load_fn=np.load,
35 mel_length_threshold=0,
36 ):
37 """Initialize dataset.
38
39 Args:
40 root_dir (str): Root directory including dumped files.
41 mel_query (str): Query to find feature files in root_dir.
42 mel_load_fn (func): Function to load feature file.
43 mel_length_threshold (int): Threshold to remove short feature files.
44
45 """
46 # find all of mel files.
47 mel_files = sorted(find_files(root_dir, mel_query))
48 mel_lengths = [mel_load_fn(f).shape[0] for f in mel_files]
49
50 # assert the number of files
51 assert len(mel_files) != 0, f"Not found any mel files in ${root_dir}."
52
53 if ".npy" in mel_query:
54 suffix = mel_query[1:]
55 utt_ids = [os.path.basename(f).replace(suffix, "") for f in mel_files]
56
57 # set global params
58 self.utt_ids = utt_ids
59 self.mel_files = mel_files
60 self.mel_lengths = mel_lengths
61 self.mel_load_fn = mel_load_fn
62 self.mel_length_threshold = mel_length_threshold
63
64 def get_args(self):
65 return [self.utt_ids]

Callers

nothing calls this directly

Calls 1

find_filesFunction · 0.90

Tested by

no test coverage detected