MCPcopy Create free account
hub / github.com/MoonInTheRiver/DiffSinger / process_item

Method process_item

data_gen/singing/binarize.py:237–261  ·  view source on GitHub ↗
(cls, item_name, ph, txt, tg_fn, wav_fn, spk_id, encoder, binarization_args)

Source from the content-addressed store, hash-verified

235
236 @classmethod
237 def process_item(cls, item_name, ph, txt, tg_fn, wav_fn, spk_id, encoder, binarization_args):
238 if hparams['vocoder'] in VOCODERS:
239 wav, mel = VOCODERS[hparams['vocoder']].wav2spec(wav_fn)
240 else:
241 wav, mel = VOCODERS[hparams['vocoder'].split('.')[-1]].wav2spec(wav_fn)
242 res = {
243 'item_name': item_name, 'txt': txt, 'ph': ph, 'mel': mel, 'wav': wav, 'wav_fn': wav_fn,
244 'sec': len(wav) / hparams['audio_sample_rate'], 'len': mel.shape[0], 'spk_id': spk_id
245 }
246 try:
247 if binarization_args['with_f0']:
248 cls.get_pitch(wav_fn, mel, res)
249 if binarization_args['with_txt']:
250 try:
251 # print(ph)
252 phone_encoded = res['phone'] = encoder.encode(ph)
253 except:
254 traceback.print_exc()
255 raise BinarizationError(f"Empty phoneme")
256 if binarization_args['with_align']:
257 cls.get_align(tg_fn, ph, mel, phone_encoded, res)
258 except BinarizationError as e:
259 print(f"| Skip item ({e}). item_name: {item_name}, wav_fn: {wav_fn}")
260 return None
261 return res
262
263
264class ZhSingingBinarizer(ZhBinarizer, SingingBinarizer):

Callers

nothing calls this directly

Calls 5

BinarizationErrorClass · 0.90
wav2specMethod · 0.45
get_pitchMethod · 0.45
encodeMethod · 0.45
get_alignMethod · 0.45

Tested by

no test coverage detected