new
Browse files
.gitattributes
CHANGED
@@ -35,3 +35,7 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
35 |
*.mp3 filter=lfs diff=lfs merge=lfs -text
|
36 |
*.ogg filter=lfs diff=lfs merge=lfs -text
|
37 |
*.wav filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
|
35 |
*.mp3 filter=lfs diff=lfs merge=lfs -text
|
36 |
*.ogg filter=lfs diff=lfs merge=lfs -text
|
37 |
*.wav filter=lfs diff=lfs merge=lfs -text
|
38 |
+
*gz filter=lfs diff=lfs merge=lfs -text
|
39 |
+
*json* filter=lfs diff=lfs merge=lfs -text
|
40 |
+
*track* filter=lfs diff=lfs merge=lfs -text
|
41 |
+
*tfevent filter=lfs diff=lfs merge=lfs -text
|
NST_hesitate.py
ADDED
@@ -0,0 +1,216 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# coding=utf-8
|
2 |
+
# Copyright 2020 The TensorFlow Datasets Authors and the HuggingFace Datasets Authors.
|
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 |
+
|
16 |
+
# Lint as: python3
|
17 |
+
"""NST_hesitate_hesitate: Nordic Language Technology"""
|
18 |
+
|
19 |
+
import io
|
20 |
+
import json
|
21 |
+
import tarfile
|
22 |
+
import datasets
|
23 |
+
from datasets.tasks import AutomaticSpeechRecognition
|
24 |
+
|
25 |
+
|
26 |
+
_CITATION = """\
|
27 |
+
@inproceedings{,
|
28 |
+
title={},
|
29 |
+
author={},
|
30 |
+
booktitle={},
|
31 |
+
year={2022},
|
32 |
+
url={https://arxiv.org/abs/}
|
33 |
+
}
|
34 |
+
"""
|
35 |
+
|
36 |
+
_DESCRIPTION = """\
|
37 |
+
This database was created by Nordic Language Technology for the development of automatic speech recognition and dictation in Norwegian. In this version, the organization of the data have been altered to improve the usefulness of the database.
|
38 |
+
|
39 |
+
The acoustic databases described below were developed by the firm Nordisk språkteknologi holding AS (NST_hesitate), which went bankrupt in 2003. In 2006, a consortium consisting of the University of Oslo, the University of Bergen, the Norwegian University of Science and Technology, the Norwegian Language Council and IBM bought the bankruptcy estate of NST_hesitate, in order to ensure that the language resources developed by NST_hesitate were preserved. In 2009, the Norwegian Ministry of Culture charged the National Library of Norway with the task of creating a Norwegian language bank, which they initiated in 2010. The resources from NST_hesitate were transferred to the National Library in May 2011, and are now made available in Språkbanken, for the time being without any further modification. Språkbanken is open for feedback from users about how the resources can be improved, and we are also interested in improved versions of the databases that users wish to share with other users. Please send response and feedback to sprakbanken@nb.no.
|
40 |
+
"""
|
41 |
+
|
42 |
+
_HOMEPAGE = "https://www.nb.no/sprakbanken/en/resource-catalogue/oai-nb-no-sbr-54/"
|
43 |
+
|
44 |
+
# Example: https://huggingface.co/datasets/NbAiLab/NST_hesitate/resolve/main/data/train/NST_hesitate_no-0001-of-0001.tar.gz
|
45 |
+
_DATA_URL = "https://huggingface.co/datasets/NbAiLab/NST_hesitate/resolve/main/data/{split}/NST_hesitate_{lang_code}-{shard_idx:04d}-of-{shard_total:04d}.tar.gz"
|
46 |
+
# Example: https://huggingface.co/datasets/NbAiLab/NST_hesitate/resolve/main/data/test/NST_hesitate_no-0001-of-0001.json
|
47 |
+
_METADATA_URL = "https://huggingface.co/datasets/NbAiLab/NST_hesitate/resolve/main/data/{split}/NST_hesitate_{lang_code}-{shard_idx:04d}-of-{shard_total:04d}.json"
|
48 |
+
|
49 |
+
_SHARDS = {
|
50 |
+
"no": {
|
51 |
+
"test":1,
|
52 |
+
"train": 1,
|
53 |
+
},
|
54 |
+
}
|
55 |
+
|
56 |
+
_METADATA_MAPPING = {
|
57 |
+
"id": "Id",
|
58 |
+
"speakerId": "SpeakerId",
|
59 |
+
"speakerName": "SpeakerName",
|
60 |
+
"speakerAge": "SpeakerAge",
|
61 |
+
"sex": "Sex",
|
62 |
+
"speakerBirthPlace": "SpeakerBirthPlace",
|
63 |
+
"speakerYouth": "SpeakerYouth",
|
64 |
+
"speakerSheet": "SpeakerSheet",
|
65 |
+
"script": "Script",
|
66 |
+
"version": "Version",
|
67 |
+
"board": "Board",
|
68 |
+
"coding": "Coding",
|
69 |
+
"frequency": "Frequency",
|
70 |
+
"channels": "Channels",
|
71 |
+
"byteFormat": "Byteformat",
|
72 |
+
"delimiter": "Delimiter",
|
73 |
+
"characterSet": "CharacterSet",
|
74 |
+
"ansi_codepage": "Ansi_codepage",
|
75 |
+
"dos_codepage": "Dos_codepage",
|
76 |
+
"normalizedText": "normalizedText",
|
77 |
+
"text": "text",
|
78 |
+
"file": "file",
|
79 |
+
|
80 |
+
}
|
81 |
+
|
82 |
+
|
83 |
+
class NST_hesitateConfig(datasets.BuilderConfig):
|
84 |
+
"""BuilderConfig for NST_hesitate."""
|
85 |
+
|
86 |
+
def __init__(self, *args, **kwargs):
|
87 |
+
"""BuilderConfig for NST_hesitate.
|
88 |
+
Args:
|
89 |
+
**kwargs: keyword arguments forwarded to super.
|
90 |
+
"""
|
91 |
+
super(NST_hesitateConfig, self).__init__(*args, **kwargs)
|
92 |
+
|
93 |
+
|
94 |
+
class NST_hesitate(datasets.GeneratorBasedBuilder):
|
95 |
+
"""NST_hesitate dataset."""
|
96 |
+
|
97 |
+
DEFAULT_WRITER_BATCH_SIZE = 1000
|
98 |
+
BUILDER_CONFIGS = [
|
99 |
+
NST_hesitateConfig(
|
100 |
+
name="no",
|
101 |
+
version=datasets.Version("1.0.1"),
|
102 |
+
description="NST_hesitate Norwegian",
|
103 |
+
),
|
104 |
+
|
105 |
+
]
|
106 |
+
|
107 |
+
def _info(self):
|
108 |
+
sampling_rate = 16000
|
109 |
+
return datasets.DatasetInfo(
|
110 |
+
description=_DESCRIPTION,
|
111 |
+
features=datasets.Features({
|
112 |
+
"id": datasets.Value("string"),
|
113 |
+
"audio": datasets.features.Audio(sampling_rate=sampling_rate),
|
114 |
+
"speakerId": datasets.Value("string"),
|
115 |
+
"speakerName": datasets.Value("string"),
|
116 |
+
"speakerAge": datasets.Value("string"),
|
117 |
+
"sex": datasets.Value("string"),
|
118 |
+
"speakerBirthPlace": datasets.Value("string"),
|
119 |
+
"speakerYouth": datasets.Value("string"),
|
120 |
+
"speakerSheet": datasets.Value("string"),
|
121 |
+
"script": datasets.Value("string"),
|
122 |
+
"version": datasets.Value("string"),
|
123 |
+
"board": datasets.Value("string"),
|
124 |
+
"coding": datasets.Value("string"),
|
125 |
+
"frequency": datasets.Value("string"),
|
126 |
+
"channels": datasets.Value("string"),
|
127 |
+
"byteFormat": datasets.Value("string"),
|
128 |
+
"delimiter": datasets.Value("string"),
|
129 |
+
"characterSet": datasets.Value("string"),
|
130 |
+
"ansi_codepage": datasets.Value("string"),
|
131 |
+
"dos_codepage": datasets.Value("string"),
|
132 |
+
"normalizedText": datasets.Value("string"),
|
133 |
+
"text": datasets.Value("string"),
|
134 |
+
"file": datasets.Value("string"),
|
135 |
+
|
136 |
+
}),
|
137 |
+
supervised_keys=None,
|
138 |
+
homepage=_HOMEPAGE,
|
139 |
+
citation=_CITATION,
|
140 |
+
task_templates=[
|
141 |
+
AutomaticSpeechRecognition(
|
142 |
+
audio_column="audio",
|
143 |
+
transcription_column="text"
|
144 |
+
)
|
145 |
+
],
|
146 |
+
)
|
147 |
+
|
148 |
+
def _split_generators(self, dl_manager):
|
149 |
+
"""Returns SplitGenerators."""
|
150 |
+
data_urls = {}
|
151 |
+
|
152 |
+
|
153 |
+
for split in ["train", "test"]:
|
154 |
+
data_urls[split] = []
|
155 |
+
|
156 |
+
shard_total = _SHARDS["no"][split]
|
157 |
+
for shard_idx in range(1, shard_total + 1):
|
158 |
+
|
159 |
+
# .../data/{split}/NST_hesitate_{lang_code}_{split}_{mic}-{shard_idx}-of-{shard_total}
|
160 |
+
string_formatting = dict(
|
161 |
+
split=split,
|
162 |
+
lang_code="no",
|
163 |
+
shard_idx=shard_idx,
|
164 |
+
shard_total=shard_total
|
165 |
+
)
|
166 |
+
data_urls[split] += [(
|
167 |
+
_METADATA_URL.format(**string_formatting),
|
168 |
+
_DATA_URL.format(**string_formatting)
|
169 |
+
)]
|
170 |
+
train_downloaded_data = dl_manager.download(data_urls["train"])
|
171 |
+
test_downloaded_data = dl_manager.download(data_urls["test"])
|
172 |
+
return [
|
173 |
+
datasets.SplitGenerator(
|
174 |
+
name=datasets.Split.TRAIN, gen_kwargs={
|
175 |
+
"filepaths": train_downloaded_data,
|
176 |
+
}
|
177 |
+
),
|
178 |
+
datasets.SplitGenerator(
|
179 |
+
name=datasets.Split.TEST, gen_kwargs={
|
180 |
+
"filepaths": test_downloaded_data,
|
181 |
+
}
|
182 |
+
),
|
183 |
+
]
|
184 |
+
|
185 |
+
def _generate_examples(self, filepaths):
|
186 |
+
"""Yields examples."""
|
187 |
+
lang_code, _ = self.config.name.split("-")
|
188 |
+
data_fields = list(self._info().features.keys())
|
189 |
+
data_fields.remove("id")
|
190 |
+
data_fields.remove("audio")
|
191 |
+
for metadata_path, archive_path in filepaths:
|
192 |
+
metadata = {}
|
193 |
+
with open(metadata_path) as metadata_file:
|
194 |
+
for line in metadata_file.read().split("\n"):
|
195 |
+
if line:
|
196 |
+
metadata_object = json.loads(line)
|
197 |
+
metadata_key = f'{metadata_object["id"]}_{metadata_object["file"].replace(".wav", "")}'
|
198 |
+
metadata[metadata_key] = metadata_object
|
199 |
+
with open(archive_path, "rb") as archive_fs:
|
200 |
+
archive_bytes = io.BytesIO(archive_fs.read())
|
201 |
+
with tarfile.open(fileobj=archive_bytes, mode="r") as tar:
|
202 |
+
for audio_file in tar.getmembers():
|
203 |
+
if audio_file.isfile() and audio_file.name.endswith(".mp3"):
|
204 |
+
metadata_key = f'{audio_file.name.replace(".mp3", "")}'
|
205 |
+
audio_bytes = tar.extractfile(audio_file).read()
|
206 |
+
audio_dict = {"bytes": audio_bytes, "path": audio_file.name}
|
207 |
+
fields = {key: metadata[metadata_key].get(_METADATA_MAPPING[key], "") for key in data_fields}
|
208 |
+
fields["channels"] = 1
|
209 |
+
fields["file"] = fields["file"].replace(".wav", ".mp3")
|
210 |
+
fields["frequency"] = 16000
|
211 |
+
# Fixing some errors in the metadata
|
212 |
+
|
213 |
+
yield metadata_key, {
|
214 |
+
"id": metadata_key,
|
215 |
+
**fields
|
216 |
+
}
|
README.md
ADDED
File without changes
|
data/test/NST_hesitate_no-0001-of-0001.json
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:185c2ca8a3673cf8829aca04963760d7fc83ffcdcebc8cfedc92ecfbe8d4e14f
|
3 |
+
size 49044
|
data/test/NST_hesitate_no-0001-of-0001.tar.gz
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:424d8627410bcc76eb86a78829ea44d316a1e75522bf838f3e38d135e89fc830
|
3 |
+
size 1691924
|
data/train/NST_hesitate_no-0001-of-0001.json
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:dfeb784ceb1bab54f2428d663da71b2957f155342bc6689049ca18c1d071032a
|
3 |
+
size 202345
|
data/train/NST_hesitate_no-0001-of-0001.tar.gz
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:c0b4550b138d69f3723a22e7aab2193fa4071d2cdbadbf0e69db169a869b6408
|
3 |
+
size 7152468
|