f
This commit is contained in:
parent
031769150d
commit
f691f5faa1
32
codes/scripts/audio/preparation/combine_phonetic_and_text.py
Normal file
32
codes/scripts/audio/preparation/combine_phonetic_and_text.py
Normal file
|
@ -0,0 +1,32 @@
|
|||
import os
|
||||
|
||||
if __name__ == '__main__':
|
||||
basepath = 'Y:/clips/books2'
|
||||
|
||||
english_file = os.path.join(basepath, 'transcribed-oco-realtext.tsv')
|
||||
if not os.path.exists(english_file):
|
||||
english_file = os.path.join(basepath, 'transcribed-oco.tsv')
|
||||
phoneme_file = os.path.join(basepath, 'transcribed-phoneme-oco.tsv')
|
||||
|
||||
texts = {}
|
||||
with open(english_file, 'r', encoding='utf-8') as f:
|
||||
for line in f.readlines():
|
||||
spl = line.split('\t')
|
||||
if len(spl) == 3:
|
||||
text, p, _ = spl
|
||||
texts[p] = text
|
||||
else:
|
||||
print(f'Error processing line {line}')
|
||||
|
||||
with open(phoneme_file, 'r', encoding='utf-8') as f:
|
||||
wf = open(os.path.join(basepath, 'transcribed-phoneme-english-oco.tsv'), 'w', encoding='utf-8')
|
||||
for line in f.readlines():
|
||||
spl = line.split('\t')
|
||||
if len(spl) == 3:
|
||||
_, p, codes = spl
|
||||
codes = codes.strip()
|
||||
if p not in texts:
|
||||
print(f'Could not find the text for {p}')
|
||||
continue
|
||||
wf.write(f'{texts[p]}\t{p}\t{codes}\n')
|
||||
wf.close()
|
|
@ -1,5 +1,7 @@
|
|||
import os
|
||||
import os.path as osp
|
||||
import random
|
||||
|
||||
import torch
|
||||
import torchaudio
|
||||
import torchvision.utils
|
||||
|
@ -33,6 +35,13 @@ class AudioDiffusionFid(evaluator.Evaluator):
|
|||
super().__init__(model, opt_eval, env, uses_all_ddp=True)
|
||||
self.real_path = opt_eval['eval_tsv']
|
||||
self.data = load_tsv_aligned_codes(self.real_path)
|
||||
|
||||
# Deterministically shuffle the data.
|
||||
ostate = random.getstate()
|
||||
random.seed(5)
|
||||
random.shuffle(self.data)
|
||||
random.setstate(ostate)
|
||||
|
||||
if 'clip_dataset' in opt_eval.keys():
|
||||
self.data = self.data[:opt_eval['clip_dataset']]
|
||||
if distributed.is_initialized() and distributed.get_world_size() > 1:
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
from copy import deepcopy
|
||||
|
||||
from datasets import load_metric
|
||||
#from datasets import load_metric
|
||||
|
||||
import torch
|
||||
from tqdm import tqdm
|
||||
|
|
Loading…
Reference in New Issue
Block a user