Datasets:
Srinath N Ramalingam
commited on
Commit
·
6c4ff3d
1
Parent(s):
50b4e84
New Dataset Structure
Browse filesThis view is limited to 50 files because it contains too many changes.
See raw diff
- dataset.py +13 -38
- {context_embeddings → test/context_embeddings}/p225/p225_001.npy +0 -0
- {context_embeddings → test/context_embeddings}/p225/p225_002.npy +0 -0
- {context_embeddings → test/context_embeddings}/p225/p225_003.npy +0 -0
- {context_embeddings → test/context_embeddings}/p225/p225_004.npy +0 -0
- {context_embeddings → test/context_embeddings}/p225/p225_005.npy +0 -0
- {context_embeddings → test/context_embeddings}/p225/p225_006.npy +0 -0
- {context_embeddings → test/context_embeddings}/p225/p225_007.npy +0 -0
- {context_embeddings → test/context_embeddings}/p225/p225_008.npy +0 -0
- {context_embeddings → test/context_embeddings}/p225/p225_009.npy +0 -0
- {context_embeddings → test/context_embeddings}/p225/p225_010.npy +0 -0
- {context_embeddings → test/context_embeddings}/p225/p225_011.npy +0 -0
- {context_embeddings → test/context_embeddings}/p225/p225_012.npy +0 -0
- {context_embeddings → test/context_embeddings}/p225/p225_013.npy +0 -0
- {context_embeddings → test/context_embeddings}/p225/p225_014.npy +0 -0
- {context_embeddings → test/context_embeddings}/p225/p225_016.npy +0 -0
- {context_embeddings → test/context_embeddings}/p225/p225_017.npy +0 -0
- {context_embeddings → test/context_embeddings}/p225/p225_018.npy +0 -0
- {context_embeddings → test/context_embeddings}/p225/p225_019.npy +0 -0
- {context_embeddings → test/context_embeddings}/p225/p225_020.npy +0 -0
- {context_embeddings → test/context_embeddings}/p225/p225_021.npy +0 -0
- {context_embeddings → test/context_embeddings}/p225/p225_022.npy +0 -0
- {context_embeddings → test/context_embeddings}/p225/p225_023.npy +0 -0
- {context_embeddings → test/context_embeddings}/p225/p225_024.npy +0 -0
- {context_embeddings → test/context_embeddings}/p225/p225_025.npy +0 -0
- {context_embeddings → test/context_embeddings}/p225/p225_026.npy +0 -0
- {context_embeddings → test/context_embeddings}/p225/p225_027.npy +0 -0
- {context_embeddings → test/context_embeddings}/p225/p225_028.npy +0 -0
- {context_embeddings → test/context_embeddings}/p225/p225_029.npy +0 -0
- {context_embeddings → test/context_embeddings}/p225/p225_030.npy +0 -0
- {context_embeddings → test/context_embeddings}/p225/p225_033.npy +0 -0
- {context_embeddings → test/context_embeddings}/p225/p225_035.npy +0 -0
- {context_embeddings → test/context_embeddings}/p225/p225_036.npy +0 -0
- {context_embeddings → test/context_embeddings}/p225/p225_037.npy +0 -0
- {context_embeddings → test/context_embeddings}/p225/p225_038.npy +0 -0
- {context_embeddings → test/context_embeddings}/p225/p225_039.npy +0 -0
- {context_embeddings → test/context_embeddings}/p225/p225_040.npy +0 -0
- {context_embeddings → test/context_embeddings}/p225/p225_044.npy +0 -0
- {context_embeddings → test/context_embeddings}/p225/p225_045.npy +0 -0
- {context_embeddings → test/context_embeddings}/p225/p225_046.npy +0 -0
- {context_embeddings → test/context_embeddings}/p225/p225_049.npy +0 -0
- {context_embeddings → test/context_embeddings}/p225/p225_051.npy +0 -0
- {context_embeddings → test/context_embeddings}/p225/p225_052.npy +0 -0
- {context_embeddings → test/context_embeddings}/p225/p225_053.npy +0 -0
- {context_embeddings → test/context_embeddings}/p225/p225_054.npy +0 -0
- {context_embeddings → test/context_embeddings}/p225/p225_056.npy +0 -0
- {context_embeddings → test/context_embeddings}/p225/p225_057.npy +0 -0
- {context_embeddings → test/context_embeddings}/p225/p225_058.npy +0 -0
- {context_embeddings → test/context_embeddings}/p225/p225_059.npy +0 -0
- {context_embeddings → test/context_embeddings}/p225/p225_060.npy +0 -0
dataset.py
CHANGED
@@ -1,14 +1,10 @@
|
|
1 |
import datasets
|
2 |
from pathlib import Path
|
3 |
-
import random
|
4 |
|
5 |
-
_DESCRIPTION = "Custom dataset with audio (.wav) and phoneme (.txt) pairs,
|
6 |
-
|
7 |
-
# For reproducibility!
|
8 |
-
_SEED = 42
|
9 |
|
10 |
class CustomAudioPhonemeDataset(datasets.GeneratorBasedBuilder):
|
11 |
-
VERSION = datasets.Version("1.0
|
12 |
|
13 |
def _info(self):
|
14 |
return datasets.DatasetInfo(
|
@@ -22,59 +18,38 @@ class CustomAudioPhonemeDataset(datasets.GeneratorBasedBuilder):
|
|
22 |
)
|
23 |
|
24 |
def _split_generators(self, dl_manager):
|
25 |
-
|
26 |
-
|
27 |
-
# Get all speakers from 'wav'
|
28 |
-
wav_dir = Path(data_dir) / 'wav'
|
29 |
-
speakers = sorted([d.name for d in wav_dir.iterdir() if d.is_dir()])
|
30 |
-
random.seed(_SEED)
|
31 |
-
random.shuffle(speakers)
|
32 |
-
|
33 |
-
# 80/10/10 split
|
34 |
-
N = len(speakers)
|
35 |
-
n_train = int(0.8 * N)
|
36 |
-
n_val = int(0.1 * N)
|
37 |
-
|
38 |
-
train_speakers = set(speakers[:n_train])
|
39 |
-
val_speakers = set(speakers[n_train:n_train + n_val])
|
40 |
-
test_speakers = set(speakers[n_train + n_val:])
|
41 |
-
|
42 |
return [
|
43 |
datasets.SplitGenerator(
|
44 |
name=datasets.Split.TRAIN,
|
45 |
-
gen_kwargs={"
|
46 |
),
|
47 |
datasets.SplitGenerator(
|
48 |
name=datasets.Split.VALIDATION,
|
49 |
-
gen_kwargs={"
|
50 |
),
|
51 |
datasets.SplitGenerator(
|
52 |
name=datasets.Split.TEST,
|
53 |
-
gen_kwargs={"
|
54 |
),
|
55 |
]
|
56 |
|
57 |
-
def _generate_examples(self,
|
58 |
-
|
59 |
-
wav_dir =
|
60 |
-
phoneme_dir =
|
61 |
|
62 |
-
|
63 |
-
|
64 |
-
phoneme_files = sorted([p for p in phoneme_dir.rglob('*.txt') if not p.name.startswith('._')])
|
65 |
|
66 |
-
# Map speaker from the relative path (assumes: wav/speaker/file.wav)
|
67 |
def get_speaker(path):
|
68 |
-
# wav/speaker/utterance.wav → speaker
|
69 |
return path.parent.name
|
70 |
|
71 |
-
# Match by base name
|
72 |
audio_map = {(get_speaker(p), p.stem): p for p in audio_files}
|
73 |
phoneme_map = {(get_speaker(p), p.stem): p for p in phoneme_files}
|
74 |
|
75 |
-
# Only use files where speaker is in split
|
76 |
keys = set(audio_map.keys()) & set(phoneme_map.keys())
|
77 |
-
keys = [k for k in keys if k[0] in split_speakers]
|
78 |
|
79 |
for idx, (speaker, stem) in enumerate(sorted(keys)):
|
80 |
audio_path = str(audio_map[(speaker, stem)])
|
|
|
1 |
import datasets
|
2 |
from pathlib import Path
|
|
|
3 |
|
4 |
+
_DESCRIPTION = "Custom dataset with audio (.wav) and phoneme (.txt) pairs, sharded by split."
|
|
|
|
|
|
|
5 |
|
6 |
class CustomAudioPhonemeDataset(datasets.GeneratorBasedBuilder):
|
7 |
+
VERSION = datasets.Version("1.1.0")
|
8 |
|
9 |
def _info(self):
|
10 |
return datasets.DatasetInfo(
|
|
|
18 |
)
|
19 |
|
20 |
def _split_generators(self, dl_manager):
|
21 |
+
# Each split is a folder: train/, validation/, test/
|
22 |
+
data_dir = Path(dl_manager.manual_dir)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
23 |
return [
|
24 |
datasets.SplitGenerator(
|
25 |
name=datasets.Split.TRAIN,
|
26 |
+
gen_kwargs={"split_dir": data_dir / "train"},
|
27 |
),
|
28 |
datasets.SplitGenerator(
|
29 |
name=datasets.Split.VALIDATION,
|
30 |
+
gen_kwargs={"split_dir": data_dir / "validation"},
|
31 |
),
|
32 |
datasets.SplitGenerator(
|
33 |
name=datasets.Split.TEST,
|
34 |
+
gen_kwargs={"split_dir": data_dir / "test"},
|
35 |
),
|
36 |
]
|
37 |
|
38 |
+
def _generate_examples(self, split_dir):
|
39 |
+
# Folders inside split_dir: wav/ and phonemized/
|
40 |
+
wav_dir = Path(split_dir) / "wav"
|
41 |
+
phoneme_dir = Path(split_dir) / "phonemized"
|
42 |
|
43 |
+
audio_files = sorted([p for p in wav_dir.rglob("*.wav") if not p.name.startswith("._")])
|
44 |
+
phoneme_files = sorted([p for p in phoneme_dir.rglob("*.txt") if not p.name.startswith("._")])
|
|
|
45 |
|
|
|
46 |
def get_speaker(path):
|
|
|
47 |
return path.parent.name
|
48 |
|
|
|
49 |
audio_map = {(get_speaker(p), p.stem): p for p in audio_files}
|
50 |
phoneme_map = {(get_speaker(p), p.stem): p for p in phoneme_files}
|
51 |
|
|
|
52 |
keys = set(audio_map.keys()) & set(phoneme_map.keys())
|
|
|
53 |
|
54 |
for idx, (speaker, stem) in enumerate(sorted(keys)):
|
55 |
audio_path = str(audio_map[(speaker, stem)])
|
{context_embeddings → test/context_embeddings}/p225/p225_001.npy
RENAMED
File without changes
|
{context_embeddings → test/context_embeddings}/p225/p225_002.npy
RENAMED
File without changes
|
{context_embeddings → test/context_embeddings}/p225/p225_003.npy
RENAMED
File without changes
|
{context_embeddings → test/context_embeddings}/p225/p225_004.npy
RENAMED
File without changes
|
{context_embeddings → test/context_embeddings}/p225/p225_005.npy
RENAMED
File without changes
|
{context_embeddings → test/context_embeddings}/p225/p225_006.npy
RENAMED
File without changes
|
{context_embeddings → test/context_embeddings}/p225/p225_007.npy
RENAMED
File without changes
|
{context_embeddings → test/context_embeddings}/p225/p225_008.npy
RENAMED
File without changes
|
{context_embeddings → test/context_embeddings}/p225/p225_009.npy
RENAMED
File without changes
|
{context_embeddings → test/context_embeddings}/p225/p225_010.npy
RENAMED
File without changes
|
{context_embeddings → test/context_embeddings}/p225/p225_011.npy
RENAMED
File without changes
|
{context_embeddings → test/context_embeddings}/p225/p225_012.npy
RENAMED
File without changes
|
{context_embeddings → test/context_embeddings}/p225/p225_013.npy
RENAMED
File without changes
|
{context_embeddings → test/context_embeddings}/p225/p225_014.npy
RENAMED
File without changes
|
{context_embeddings → test/context_embeddings}/p225/p225_016.npy
RENAMED
File without changes
|
{context_embeddings → test/context_embeddings}/p225/p225_017.npy
RENAMED
File without changes
|
{context_embeddings → test/context_embeddings}/p225/p225_018.npy
RENAMED
File without changes
|
{context_embeddings → test/context_embeddings}/p225/p225_019.npy
RENAMED
File without changes
|
{context_embeddings → test/context_embeddings}/p225/p225_020.npy
RENAMED
File without changes
|
{context_embeddings → test/context_embeddings}/p225/p225_021.npy
RENAMED
File without changes
|
{context_embeddings → test/context_embeddings}/p225/p225_022.npy
RENAMED
File without changes
|
{context_embeddings → test/context_embeddings}/p225/p225_023.npy
RENAMED
File without changes
|
{context_embeddings → test/context_embeddings}/p225/p225_024.npy
RENAMED
File without changes
|
{context_embeddings → test/context_embeddings}/p225/p225_025.npy
RENAMED
File without changes
|
{context_embeddings → test/context_embeddings}/p225/p225_026.npy
RENAMED
File without changes
|
{context_embeddings → test/context_embeddings}/p225/p225_027.npy
RENAMED
File without changes
|
{context_embeddings → test/context_embeddings}/p225/p225_028.npy
RENAMED
File without changes
|
{context_embeddings → test/context_embeddings}/p225/p225_029.npy
RENAMED
File without changes
|
{context_embeddings → test/context_embeddings}/p225/p225_030.npy
RENAMED
File without changes
|
{context_embeddings → test/context_embeddings}/p225/p225_033.npy
RENAMED
File without changes
|
{context_embeddings → test/context_embeddings}/p225/p225_035.npy
RENAMED
File without changes
|
{context_embeddings → test/context_embeddings}/p225/p225_036.npy
RENAMED
File without changes
|
{context_embeddings → test/context_embeddings}/p225/p225_037.npy
RENAMED
File without changes
|
{context_embeddings → test/context_embeddings}/p225/p225_038.npy
RENAMED
File without changes
|
{context_embeddings → test/context_embeddings}/p225/p225_039.npy
RENAMED
File without changes
|
{context_embeddings → test/context_embeddings}/p225/p225_040.npy
RENAMED
File without changes
|
{context_embeddings → test/context_embeddings}/p225/p225_044.npy
RENAMED
File without changes
|
{context_embeddings → test/context_embeddings}/p225/p225_045.npy
RENAMED
File without changes
|
{context_embeddings → test/context_embeddings}/p225/p225_046.npy
RENAMED
File without changes
|
{context_embeddings → test/context_embeddings}/p225/p225_049.npy
RENAMED
File without changes
|
{context_embeddings → test/context_embeddings}/p225/p225_051.npy
RENAMED
File without changes
|
{context_embeddings → test/context_embeddings}/p225/p225_052.npy
RENAMED
File without changes
|
{context_embeddings → test/context_embeddings}/p225/p225_053.npy
RENAMED
File without changes
|
{context_embeddings → test/context_embeddings}/p225/p225_054.npy
RENAMED
File without changes
|
{context_embeddings → test/context_embeddings}/p225/p225_056.npy
RENAMED
File without changes
|
{context_embeddings → test/context_embeddings}/p225/p225_057.npy
RENAMED
File without changes
|
{context_embeddings → test/context_embeddings}/p225/p225_058.npy
RENAMED
File without changes
|
{context_embeddings → test/context_embeddings}/p225/p225_059.npy
RENAMED
File without changes
|
{context_embeddings → test/context_embeddings}/p225/p225_060.npy
RENAMED
File without changes
|