phdkhanh2507
commited on
Update transcribed-vietnamese-audio.py
Browse files
transcribed-vietnamese-audio.py
CHANGED
@@ -57,12 +57,9 @@ class TranscribedVietnameseAudio(datasets.GeneratorBasedBuilder):
|
|
57 |
features = datasets.Features({
|
58 |
"id": datasets.Value("string"),
|
59 |
"channel": datasets.Value("string"),
|
60 |
-
"visual": datasets.Value("string"),
|
61 |
"duration": datasets.Value("float64"),
|
62 |
"fps": datasets.Value("int8"),
|
63 |
-
"audio": datasets.Value("binary"),
|
64 |
"sampling_rate": datasets.Value("int64"),
|
65 |
-
"transcript": datasets.Value("string"),
|
66 |
})
|
67 |
|
68 |
return datasets.DatasetInfo(
|
@@ -85,30 +82,18 @@ class TranscribedVietnameseAudio(datasets.GeneratorBasedBuilder):
|
|
85 |
metadata_paths = dl_manager.download(
|
86 |
[_URLS["meta"].format(channel=channel) for channel in config_names]
|
87 |
)
|
88 |
-
transcript_dirs = dl_manager.download_and_extract(
|
89 |
-
[_URLS["transcript"].format(channel=channel) for channel in config_names]
|
90 |
-
)
|
91 |
-
|
92 |
-
transcript_dict = {
|
93 |
-
channel: transcript_dir
|
94 |
-
for channel, transcript_dir in zip(config_names, transcript_dirs)
|
95 |
-
}
|
96 |
|
97 |
return [
|
98 |
datasets.SplitGenerator(
|
99 |
name=datasets.Split.TRAIN,
|
100 |
gen_kwargs={
|
101 |
"metadata_paths": metadata_paths,
|
102 |
-
"transcript_dict": transcript_dict,
|
103 |
},
|
104 |
),
|
105 |
]
|
106 |
|
107 |
def _generate_examples(
|
108 |
self, metadata_paths: List[str],
|
109 |
-
visual_dict: dict,
|
110 |
-
audio_dict: dict,
|
111 |
-
transcript_dict: dict,
|
112 |
) -> Tuple[int, dict]:
|
113 |
"""
|
114 |
Generate examples from metadata.
|
@@ -122,19 +107,13 @@ class TranscribedVietnameseAudio(datasets.GeneratorBasedBuilder):
|
|
122 |
data_files=metadata_paths,
|
123 |
split="train",
|
124 |
)
|
125 |
-
for i, sample in enumerate(dataset):
|
126 |
-
channel = sample["channel"]
|
127 |
-
transcript_path = os.path.join(
|
128 |
-
transcript_dict[channel], channel, sample["id"] + ".txt"
|
129 |
-
)
|
130 |
|
131 |
yield i, {
|
132 |
"id": sample["id"],
|
133 |
-
"
|
134 |
-
"
|
135 |
-
"
|
136 |
-
"
|
137 |
-
"transcript": self.__get_text_data(transcript_path),
|
138 |
}
|
139 |
|
140 |
def __get_binary_data(self, path: str) -> bytes:
|
|
|
57 |
features = datasets.Features({
|
58 |
"id": datasets.Value("string"),
|
59 |
"channel": datasets.Value("string"),
|
|
|
60 |
"duration": datasets.Value("float64"),
|
61 |
"fps": datasets.Value("int8"),
|
|
|
62 |
"sampling_rate": datasets.Value("int64"),
|
|
|
63 |
})
|
64 |
|
65 |
return datasets.DatasetInfo(
|
|
|
82 |
metadata_paths = dl_manager.download(
|
83 |
[_URLS["meta"].format(channel=channel) for channel in config_names]
|
84 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
85 |
|
86 |
return [
|
87 |
datasets.SplitGenerator(
|
88 |
name=datasets.Split.TRAIN,
|
89 |
gen_kwargs={
|
90 |
"metadata_paths": metadata_paths,
|
|
|
91 |
},
|
92 |
),
|
93 |
]
|
94 |
|
95 |
def _generate_examples(
|
96 |
self, metadata_paths: List[str],
|
|
|
|
|
|
|
97 |
) -> Tuple[int, dict]:
|
98 |
"""
|
99 |
Generate examples from metadata.
|
|
|
107 |
data_files=metadata_paths,
|
108 |
split="train",
|
109 |
)
|
|
|
|
|
|
|
|
|
|
|
110 |
|
111 |
yield i, {
|
112 |
"id": sample["id"],
|
113 |
+
"chunk_id": sample["chunk_id"],
|
114 |
+
"video_fps": sample["video_fps"],
|
115 |
+
"audio_fps": sample["audio_fps"],
|
116 |
+
"transcript": sample["transcript"],
|
|
|
117 |
}
|
118 |
|
119 |
def __get_binary_data(self, path: str) -> bytes:
|