small fix
Browse files- yttemporal180m.py +14 -11
yttemporal180m.py
CHANGED
|
@@ -1,4 +1,3 @@
|
|
| 1 |
-
import os
|
| 2 |
import json
|
| 3 |
import datasets
|
| 4 |
import datetime
|
|
@@ -19,8 +18,10 @@ that covers diverse topics.
|
|
| 19 |
|
| 20 |
_URL_BASE = "https://rowanzellers.com/merlot/#data"
|
| 21 |
|
| 22 |
-
url_numbers = ["00" + str(i) if i<10 else "0"+ str(i) for i in range(100)]
|
| 23 |
-
_DL_URLS = [
|
|
|
|
|
|
|
| 24 |
|
| 25 |
def json_serializer(o):
|
| 26 |
if isinstance(o, datetime):
|
|
@@ -29,6 +30,7 @@ def json_serializer(o):
|
|
| 29 |
raise TypeError(
|
| 30 |
f"Object of type {o.__class__.__name__} is not JSON serializable")
|
| 31 |
|
|
|
|
| 32 |
class yttemporal180mConfig(datasets.BuilderConfig):
|
| 33 |
"""BuilderConfig for ActivityNet Captions."""
|
| 34 |
|
|
@@ -53,7 +55,7 @@ class yttemporal180m(datasets.GeneratorBasedBuilder):
|
|
| 53 |
"video_id": datasets.Value("string"),
|
| 54 |
"video_url": datasets.Value("string"),
|
| 55 |
"asr": datasets.Value("string"),
|
| 56 |
-
"title": datasets.Value("string"),
|
| 57 |
"meta": datasets.Value("string"),
|
| 58 |
}
|
| 59 |
),
|
|
@@ -63,7 +65,8 @@ class yttemporal180m(datasets.GeneratorBasedBuilder):
|
|
| 63 |
)
|
| 64 |
|
| 65 |
def _split_generators(self, dl_manager):
|
| 66 |
-
archive_paths = [dl_manager.download_and_extract(
|
|
|
|
| 67 |
|
| 68 |
train_split = [
|
| 69 |
datasets.SplitGenerator(
|
|
@@ -73,7 +76,7 @@ class yttemporal180m(datasets.GeneratorBasedBuilder):
|
|
| 73 |
},
|
| 74 |
)
|
| 75 |
]
|
| 76 |
-
|
| 77 |
return train_split
|
| 78 |
|
| 79 |
def _generate_examples(self, jsonl_files):
|
|
@@ -84,27 +87,27 @@ class yttemporal180m(datasets.GeneratorBasedBuilder):
|
|
| 84 |
json_list = list(jsonl_file)
|
| 85 |
for json_str in json_list:
|
| 86 |
infos = json.loads(json_str)
|
| 87 |
-
|
| 88 |
id = infos['info']['display_id']
|
| 89 |
url = "https://www.youtube.com/watch?v=" + id
|
| 90 |
asr = ""
|
| 91 |
for example in infos['denoised']:
|
| 92 |
asr += example["cleanasr"]
|
| 93 |
-
|
| 94 |
metadata_dict = {
|
| 95 |
"asr_info": infos["denoised"],
|
| 96 |
"info": infos["info"],
|
| 97 |
-
"subtitles": infos["subtitles"],
|
| 98 |
}
|
| 99 |
yield idx, {
|
| 100 |
"video_id": id,
|
| 101 |
"video_url": url,
|
| 102 |
"asr": asr,
|
| 103 |
-
"title": infos['info']['title'],
|
| 104 |
"meta": json.dumps(
|
| 105 |
metadata_dict,
|
| 106 |
default=json_serializer,
|
| 107 |
indent=2
|
| 108 |
)
|
| 109 |
}
|
| 110 |
-
idx += 1
|
|
|
|
|
|
|
| 1 |
import json
|
| 2 |
import datasets
|
| 3 |
import datetime
|
|
|
|
| 18 |
|
| 19 |
_URL_BASE = "https://rowanzellers.com/merlot/#data"
|
| 20 |
|
| 21 |
+
url_numbers = ["00" + str(i) if i < 10 else "0" + str(i) for i in range(100)]
|
| 22 |
+
_DL_URLS = [
|
| 23 |
+
f"https://storage.googleapis.com/merlot/yttemporal180m/yttemporal180m_{num}of100.jsonl.gz" for num in url_numbers]
|
| 24 |
+
|
| 25 |
|
| 26 |
def json_serializer(o):
|
| 27 |
if isinstance(o, datetime):
|
|
|
|
| 30 |
raise TypeError(
|
| 31 |
f"Object of type {o.__class__.__name__} is not JSON serializable")
|
| 32 |
|
| 33 |
+
|
| 34 |
class yttemporal180mConfig(datasets.BuilderConfig):
|
| 35 |
"""BuilderConfig for ActivityNet Captions."""
|
| 36 |
|
|
|
|
| 55 |
"video_id": datasets.Value("string"),
|
| 56 |
"video_url": datasets.Value("string"),
|
| 57 |
"asr": datasets.Value("string"),
|
| 58 |
+
"title": datasets.Value("string"),
|
| 59 |
"meta": datasets.Value("string"),
|
| 60 |
}
|
| 61 |
),
|
|
|
|
| 65 |
)
|
| 66 |
|
| 67 |
def _split_generators(self, dl_manager):
|
| 68 |
+
archive_paths = [dl_manager.download_and_extract(
|
| 69 |
+
url) for url in _DL_URLS]
|
| 70 |
|
| 71 |
train_split = [
|
| 72 |
datasets.SplitGenerator(
|
|
|
|
| 76 |
},
|
| 77 |
)
|
| 78 |
]
|
| 79 |
+
|
| 80 |
return train_split
|
| 81 |
|
| 82 |
def _generate_examples(self, jsonl_files):
|
|
|
|
| 87 |
json_list = list(jsonl_file)
|
| 88 |
for json_str in json_list:
|
| 89 |
infos = json.loads(json_str)
|
| 90 |
+
|
| 91 |
id = infos['info']['display_id']
|
| 92 |
url = "https://www.youtube.com/watch?v=" + id
|
| 93 |
asr = ""
|
| 94 |
for example in infos['denoised']:
|
| 95 |
asr += example["cleanasr"]
|
| 96 |
+
|
| 97 |
metadata_dict = {
|
| 98 |
"asr_info": infos["denoised"],
|
| 99 |
"info": infos["info"],
|
| 100 |
+
"subtitles": infos["subtitles"],
|
| 101 |
}
|
| 102 |
yield idx, {
|
| 103 |
"video_id": id,
|
| 104 |
"video_url": url,
|
| 105 |
"asr": asr,
|
| 106 |
+
"title": infos['info']['title'],
|
| 107 |
"meta": json.dumps(
|
| 108 |
metadata_dict,
|
| 109 |
default=json_serializer,
|
| 110 |
indent=2
|
| 111 |
)
|
| 112 |
}
|
| 113 |
+
idx += 1
|