Update czech_parliament_plenary_hearings.py
Browse files
czech_parliament_plenary_hearings.py
CHANGED
@@ -40,30 +40,35 @@ class CzechParliamentPlenaryHearings(GeneratorBasedBuilder):
|
|
40 |
citation=_CITATION,
|
41 |
license=_LICENSE
|
42 |
)
|
43 |
-
|
44 |
def _split_generators(self, dl_manager):
|
45 |
-
|
46 |
-
data_dir = os.path.join(
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
|
|
|
|
52 |
|
53 |
-
def _generate_examples(self,
|
54 |
-
split_dir = os.path.join(data_dir, split)
|
55 |
for folder_name in os.listdir(split_dir):
|
56 |
folder_path = os.path.join(split_dir, folder_name)
|
57 |
if os.path.isdir(folder_path):
|
58 |
-
for
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
|
|
|
|
|
|
65 |
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
|
|
|
|
|
40 |
citation=_CITATION,
|
41 |
license=_LICENSE
|
42 |
)
|
|
|
43 |
def _split_generators(self, dl_manager):
|
44 |
+
archive_path = dl_manager.download(_DATASET_URL)
|
45 |
+
data_dir = os.path.join(archive_path, 'ASR_DATA')
|
46 |
+
splits = ['train', 'dev', 'test']
|
47 |
+
for split in splits:
|
48 |
+
split_dir = os.path.join(data_dir, split)
|
49 |
+
yield split, {
|
50 |
+
'data_dir': split_dir,
|
51 |
+
'archive_path': archive_path,
|
52 |
+
}
|
53 |
|
54 |
+
def _generate_examples(self, split_dir, archive_path):
|
|
|
55 |
for folder_name in os.listdir(split_dir):
|
56 |
folder_path = os.path.join(split_dir, folder_name)
|
57 |
if os.path.isdir(folder_path):
|
58 |
+
for file_name in os.listdir(folder_path):
|
59 |
+
file_path = os.path.join(folder_path, file_name)
|
60 |
+
if file_name.endswith('.trn'):
|
61 |
+
with open(file_path, 'r') as f:
|
62 |
+
transcription = f.read().strip()
|
63 |
+
elif file_name.endswith('.wav'):
|
64 |
+
with self._dl_manager.iter_archive(archive_path, filter_func=lambda x: x.path == file_path) as files:
|
65 |
+
audio_file = next(files)
|
66 |
+
audio_path = os.path.join(folder_name, audio_file.path.split('/')[-1])
|
67 |
+
audio, sr = librosa.load(audio_file, sr=16000)
|
68 |
|
69 |
+
yield f'{folder_name}/{audio_file.path.split("/")[-1]}', {
|
70 |
+
'audio': {
|
71 |
+
'path': audio_path, 'bytes': audio
|
72 |
+
},
|
73 |
+
'transcription': transcription,
|
74 |
+
}
|