Datasets:
Commit ·
94efbe5
1
Parent(s): 211d019
Add ASCEND loading script
Browse files
ascend.py
ADDED
|
@@ -0,0 +1,131 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# coding=utf-8
|
| 2 |
+
# Copyright 2021 The HuggingFace Datasets Authors and the current dataset script contributor.
|
| 3 |
+
#
|
| 4 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 5 |
+
# you may not use this file except in compliance with the License.
|
| 6 |
+
# You may obtain a copy of the License at
|
| 7 |
+
#
|
| 8 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 9 |
+
#
|
| 10 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 11 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 12 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 |
+
# See the License for the specific language governing permissions and
|
| 14 |
+
# limitations under the License.
|
| 15 |
+
""" Common Voice Dataset"""
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
import os
|
| 19 |
+
|
| 20 |
+
import datasets
|
| 21 |
+
from datasets.tasks import AutomaticSpeechRecognition
|
| 22 |
+
import pandas as pd
|
| 23 |
+
|
| 24 |
+
|
| 25 |
+
_CITATION = """\
|
| 26 |
+
@inproceedings{lovenia2021ascend,
|
| 27 |
+
title = {ASCEND: A Spontaneous Chinese-English Dataset for Code-switching in Multi-turn Conversation},
|
| 28 |
+
author = {Lovenia, Holy and Cahyawijaya, Samuel and Winata, Genta Indra and Xu, Peng and Yan, Xu and Liu, Zihan and Frieske, Rita and Yu, Tiezheng and Dai, Wenliang and Barezi, Elham J and others},
|
| 29 |
+
booktitle = {Proceedings of the International Conference on Language Resources and Evaluation, {LREC} 2022, 20-25 June 2022, Lu Palais du Pharo, France},
|
| 30 |
+
publisher = {European Language Resources Association},
|
| 31 |
+
year = {2022},
|
| 32 |
+
pages = {}
|
| 33 |
+
}
|
| 34 |
+
"""
|
| 35 |
+
|
| 36 |
+
_DESCRIPTION = """\
|
| 37 |
+
ASCEND (A Spontaneous Chinese-English Dataset) introduces a high-quality resource of spontaneous multi-turn conversational dialogue Chinese-English code-switching corpus collected in Hong Kong. ASCEND consists of 10.62 hours of spontaneous speech with a total of ~12.3K utterances. The corpus is split into 3 sets: training, validation, and test with a ratio of 8:1:1 while maintaining a balanced gender proportion on each set.
|
| 38 |
+
"""
|
| 39 |
+
|
| 40 |
+
_HOMEPAGE = "https://huggingface.co/datasets/CAiRE/ASCEND"
|
| 41 |
+
|
| 42 |
+
|
| 43 |
+
class ASCENDConfig(datasets.BuilderConfig):
|
| 44 |
+
"""BuilderConfig for ASCEND."""
|
| 45 |
+
|
| 46 |
+
def __init__(self, name, **kwargs):
|
| 47 |
+
"""
|
| 48 |
+
Args:
|
| 49 |
+
**kwargs: keyword arguments forwarded to super.
|
| 50 |
+
"""
|
| 51 |
+
super(ASCENDConfig, self).__init__(name, **kwargs)
|
| 52 |
+
|
| 53 |
+
|
| 54 |
+
class ASCEND(datasets.GeneratorBasedBuilder):
|
| 55 |
+
"""ASCEND: A Spontaneous Chinese-English Dataset for code-switching. Snapshot date: 5 January 2022."""
|
| 56 |
+
|
| 57 |
+
BUILDER_CONFIGS = [
|
| 58 |
+
ASCENDConfig(
|
| 59 |
+
name="train",
|
| 60 |
+
version=datasets.Version("1.0.0", ""),
|
| 61 |
+
description=_DESCRIPTION,
|
| 62 |
+
),
|
| 63 |
+
ASCENDConfig(
|
| 64 |
+
name="validation",
|
| 65 |
+
version=datasets.Version("1.0.0", ""),
|
| 66 |
+
description=_DESCRIPTION,
|
| 67 |
+
),
|
| 68 |
+
ASCENDConfig(
|
| 69 |
+
name="test",
|
| 70 |
+
version=datasets.Version("1.0.0", ""),
|
| 71 |
+
description=_DESCRIPTION,
|
| 72 |
+
),
|
| 73 |
+
]
|
| 74 |
+
|
| 75 |
+
def _info(self):
|
| 76 |
+
features = datasets.Features(
|
| 77 |
+
{
|
| 78 |
+
"path": datasets.Value("string"),
|
| 79 |
+
"audio": datasets.Audio(sampling_rate=16_000),
|
| 80 |
+
"transcription": datasets.Value("string"),
|
| 81 |
+
"duration": datasets.Value("float32"),
|
| 82 |
+
"language": datasets.Value("string"),
|
| 83 |
+
"original_speaker_id": datasets.Value("int64"),
|
| 84 |
+
"session_id": datasets.Value("int64"),
|
| 85 |
+
"topic": datasets.Value("string"),
|
| 86 |
+
}
|
| 87 |
+
)
|
| 88 |
+
return datasets.DatasetInfo(
|
| 89 |
+
description=_DESCRIPTION,
|
| 90 |
+
features=features,
|
| 91 |
+
supervised_keys=None,
|
| 92 |
+
homepage=_HOMEPAGE,
|
| 93 |
+
citation=_CITATION,
|
| 94 |
+
task_templates=[AutomaticSpeechRecognition(audio_column="audio", transcription_column="transcription")],
|
| 95 |
+
)
|
| 96 |
+
|
| 97 |
+
def _split_generators(self, dl_manager):
|
| 98 |
+
return [
|
| 99 |
+
datasets.SplitGenerator(
|
| 100 |
+
name=datasets.Split.TRAIN,
|
| 101 |
+
gen_kwargs={
|
| 102 |
+
"metadata_path": "train_metadata.csv",
|
| 103 |
+
"split": "train",
|
| 104 |
+
},
|
| 105 |
+
),
|
| 106 |
+
datasets.SplitGenerator(
|
| 107 |
+
name=datasets.Split.TEST,
|
| 108 |
+
gen_kwargs={
|
| 109 |
+
"metadata_path": "test_metadata.csv",
|
| 110 |
+
"split": "test"
|
| 111 |
+
},
|
| 112 |
+
),
|
| 113 |
+
datasets.SplitGenerator(
|
| 114 |
+
name=datasets.Split.VALIDATION,
|
| 115 |
+
gen_kwargs={
|
| 116 |
+
"metadata_path": "validation_metadata.csv",
|
| 117 |
+
"split": "validation",
|
| 118 |
+
},
|
| 119 |
+
),
|
| 120 |
+
]
|
| 121 |
+
|
| 122 |
+
def _generate_examples(self, metadata_path):
|
| 123 |
+
metadata_df = pd.read_csv(metadata_path)
|
| 124 |
+
|
| 125 |
+
for index, row in metadata_df.iterrows():
|
| 126 |
+
example = {
|
| 127 |
+
"id": index,
|
| 128 |
+
"audio": row["audio"],
|
| 129 |
+
"transcription": row["transcription"]
|
| 130 |
+
}
|
| 131 |
+
yield index, example
|