CoolFace
Apppublic

mitudesk/uma_diffsvc

sourceHugging Faceapache-2.0updated 4y agoView on Hugging Face
0likes
SVCpre.py63 linesDownload Raw Back to preprocessing
1'''2 3    item: one piece of data4    item_name: data id5    wavfn: wave file path6    txt: lyrics7    ph: phoneme8    tgfn: text grid file path (unused)9    spk: dataset name10    wdb: word boundary11    ph_durs: phoneme durations12    midi: pitch as midi notes13    midi_dur: midi duration14    is_slur: keep singing upon note changes15'''16 17 18from copy import deepcopy19 20import logging21 22from preprocessing.process_pipeline import File2Batch23from utils.hparams import hparams24from preprocessing.base_binarizer import BaseBinarizer25 26SVCSINGING_ITEM_ATTRIBUTES = ['wav_fn', 'spk_id']27class 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_names45    46    @property47    def train_item_names(self):48        return self._train_item_names49 50    @property51    def valid_item_names(self):52        return self._test_item_names53 54    @property55    def test_item_names(self):56        return self._test_item_names57 58    def load_meta_data(self):59        self.items = File2Batch.file2temporary_dict()60    61    def _phone_encoder(self):62        from preprocessing.hubertinfer import Hubertencoder63        return Hubertencoder(hparams['hubert_path'])