|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"""ASR Dataset for various football leagues and seasons""" |
|
|
|
import json |
|
import os |
|
|
|
import datasets |
|
|
|
|
|
_CITATION = """\ |
|
@InProceedings{huggingface:dataset, |
|
title = {ASR Dataset for Football Leagues}, |
|
author={Your Name}, |
|
year={2024} |
|
} |
|
""" |
|
|
|
_DESCRIPTION = """\ |
|
This dataset contains Automatic Speech Recognition (ASR) data for various football leagues and seasons. |
|
The dataset includes ASR outputs from Whisper v1, v2, and v3, along with their English-translated versions. |
|
""" |
|
|
|
_HOMEPAGE = "https://github.com/SoccerNet/sn-echoes" |
|
|
|
_LICENSE = "Apache License 2.0" |
|
|
|
_URLS = { |
|
"whisper_v1": "whisper_v1/", |
|
"whisper_v1_en": "wisper_v1_en/", |
|
"whisper_v2": "wisper_v2/", |
|
"whisper_v2_en": "wisper_v2_en/", |
|
"whisper_v3": "wisper_v3/", |
|
} |
|
|
|
|
|
class FootballASRDataset(datasets.GeneratorBasedBuilder): |
|
"""ASR Dataset for various football leagues and seasons""" |
|
|
|
VERSION = datasets.Version("1.0.0") |
|
|
|
BUILDER_CONFIGS = [ |
|
datasets.BuilderConfig(name="whisper_v1", version=VERSION, description="Contains ASR from Whisper v1"), |
|
datasets.BuilderConfig(name="whisper_v1_en", version=VERSION, description="English-translated datasets from Whisper v1"), |
|
|
|
|
|
|
|
] |
|
|
|
DEFAULT_CONFIG_NAME = "whisper_v1" |
|
|
|
def _info(self): |
|
features = datasets.Features( |
|
{ |
|
"segment_index": datasets.Value("int32"), |
|
"start_time": datasets.Value("float"), |
|
"end_time": datasets.Value("float"), |
|
"transcribed_text": datasets.Value("string"), |
|
} |
|
) |
|
return datasets.DatasetInfo( |
|
description=_DESCRIPTION, |
|
features=features, |
|
homepage=_HOMEPAGE, |
|
license=_LICENSE, |
|
citation=_CITATION, |
|
) |
|
|
|
def _split_generators(self, dl_manager): |
|
urls = _URLS[self.config.name] |
|
data_dir = dl_manager.download_and_extract("https://codeload.github.com/SoccerNet/sn-echoes/zip/refs/heads/main") +"/sn-echoes-main/Dataset/" |
|
print("data_dir", { "data_dir": os.path.join(data_dir+ urls),}) |
|
return [ |
|
datasets.SplitGenerator( |
|
name=datasets.Split.TRAIN, |
|
gen_kwargs={ |
|
"data_dir": os.path.join(data_dir+ urls), |
|
},) |
|
] |
|
|
|
def _generate_examples(self, data_dir,): |
|
for root, _, files in os.walk(data_dir): |
|
for file in files: |
|
if file.endswith(".json"): |
|
with open(os.path.join(root, file), encoding="utf-8") as f: |
|
data = json.load(f) |
|
for segment_index, segment_data in data["segments"].items(): |
|
yield f"{file}_{segment_index}", { |
|
"segment_index": segment_index, |
|
"start_time": segment_data[0], |
|
"end_time": segment_data[1], |
|
"transcribed_text": segment_data[2], |
|
} |
|
|