carlosdanielhernandezmena
commited on
Commit
•
678512c
1
Parent(s):
f8feed4
Adding files to the repo for the first time
Browse files- chm150_asr.py +122 -0
- corpus/files/metadata_train.tsv +0 -0
- corpus/files/tars_train.paths +1 -0
- corpus/speech/train.tar.gz +3 -0
chm150_asr.py
ADDED
@@ -0,0 +1,122 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from collections import defaultdict
|
2 |
+
import os
|
3 |
+
import json
|
4 |
+
import csv
|
5 |
+
import datasets
|
6 |
+
|
7 |
+
_NAME="chm150_asr"
|
8 |
+
_VERSION="1.0.0"
|
9 |
+
|
10 |
+
_DESCRIPTION = """
|
11 |
+
The CHM150 is a corpus of microphone speech of mexican Spanish taken from 75 male speakers and
|
12 |
+
75 female speakers in a noise environment of a "quiet office" with a total duration of 1.63 hours.
|
13 |
+
"""
|
14 |
+
|
15 |
+
_CITATION = """
|
16 |
+
@misc{menachm150asr2016,
|
17 |
+
title={CHM150 CORPUS: Audio and Transcripts in Spanish of 150 speakers from Mexico City.},
|
18 |
+
ldc_catalog_no={LDC2016S04},
|
19 |
+
DOI={https://doi.org/10.35111/ygn0-wm25},
|
20 |
+
author={Hernandez Mena, Carlos Daniel and Herrera Camacho, Jose Abel},
|
21 |
+
journal={Linguistic Data Consortium, Philadelphia},
|
22 |
+
year={2016},
|
23 |
+
url={https://catalog.ldc.upenn.edu/LDC2016S04},
|
24 |
+
}
|
25 |
+
"""
|
26 |
+
|
27 |
+
_HOMEPAGE = "https://catalog.ldc.upenn.edu/LDC2016S04"
|
28 |
+
|
29 |
+
_LICENSE = "CC-BY-SA-4.0, See http://creativecommons.org/licenses/by-sa/4.0/"
|
30 |
+
|
31 |
+
_BASE_DATA_DIR = "corpus/"
|
32 |
+
_METADATA_TRAIN = os.path.join(_BASE_DATA_DIR,"files", "metadata_train.tsv")
|
33 |
+
|
34 |
+
_TARS_TRAIN = os.path.join(_BASE_DATA_DIR,"files", "tars_train.paths")
|
35 |
+
|
36 |
+
class CHM150Config(datasets.BuilderConfig):
|
37 |
+
"""BuilderConfig for CHM150 CORPUS"""
|
38 |
+
|
39 |
+
def __init__(self, name, **kwargs):
|
40 |
+
name=_NAME
|
41 |
+
super().__init__(name=name, **kwargs)
|
42 |
+
|
43 |
+
class CHM150(datasets.GeneratorBasedBuilder):
|
44 |
+
"""CHM150 CORPUS"""
|
45 |
+
|
46 |
+
VERSION = datasets.Version(_VERSION)
|
47 |
+
BUILDER_CONFIGS = [
|
48 |
+
CHM150Config(
|
49 |
+
name=_NAME,
|
50 |
+
version=datasets.Version(_VERSION),
|
51 |
+
)
|
52 |
+
]
|
53 |
+
|
54 |
+
def _info(self):
|
55 |
+
features = datasets.Features(
|
56 |
+
{
|
57 |
+
"audio_id": datasets.Value("string"),
|
58 |
+
"audio": datasets.Audio(sampling_rate=16000),
|
59 |
+
"speaker_id": datasets.Value("string"),
|
60 |
+
"gender": datasets.Value("string"),
|
61 |
+
"duration": datasets.Value("float32"),
|
62 |
+
"normalized_text": datasets.Value("string"),
|
63 |
+
}
|
64 |
+
)
|
65 |
+
return datasets.DatasetInfo(
|
66 |
+
description=_DESCRIPTION,
|
67 |
+
features=features,
|
68 |
+
homepage=_HOMEPAGE,
|
69 |
+
license=_LICENSE,
|
70 |
+
citation=_CITATION,
|
71 |
+
)
|
72 |
+
|
73 |
+
def _split_generators(self, dl_manager):
|
74 |
+
|
75 |
+
metadata_train=dl_manager.download_and_extract(_METADATA_TRAIN)
|
76 |
+
|
77 |
+
tars_train=dl_manager.download_and_extract(_TARS_TRAIN)
|
78 |
+
|
79 |
+
hash_tar_files=defaultdict(dict)
|
80 |
+
|
81 |
+
with open(tars_train,'r') as f:
|
82 |
+
hash_tar_files['train']=[path.replace('\n','') for path in f]
|
83 |
+
|
84 |
+
hash_meta_paths={"train":metadata_train}
|
85 |
+
audio_paths = dl_manager.download(hash_tar_files)
|
86 |
+
|
87 |
+
splits=["train"]
|
88 |
+
local_extracted_audio_paths = (
|
89 |
+
dl_manager.extract(audio_paths) if not dl_manager.is_streaming else
|
90 |
+
{
|
91 |
+
split:[None] * len(audio_paths[split]) for split in splits
|
92 |
+
}
|
93 |
+
)
|
94 |
+
|
95 |
+
return [
|
96 |
+
datasets.SplitGenerator(
|
97 |
+
name=datasets.Split.TRAIN,
|
98 |
+
gen_kwargs={
|
99 |
+
"audio_archives": [dl_manager.iter_archive(archive) for archive in audio_paths["train"]],
|
100 |
+
"local_extracted_archives_paths": local_extracted_audio_paths["train"],
|
101 |
+
"metadata_paths": hash_meta_paths["train"],
|
102 |
+
}
|
103 |
+
),
|
104 |
+
]
|
105 |
+
|
106 |
+
def _generate_examples(self, audio_archives, local_extracted_archives_paths, metadata_paths):
|
107 |
+
|
108 |
+
features = ["speaker_id","gender","duration","normalized_text"]
|
109 |
+
|
110 |
+
with open(metadata_paths) as f:
|
111 |
+
metadata = {x["audio_id"]: x for x in csv.DictReader(f, delimiter="\t")}
|
112 |
+
|
113 |
+
for audio_archive, local_extracted_archive_path in zip(audio_archives, local_extracted_archives_paths):
|
114 |
+
for audio_filename, audio_file in audio_archive:
|
115 |
+
audio_id =os.path.splitext(os.path.basename(audio_filename))[0]
|
116 |
+
path = os.path.join(local_extracted_archive_path, audio_filename) if local_extracted_archive_path else audio_filename
|
117 |
+
|
118 |
+
yield audio_id, {
|
119 |
+
"audio_id": audio_id,
|
120 |
+
**{feature: metadata[audio_id][feature] for feature in features},
|
121 |
+
"audio": {"path": path, "bytes": audio_file.read()},
|
122 |
+
}
|
corpus/files/metadata_train.tsv
ADDED
The diff for this file is too large to render.
See raw diff
|
|
corpus/files/tars_train.paths
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
corpus/speech/train.tar.gz
|
corpus/speech/train.tar.gz
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:22edab7b068873e44acd52a6f1f1465279bc5821ba29bcf2485bb75b027a0870
|
3 |
+
size 110086793
|