commit files to HF hub
Browse files- youtube-transcription.py +72 -0
youtube-transcription.py
ADDED
@@ -0,0 +1,72 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import datasets
|
2 |
+
|
3 |
+
_CITATION = """\
|
4 |
+
@InProceedings{huggingface:dataset,
|
5 |
+
title = {A great new dataset},
|
6 |
+
author={huggingface, Inc.
|
7 |
+
},
|
8 |
+
year={2021}
|
9 |
+
}
|
10 |
+
"""
|
11 |
+
|
12 |
+
_DESCRIPTION = """\
|
13 |
+
This is YouTube video transcription dataset built from YTTTS Speech Collection for semantic search.
|
14 |
+
"""
|
15 |
+
_HOMEPAGE = "https://huggingface.co/datasets/ashraq/youtube-transcription"
|
16 |
+
|
17 |
+
_LICENSE = ""
|
18 |
+
|
19 |
+
TRAIN_URL = "yt-transcriptions.jsonl"
|
20 |
+
|
21 |
+
|
22 |
+
class DhivehiCorpus(datasets.GeneratorBasedBuilder):
|
23 |
+
VERSION = datasets.Version("1.1.0")
|
24 |
+
|
25 |
+
def _info(self):
|
26 |
+
return datasets.DatasetInfo(
|
27 |
+
description=_DESCRIPTION,
|
28 |
+
features=datasets.Features(
|
29 |
+
{
|
30 |
+
"video_id": datasets.Value("string"),
|
31 |
+
"text": datasets.Value("string"),
|
32 |
+
"start_timestamp": datasets.Value("string"),
|
33 |
+
"end_timestamp": datasets.Value("string"),
|
34 |
+
"start_second": datasets.Value("string"),
|
35 |
+
"end_second": datasets.Value("string"),
|
36 |
+
"url": datasets.Value("string")
|
37 |
+
},
|
38 |
+
),
|
39 |
+
|
40 |
+
supervised_keys=None,
|
41 |
+
homepage=_HOMEPAGE,
|
42 |
+
citation=_CITATION,
|
43 |
+
)
|
44 |
+
|
45 |
+
def _split_generators(self, dl_manager):
|
46 |
+
train_path = dl_manager.download_and_extract(TRAIN_URL)
|
47 |
+
return [
|
48 |
+
datasets.SplitGenerator(
|
49 |
+
name=datasets.Split.TRAIN,
|
50 |
+
gen_kwargs={
|
51 |
+
"filepath": train_path,
|
52 |
+
"split": "train",
|
53 |
+
},
|
54 |
+
),
|
55 |
+
]
|
56 |
+
|
57 |
+
def _generate_examples(self, filepath, split):
|
58 |
+
with open(filepath, encoding="utf8") as f:
|
59 |
+
id_ = 0
|
60 |
+
for doc in f:
|
61 |
+
data = {
|
62 |
+
"video_id": doc["video_id"],
|
63 |
+
"text": doc["text"],
|
64 |
+
"start_timestamp": doc["start_timestamp"],
|
65 |
+
"end_timestamp": doc["end_timestamp"],
|
66 |
+
"start_second": doc["start_second"],
|
67 |
+
"end_second": doc["end_second"],
|
68 |
+
"url": doc["url"]
|
69 |
+
}
|
70 |
+
yield id_, data
|
71 |
+
id_ += 1
|
72 |
+
|