Datasets:
Tasks:
Automatic Speech Recognition
Languages:
Catalan
Size:
n<1K
ArXiv:
Tags:
Catalan Speech
Project AINA
Barcelona Supercomputing Center
BSC
code-switching
catalan-spanish code-switching
License:
Commit
·
d3a0020
1
Parent(s):
5c4d01c
Creating the repo structure
Browse files- BSCs_Code_Switching_CA-ES_ASR_Test.py +120 -0
- corpus/files/metadata.tsv +0 -0
- corpus/files/tars.paths +2 -0
- corpus/speech/quitar.txt +0 -0
BSCs_Code_Switching_CA-ES_ASR_Test.py
ADDED
|
@@ -0,0 +1,120 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from collections import defaultdict
|
| 2 |
+
import os
|
| 3 |
+
import json
|
| 4 |
+
import csv
|
| 5 |
+
import datasets
|
| 6 |
+
|
| 7 |
+
_NAME="BSCs_Code_Switching_CA-ES_ASR_Test"
|
| 8 |
+
_VERSION="1.0.0"
|
| 9 |
+
|
| 10 |
+
_DESCRIPTION = """
|
| 11 |
+
The BSC's Code-Switching Catalan-Spanish ASR Test is a speech dataset of 4 hours and 9 minutes. It consists of carefully selected recordings that feature code-switching between Catalan and Spanish. This dataset is designed to be a test set for Catalan ASR systems that need to handle code-switching to Spanish.
|
| 12 |
+
"""
|
| 13 |
+
|
| 14 |
+
_CITATION = """
|
| 15 |
+
@misc{mena2025optimizing,
|
| 16 |
+
title={BSC's Code-Switching Catalan-Spanish ASR Test},
|
| 17 |
+
author={Hernández Mena, Carlos Daniel and Serra, Pol and Romero, Jacobo and Messaoudi, Abir and Giraldo, Jose and Armentano-Oller, Carme and Zevallos, Rodolfo and Meza, Ivan and Hernando, Javier},
|
| 18 |
+
organization={Barcelona Supercomputing Center},
|
| 19 |
+
year={2025},
|
| 20 |
+
url={https://huggingface.co/datasets/BSC-LT/BSCs_Code_Switching_CA-ES_ASR_Test},
|
| 21 |
+
}
|
| 22 |
+
"""
|
| 23 |
+
|
| 24 |
+
_HOMEPAGE = "https://huggingface.co/BSC-LT"
|
| 25 |
+
|
| 26 |
+
_LICENSE = "CC-BY-4.0, See https://creativecommons.org/licenses/by/4.0/deed.en"
|
| 27 |
+
|
| 28 |
+
_BASE_DATA_DIR = "corpus/"
|
| 29 |
+
_METADATA = os.path.join(_BASE_DATA_DIR,"files", "metadata.tsv")
|
| 30 |
+
|
| 31 |
+
_TARS = os.path.join(_BASE_DATA_DIR,"files", "tars.paths")
|
| 32 |
+
|
| 33 |
+
class BCSCSATConfig(datasets.BuilderConfig):
|
| 34 |
+
"""BuilderConfig for BSC's Code-Switching Catalan-Spanish ASR Test"""
|
| 35 |
+
|
| 36 |
+
def __init__(self, name, **kwargs):
|
| 37 |
+
name=_NAME
|
| 38 |
+
super().__init__(name=name, **kwargs)
|
| 39 |
+
|
| 40 |
+
class BCSCSAT(datasets.GeneratorBasedBuilder):
|
| 41 |
+
"""BSC's Code-Switching Catalan-Spanish ASR Test"""
|
| 42 |
+
|
| 43 |
+
VERSION = datasets.Version(_VERSION)
|
| 44 |
+
BUILDER_CONFIGS = [
|
| 45 |
+
BCSCSATConfig(
|
| 46 |
+
name=_NAME,
|
| 47 |
+
version=datasets.Version(_VERSION),
|
| 48 |
+
)
|
| 49 |
+
]
|
| 50 |
+
|
| 51 |
+
def _info(self):
|
| 52 |
+
features = datasets.Features(
|
| 53 |
+
{
|
| 54 |
+
"audio_id": datasets.Value("string"),
|
| 55 |
+
"audio": datasets.Audio(sampling_rate=16000),
|
| 56 |
+
"source": datasets.Value("string"),
|
| 57 |
+
"split": datasets.Value("string"),
|
| 58 |
+
"duration": datasets.Value("float32"),
|
| 59 |
+
"normalized_text": datasets.Value("string"),
|
| 60 |
+
}
|
| 61 |
+
)
|
| 62 |
+
return datasets.DatasetInfo(
|
| 63 |
+
description=_DESCRIPTION,
|
| 64 |
+
features=features,
|
| 65 |
+
homepage=_HOMEPAGE,
|
| 66 |
+
license=_LICENSE,
|
| 67 |
+
citation=_CITATION,
|
| 68 |
+
)
|
| 69 |
+
|
| 70 |
+
def _split_generators(self, dl_manager):
|
| 71 |
+
|
| 72 |
+
metadata=dl_manager.download_and_extract(_METADATA)
|
| 73 |
+
|
| 74 |
+
tars=dl_manager.download_and_extract(_TARS)
|
| 75 |
+
|
| 76 |
+
hash_tar_files=defaultdict(dict)
|
| 77 |
+
|
| 78 |
+
with open(tars,'r') as f:
|
| 79 |
+
hash_tar_files['test']=[path.replace('\n','') for path in f]
|
| 80 |
+
|
| 81 |
+
hash_meta_paths={"test":metadata}
|
| 82 |
+
audio_paths = dl_manager.download(hash_tar_files)
|
| 83 |
+
|
| 84 |
+
splits=["test"]
|
| 85 |
+
local_extracted_audio_paths = (
|
| 86 |
+
dl_manager.extract(audio_paths) if not dl_manager.is_streaming else
|
| 87 |
+
{
|
| 88 |
+
split:[None] * len(audio_paths[split]) for split in splits
|
| 89 |
+
}
|
| 90 |
+
)
|
| 91 |
+
|
| 92 |
+
return [
|
| 93 |
+
datasets.SplitGenerator(
|
| 94 |
+
name=datasets.Split.TEST,
|
| 95 |
+
gen_kwargs={
|
| 96 |
+
"audio_archives": [dl_manager.iter_archive(archive) for archive in audio_paths["test"]],
|
| 97 |
+
"local_extracted_archives_paths": local_extracted_audio_paths["test"],
|
| 98 |
+
"metadata_paths": hash_meta_paths["test"],
|
| 99 |
+
}
|
| 100 |
+
),
|
| 101 |
+
]
|
| 102 |
+
|
| 103 |
+
def _generate_examples(self, audio_archives, local_extracted_archives_paths, metadata_paths):
|
| 104 |
+
|
| 105 |
+
features = ["source","split","duration","normalized_text"]
|
| 106 |
+
|
| 107 |
+
with open(metadata_paths) as f:
|
| 108 |
+
metadata = {x["audio_id"]: x for x in csv.DictReader(f, delimiter="\t")}
|
| 109 |
+
|
| 110 |
+
for audio_archive, local_extracted_archive_path in zip(audio_archives, local_extracted_archives_paths):
|
| 111 |
+
for audio_filename, audio_file in audio_archive:
|
| 112 |
+
audio_id =os.path.splitext(os.path.basename(audio_filename))[0]
|
| 113 |
+
path = os.path.join(local_extracted_archive_path, audio_filename) if local_extracted_archive_path else audio_filename
|
| 114 |
+
|
| 115 |
+
yield audio_id, {
|
| 116 |
+
"audio_id": audio_id,
|
| 117 |
+
**{feature: metadata[audio_id][feature] for feature in features},
|
| 118 |
+
"audio": {"path": path, "bytes": audio_file.read()},
|
| 119 |
+
}
|
| 120 |
+
|
corpus/files/metadata.tsv
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
corpus/files/tars.paths
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
corpus/speech/corts_valencianes_anonymized.tar.gz
|
| 2 |
+
corpus/speech/parlament_parla.tar.gz
|
corpus/speech/quitar.txt
ADDED
|
File without changes
|