Bagas Shalahuddin Wahid
commited on
Commit
·
6dd5316
1
Parent(s):
29ecf0c
test 1
Browse files- README.md +9 -0
- __init__.py +0 -0
- requirements.txt +2 -0
- su_id_asr_split.py +176 -0
README.md
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
language:
|
| 3 |
+
- jav
|
| 4 |
+
pretty_name: Jv Id Asr
|
| 5 |
+
task_categories:
|
| 6 |
+
- speech-recognition
|
| 7 |
+
tags:
|
| 8 |
+
- speech-recognition
|
| 9 |
+
---
|
__init__.py
ADDED
|
File without changes
|
requirements.txt
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
seacrowd>=0.2.0
|
| 2 |
+
gdown
|
su_id_asr_split.py
ADDED
|
@@ -0,0 +1,176 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import csv
|
| 2 |
+
import os
|
| 3 |
+
from typing import Dict, List
|
| 4 |
+
|
| 5 |
+
import datasets
|
| 6 |
+
|
| 7 |
+
from seacrowd.utils import schemas
|
| 8 |
+
from seacrowd.utils.configs import SEACrowdConfig
|
| 9 |
+
from seacrowd.utils.constants import (DEFAULT_SEACROWD_VIEW_NAME,
|
| 10 |
+
DEFAULT_SOURCE_VIEW_NAME, Tasks)
|
| 11 |
+
|
| 12 |
+
_DATASETNAME = "su_id_asr"
|
| 13 |
+
_SOURCE_VIEW_NAME = DEFAULT_SOURCE_VIEW_NAME
|
| 14 |
+
_UNIFIED_VIEW_NAME = DEFAULT_SEACROWD_VIEW_NAME
|
| 15 |
+
|
| 16 |
+
_LANGUAGES = ["sun"]
|
| 17 |
+
_LOCAL = False
|
| 18 |
+
_CITATION = """\
|
| 19 |
+
@inproceedings{sodimana18_sltu,
|
| 20 |
+
author={Keshan Sodimana and Pasindu {De Silva} and Supheakmungkol Sarin and Oddur Kjartansson and Martin Jansche and Knot Pipatsrisawat and Linne Ha},
|
| 21 |
+
title={{A Step-by-Step Process for Building TTS Voices Using Open Source Data and Frameworks for Bangla, Javanese, Khmer, Nepali, Sinhala, and Sundanese}},
|
| 22 |
+
year=2018,
|
| 23 |
+
booktitle={Proc. 6th Workshop on Spoken Language Technologies for Under-Resourced Languages (SLTU 2018)},
|
| 24 |
+
pages={66--70},
|
| 25 |
+
doi={10.21437/SLTU.2018-14}
|
| 26 |
+
}
|
| 27 |
+
"""
|
| 28 |
+
|
| 29 |
+
_DESCRIPTION = """\
|
| 30 |
+
Sundanese ASR training data set containing ~220K utterances.
|
| 31 |
+
This dataset was collected by Google in Indonesia.
|
| 32 |
+
"""
|
| 33 |
+
|
| 34 |
+
_HOMEPAGE = "https://indonlp.github.io/nusa-catalogue/card.html?su_id_asr"
|
| 35 |
+
|
| 36 |
+
_LICENSE = "Attribution-ShareAlike 4.0 International."
|
| 37 |
+
|
| 38 |
+
_URLs = {
|
| 39 |
+
"su_id_asr_train": "https://drive.google.com/file/d/1-9oCkIQSok_STemyNBLx2EDQXfmWabsU/view?usp=sharing",
|
| 40 |
+
"su_id_asr_dev": "https://drive.google.com/file/d/1IkqEuGrIyKbCSDo9q6F6_r_vkeJ1pcrp/view?usp=sharing",
|
| 41 |
+
"su_id_asr_test": "https://drive.google.com/file/d/1-7aLW9Tzs4lxm9ImWho91FjpgpVC6wAc/view?usp=sharing",
|
| 42 |
+
}
|
| 43 |
+
|
| 44 |
+
_SUPPORTED_TASKS = [Tasks.SPEECH_RECOGNITION] # example: [Tasks.TRANSLATION, Tasks.NAMED_ENTITY_RECOGNITION, Tasks.RELATION_EXTRACTION]
|
| 45 |
+
|
| 46 |
+
_SOURCE_VERSION = "1.0.0"
|
| 47 |
+
|
| 48 |
+
_SEACROWD_VERSION = "2024.06.20"
|
| 49 |
+
|
| 50 |
+
def download_from_gdrive(url, output_dir):
|
| 51 |
+
"""Download a file from Google Drive and save it to the specified directory."""
|
| 52 |
+
file_id = url.split("/d/")[-1].split("/")[0] # Extract FILE_ID from URL
|
| 53 |
+
gdrive_url = f"https://drive.google.com/uc?id={file_id}"
|
| 54 |
+
output_path = os.path.join(output_dir, f"{file_id}.zip") # Save file
|
| 55 |
+
gdown.download(gdrive_url, output_path, quiet=False)
|
| 56 |
+
return output_path
|
| 57 |
+
|
| 58 |
+
|
| 59 |
+
class JvIdASR(datasets.GeneratorBasedBuilder):
|
| 60 |
+
"""Javanese ASR training data set containing ~185K utterances."""
|
| 61 |
+
|
| 62 |
+
SOURCE_VERSION = datasets.Version(_SOURCE_VERSION)
|
| 63 |
+
SEACROWD_VERSION = datasets.Version(_SEACROWD_VERSION)
|
| 64 |
+
|
| 65 |
+
BUILDER_CONFIGS = [
|
| 66 |
+
SEACrowdConfig(
|
| 67 |
+
name="su_id_asr_source",
|
| 68 |
+
version=SOURCE_VERSION,
|
| 69 |
+
description="su_id_asr source schema",
|
| 70 |
+
schema="source",
|
| 71 |
+
subset_id="su_id_asr",
|
| 72 |
+
),
|
| 73 |
+
SEACrowdConfig(
|
| 74 |
+
name="su_id_asr_seacrowd_sptext",
|
| 75 |
+
version=SEACROWD_VERSION,
|
| 76 |
+
description="su_id_asr Nusantara schema",
|
| 77 |
+
schema="seacrowd_sptext",
|
| 78 |
+
subset_id="su_id_asr",
|
| 79 |
+
),
|
| 80 |
+
]
|
| 81 |
+
|
| 82 |
+
DEFAULT_CONFIG_NAME = "su_id_asr_source"
|
| 83 |
+
|
| 84 |
+
|
| 85 |
+
def _split_generators(self, dl_manager: datasets.DownloadManager) -> List[datasets.SplitGenerator]:
|
| 86 |
+
"""Returns SplitGenerators."""
|
| 87 |
+
|
| 88 |
+
def download_from_gdrive(url, name):
|
| 89 |
+
# Create a temporary directory for downloads
|
| 90 |
+
with tempfile.TemporaryDirectory() as temp_dir:
|
| 91 |
+
file_id = url.split("/d/")[-1].split("/")[0]
|
| 92 |
+
output_path = os.path.join(temp_dir, f"{name}.zip")
|
| 93 |
+
|
| 94 |
+
# Download using gdown with fuzzy=True
|
| 95 |
+
gdown.download(url, output_path, fuzzy=True)
|
| 96 |
+
|
| 97 |
+
# Use dl_manager to extract and manage the downloaded file
|
| 98 |
+
extracted_path = dl_manager.extract(output_path)
|
| 99 |
+
return extracted_path
|
| 100 |
+
|
| 101 |
+
# Download and extract all splits
|
| 102 |
+
paths = {
|
| 103 |
+
"train": download_from_gdrive(_URLs["su_id_asr_train"], 'asr_sundanese_train'),
|
| 104 |
+
"dev": download_from_gdrive(_URLs["su_id_asr_dev"], 'asr_sundanese_dev'),
|
| 105 |
+
"test": download_from_gdrive(_URLs["su_id_asr_test"], 'asr_sundanese_test')
|
| 106 |
+
}
|
| 107 |
+
|
| 108 |
+
return [
|
| 109 |
+
datasets.SplitGenerator(
|
| 110 |
+
name=datasets.Split.TRAIN,
|
| 111 |
+
gen_kwargs={"filepath": paths["train"]},
|
| 112 |
+
),
|
| 113 |
+
datasets.SplitGenerator(
|
| 114 |
+
name=datasets.Split.VALIDATION,
|
| 115 |
+
gen_kwargs={"filepath": paths["dev"]},
|
| 116 |
+
),
|
| 117 |
+
datasets.SplitGenerator(
|
| 118 |
+
name=datasets.Split.TEST,
|
| 119 |
+
gen_kwargs={"filepath": paths["test"]},
|
| 120 |
+
),
|
| 121 |
+
]
|
| 122 |
+
|
| 123 |
+
def _info(self) -> datasets.DatasetInfo:
|
| 124 |
+
if self.config.schema == "source":
|
| 125 |
+
features = datasets.Features(
|
| 126 |
+
{
|
| 127 |
+
"id": datasets.Value("string"),
|
| 128 |
+
"speaker_id": datasets.Value("string"),
|
| 129 |
+
"path": datasets.Value("string"),
|
| 130 |
+
"audio": datasets.Audio(sampling_rate=16_000),
|
| 131 |
+
"text": datasets.Value("string"),
|
| 132 |
+
}
|
| 133 |
+
)
|
| 134 |
+
elif self.config.schema == "seacrowd_sptext":
|
| 135 |
+
features = schemas.speech_text_features
|
| 136 |
+
|
| 137 |
+
return datasets.DatasetInfo(
|
| 138 |
+
description=_DESCRIPTION,
|
| 139 |
+
features=features,
|
| 140 |
+
homepage=_HOMEPAGE,
|
| 141 |
+
license=_LICENSE,
|
| 142 |
+
citation=_CITATION,
|
| 143 |
+
)
|
| 144 |
+
|
| 145 |
+
def _generate_examples(self, filepath: str):
|
| 146 |
+
tsv_file = os.path.join(filepath, "asr_sundanese", "utt_spk_text.tsv")
|
| 147 |
+
with open(tsv_file, "r") as f:
|
| 148 |
+
tsv_file = csv.reader(f, delimiter="\t")
|
| 149 |
+
for line in tsv_file:
|
| 150 |
+
audio_id, sp_id, text = line[0], line[1], line[2]
|
| 151 |
+
wav_path = os.path.join(filepath, "asr_sundanese", "data", "{}".format(audio_id[:2]), "{}.flac".format(audio_id))
|
| 152 |
+
|
| 153 |
+
if os.path.exists(wav_path):
|
| 154 |
+
if self.config.schema == "source":
|
| 155 |
+
ex = {
|
| 156 |
+
"id": audio_id,
|
| 157 |
+
"speaker_id": sp_id,
|
| 158 |
+
"path": wav_path,
|
| 159 |
+
"audio": wav_path,
|
| 160 |
+
"text": text,
|
| 161 |
+
}
|
| 162 |
+
yield audio_id, ex
|
| 163 |
+
elif self.config.schema == "seacrowd_sptext":
|
| 164 |
+
ex = {
|
| 165 |
+
"id": audio_id,
|
| 166 |
+
"speaker_id": sp_id,
|
| 167 |
+
"path": wav_path,
|
| 168 |
+
"audio": wav_path,
|
| 169 |
+
"text": text,
|
| 170 |
+
"metadata": {
|
| 171 |
+
"speaker_age": None,
|
| 172 |
+
"speaker_gender": None,
|
| 173 |
+
},
|
| 174 |
+
}
|
| 175 |
+
yield audio_id, ex
|
| 176 |
+
f.close()
|