jkot commited on
Commit
d448a85
1 Parent(s): 2220a25

Update czech_parliament_plenary_hearings.py

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