forked from jaywalnut310/vits
-
Notifications
You must be signed in to change notification settings - Fork 0
/
check_data.py
56 lines (46 loc) · 1.34 KB
/
check_data.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
import torch
import matplotlib
matplotlib.use("Agg")
import matplotlib.pyplot as plt
import numpy as np
import soundfile as sf
import librosa
dirs = {
"dataset": "./DUMMY1",
"preprocessed": "preprocessed_data/LJSpeech_paper",
"save": "./temp"
}
samples = {"0003": "LJ001-0003"}
class CheckData():
def __init__(self):
self.datum = {}
for sample, name in samples.items():
wav_path = f'{dirs["dataset"]}/{name}.wav'
wav, sr = sf.read(wav_path)
pitch_path = f'{dirs["preprocessed"]}/pitch/pitch-{name}.npy'
pitch = np.load(pitch_path)
energy_path = f'{dirs["preprocessed"]}/energy/energy-{name}.npy'
energy = np.load(energy_path)
mel_path = f'{dirs["preprocessed"]}/mel/mel-{name}.npy'
mel = np.load(mel_path)
self.datum[name] = (wav, pitch, energy, mel)
def analysis(self):
for name, data in self.datum.items():
wav, pitch, energy, mel = data
print(energy.size)
print(pitch.size)
print(mel.size)
plt.figure(figsize=(10, 10))
plt.subplot(2,2,1)
plt.plot(pitch)
plt.subplot(2,2,2)
plt.plot(energy)
plt.subplot(2,2,3)
librosa.display.specshow(mel, sr=22050)
plt.savefig(f'{dirs["save"]}/{name}.png')
exit()
def main():
checkdata = CheckData()
checkdata.analysis()
if __name__ == '__main__':
main()