Update czech_parliament_plenary_hearings.py
Browse files
czech_parliament_plenary_hearings.py
CHANGED
@@ -61,18 +61,25 @@ class CzechParliamentPlenaryHearings(GeneratorBasedBuilder):
|
|
61 |
|
62 |
def _generate_examples(self, split, data_dir):
|
63 |
split_dir = os.path.join(data_dir, split)
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
72 |
|
73 |
-
|
|
|
|
|
|
|
|
|
|
|
74 |
|
75 |
-
yield f"{folder_name}/{audio_file}", {
|
76 |
-
'audio': audio,
|
77 |
-
'transcription': transcription,
|
78 |
-
}
|
|
|
61 |
|
62 |
def _generate_examples(self, split, data_dir):
|
63 |
split_dir = os.path.join(data_dir, split)
|
64 |
+
with os.scandir(split_dir) as it:
|
65 |
+
for entry in it:
|
66 |
+
if entry.is_dir():
|
67 |
+
folder_name = entry.name
|
68 |
+
folder_path = os.path.join(split_dir, folder_name)
|
69 |
+
with os.scandir(folder_path) as it2:
|
70 |
+
for entry2 in it2:
|
71 |
+
if entry2.is_file() and entry2.name.endswith('.wav'):
|
72 |
+
audio_file = entry2.name
|
73 |
+
audio_path = os.path.join(folder_path, audio_file)
|
74 |
+
transcription_path = os.path.join(
|
75 |
+
folder_path, audio_file + '.trn')
|
76 |
+
transcription = open(
|
77 |
+
transcription_path).read().strip()
|
78 |
|
79 |
+
audio, sr = librosa.load(audio_path, sr=16000)
|
80 |
+
|
81 |
+
yield f"{folder_name}/{audio_file}", {
|
82 |
+
'audio': audio,
|
83 |
+
'transcription': transcription,
|
84 |
+
}
|
85 |
|
|
|
|
|
|
|
|