-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathsample.py
73 lines (53 loc) · 1.81 KB
/
sample.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import sys
sys.path.append('..')
import speechset
sys.path.pop()
# construct data reader
lj = speechset.datasets.LJSpeech('D:\\dataset\\LJSpeech-1.1')
# construct configuration
config = speechset.Config()
# construct acoustic model
acoustic = speechset.AcousticDataset(lj, config)
# indexing
text, mel = acoustic[0]
print(text.shape, mel.shape)
# split sample
testset = acoustic.split(1000)
# back pack
text, mel, textlen, mellen = acoustic[0:3]
print(text.shape, mel.shape, textlen.shape, mellen.shape)
# iteration
text, mel = next(iter(testset))
print(text.shape, mel.shape)
# construct vocoder model
vocoder = speechset.VocoderDataset(lj, config)
# unpack
mel, audio, mellen, audiolen = vocoder[0:3]
print(mel.shape, audio.shape, mellen.shape, audiolen.shape)
# speaker id support
libri = speechset.datasets.LibriTTS('D:\\dataset\\LibriTTS\\test-clean')
# construct multi speaker
acoustic = speechset.utils.IDWrapper(
speechset.AcousticDataset(libri, config))
# unpack
sid, text, mel, textlen, mellen = acoustic[0:3]
print(sid.shape, text.shape, mel.shape, textlen.shape, mellen.shape)
# construct concatenated reader
concat = speechset.datasets.ConcatReader([libri, libri])
print(len(concat.speakers()))
# construct wav model
wavset = speechset.utils.IDWrapper(speechset.WavDataset(concat))
# unpack
sid, speeches = wavset[0]
print(sid, speeches.shape)
# dump
DUMP_PATH = 'D:\\dataset\\LibriTTS\\test-clean-dump'
speechset.utils.mp_dump(acoustic, DUMP_PATH, 4)
# load dump
class WrappedAcoustic(speechset.utils.IDWrapper):
def __init__(self, *args, **kwargs):
super().__init__(speechset.AcousticDataset(*args, **kwargs))
dumped = speechset.utils.DumpDataset(WrappedAcoustic, DUMP_PATH)
# unpack
sid, text, mel, textlen, mellen = dumped[0:3]
print(sid.shape, text.shape, mel.shape, textlen.shape, mellen.shape)