Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
prophesier
GitHub Repository: prophesier/diff-svc
Path: blob/main/preprocessing/SVCpre.py
694 views
1
'''
2
3
item: one piece of data
4
item_name: data id
5
wavfn: wave file path
6
txt: lyrics
7
ph: phoneme
8
tgfn: text grid file path (unused)
9
spk: dataset name
10
wdb: word boundary
11
ph_durs: phoneme durations
12
midi: pitch as midi notes
13
midi_dur: midi duration
14
is_slur: keep singing upon note changes
15
'''
16
17
18
from copy import deepcopy
19
20
import logging
21
22
from preprocessing.process_pipeline import File2Batch
23
from utils.hparams import hparams
24
from preprocessing.base_binarizer import BaseBinarizer
25
26
SVCSINGING_ITEM_ATTRIBUTES = ['wav_fn', 'spk_id']
27
class SVCBinarizer(BaseBinarizer):
28
def __init__(self, item_attributes=SVCSINGING_ITEM_ATTRIBUTES):
29
super().__init__(item_attributes)
30
print('spkers: ', set(item['spk_id'] for item in self.items.values()))
31
self.item_names = sorted(list(self.items.keys()))
32
self._train_item_names, self._test_item_names = self.split_train_test_set(self.item_names)
33
# self._valid_item_names=[]
34
35
def split_train_test_set(self, item_names):
36
item_names = deepcopy(item_names)
37
if hparams['choose_test_manually']:
38
test_item_names = [x for x in item_names if any([x.startswith(ts) for ts in hparams['test_prefixes']])]
39
else:
40
test_item_names = item_names[-5:]
41
train_item_names = [x for x in item_names if x not in set(test_item_names)]
42
logging.info("train {}".format(len(train_item_names)))
43
logging.info("test {}".format(len(test_item_names)))
44
return train_item_names, test_item_names
45
46
@property
47
def train_item_names(self):
48
return self._train_item_names
49
50
@property
51
def valid_item_names(self):
52
return self._test_item_names
53
54
@property
55
def test_item_names(self):
56
return self._test_item_names
57
58
def load_meta_data(self):
59
self.items = File2Batch.file2temporary_dict()
60
61
def _phone_encoder(self):
62
from preprocessing.hubertinfer import Hubertencoder
63
return Hubertencoder(hparams['hubert_path'])
64