Datasets:
Upload folder using huggingface_hub
Browse files- README.md +71 -3
- metadata/asr_calls_v2/train.tsv +0 -0
- metadata/asr_calls_v2/validate.tsv +0 -0
- metadata/buriy_audio_books_2/train.tsv +0 -0
- metadata/buriy_audio_books_2/validate.tsv +0 -0
- metadata/public_youtube700/train.tsv +0 -0
- metadata/public_youtube700/validate.tsv +0 -0
- n_shards.json +14 -0
- open_stt.py +189 -0
README.md
CHANGED
@@ -1,3 +1,71 @@
|
|
1 |
-
---
|
2 |
-
|
3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
language:
|
3 |
+
- ru
|
4 |
+
|
5 |
+
license: cc-by-nc-4.0
|
6 |
+
task_categories:
|
7 |
+
- automatic-speech-recognition
|
8 |
+
size_categories:
|
9 |
+
- 10K<n<100K
|
10 |
+
tags:
|
11 |
+
- audio
|
12 |
+
- speech
|
13 |
+
- Russian
|
14 |
+
- ASR
|
15 |
+
- voice
|
16 |
+
|
17 |
+
dataset_info:
|
18 |
+
features:
|
19 |
+
- dtype: string
|
20 |
+
name: id
|
21 |
+
- dtype: string
|
22 |
+
name: path
|
23 |
+
- dtype: string
|
24 |
+
name: text
|
25 |
+
- dtype: float32
|
26 |
+
name: duration
|
27 |
+
- dtype: audio
|
28 |
+
name: audio
|
29 |
+
|
30 |
+
config_name: asr_calls_v2, buriy_audio_books_2, public_youtube700
|
31 |
+
splits:
|
32 |
+
- name: train
|
33 |
+
- name: validate
|
34 |
+
|
35 |
+
pretty_name: open_stt
|
36 |
+
---
|
37 |
+
|
38 |
+
# open_stt Dataset
|
39 |
+
|
40 |
+
## Dataset Description
|
41 |
+
|
42 |
+
open_stt is a Russian dataset for speech research.
|
43 |
+
|
44 |
+
## Dataset Structure
|
45 |
+
|
46 |
+
This dataset is organized as follows:
|
47 |
+
|
48 |
+
|
49 |
+
### asr_calls_v2 subset
|
50 |
+
|
51 |
+
| Split | Samples |
|
52 |
+
|-------|--------|
|
53 |
+
| train | 7770 |
|
54 |
+
| validate | 5180 |
|
55 |
+
| **Total** | **12950** |
|
56 |
+
|
57 |
+
### buriy_audio_books_2 subset
|
58 |
+
|
59 |
+
| Split | Samples |
|
60 |
+
|-------|--------|
|
61 |
+
| train | 4710 |
|
62 |
+
| validate | 3140 |
|
63 |
+
| **Total** | **7850** |
|
64 |
+
|
65 |
+
### public_youtube700 subset
|
66 |
+
|
67 |
+
| Split | Samples |
|
68 |
+
|-------|--------|
|
69 |
+
| train | 4386 |
|
70 |
+
| validate | 2925 |
|
71 |
+
| **Total** | **7311** |
|
metadata/asr_calls_v2/train.tsv
ADDED
The diff for this file is too large to render.
See raw diff
|
|
metadata/asr_calls_v2/validate.tsv
ADDED
The diff for this file is too large to render.
See raw diff
|
|
metadata/buriy_audio_books_2/train.tsv
ADDED
The diff for this file is too large to render.
See raw diff
|
|
metadata/buriy_audio_books_2/validate.tsv
ADDED
The diff for this file is too large to render.
See raw diff
|
|
metadata/public_youtube700/train.tsv
ADDED
The diff for this file is too large to render.
See raw diff
|
|
metadata/public_youtube700/validate.tsv
ADDED
The diff for this file is too large to render.
See raw diff
|
|
n_shards.json
ADDED
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"asr_calls_v2": {
|
3 |
+
"train": 1,
|
4 |
+
"validate": 1
|
5 |
+
},
|
6 |
+
"buriy_audio_books_2": {
|
7 |
+
"train": 1,
|
8 |
+
"validate": 1
|
9 |
+
},
|
10 |
+
"public_youtube700": {
|
11 |
+
"train": 1,
|
12 |
+
"validate": 1
|
13 |
+
}
|
14 |
+
}
|
open_stt.py
ADDED
@@ -0,0 +1,189 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# coding=utf-8
|
2 |
+
# Copyright 2023 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 |
+
"""Open STT Dataset"""
|
16 |
+
|
17 |
+
import csv
|
18 |
+
import os
|
19 |
+
import json
|
20 |
+
|
21 |
+
import datasets
|
22 |
+
from tqdm import tqdm
|
23 |
+
|
24 |
+
|
25 |
+
_DESCRIPTION = """open_stt is a Russian dataset for speech research."""
|
26 |
+
|
27 |
+
_CITATION = """None"""
|
28 |
+
|
29 |
+
_HOMEPAGE = "https://github.com/snakers4/open_stt"
|
30 |
+
_LICENSE = "CC-BY-NC. Commercial usage available after agreement with dataset authors"
|
31 |
+
|
32 |
+
_BASE_URL = "https://huggingface.co/datasets/Sh1man/silero_open_stt/resolve/main/"
|
33 |
+
_AUDIO_URL = _BASE_URL + "data/{subset}/{split}/{subset}_{split}_{shard_idx}.tar"
|
34 |
+
_METADATA_URL = _BASE_URL + "metadata/{subset}/{split}.tsv"
|
35 |
+
_N_SHARDS_URL = _BASE_URL + "n_shards.json"
|
36 |
+
|
37 |
+
# Информация о поднаборах
|
38 |
+
SUBSETS = {
|
39 |
+
"asr_calls_v2": {
|
40 |
+
"description": "Телефонные звонки на русском языке",
|
41 |
+
},
|
42 |
+
"buriy_audio_books_2": {
|
43 |
+
"description": "Аудиокниги на русском языке",
|
44 |
+
},
|
45 |
+
"public_youtube700": {
|
46 |
+
"description": "YouTube-видео с русской речью",
|
47 |
+
},
|
48 |
+
}
|
49 |
+
|
50 |
+
|
51 |
+
class OpenSttConfig(datasets.BuilderConfig):
|
52 |
+
"""BuilderConfig для OpenStt."""
|
53 |
+
|
54 |
+
def __init__(self, name, subset, description, **kwargs):
|
55 |
+
"""BuilderConfig для OpenStt.
|
56 |
+
|
57 |
+
Args:
|
58 |
+
name: Название набора данных
|
59 |
+
subset: Поднабор данных
|
60 |
+
description: Описание поднабора
|
61 |
+
**kwargs: Дополнительные аргументы для суперкласса
|
62 |
+
"""
|
63 |
+
self.subset = subset
|
64 |
+
super(OpenSttConfig, self).__init__(
|
65 |
+
name=name,
|
66 |
+
version=datasets.Version("1.0.0"),
|
67 |
+
description=description,
|
68 |
+
**kwargs,
|
69 |
+
)
|
70 |
+
|
71 |
+
|
72 |
+
class OpenStt(datasets.GeneratorBasedBuilder):
|
73 |
+
"""Аудио-датасет Open STT."""
|
74 |
+
|
75 |
+
VERSION = datasets.Version("1.0.0")
|
76 |
+
DEFAULT_WRITER_BATCH_SIZE = 1000
|
77 |
+
|
78 |
+
BUILDER_CONFIGS = [
|
79 |
+
OpenSttConfig(
|
80 |
+
name=subset,
|
81 |
+
subset=subset,
|
82 |
+
description=f"Open STT - {info['description']}",
|
83 |
+
)
|
84 |
+
for subset, info in SUBSETS.items()
|
85 |
+
]
|
86 |
+
|
87 |
+
def _info(self):
|
88 |
+
features = datasets.Features(
|
89 |
+
{
|
90 |
+
"id": datasets.Value("string"),
|
91 |
+
"path": datasets.Value("string"),
|
92 |
+
"text": datasets.Value("string"),
|
93 |
+
"duration": datasets.Value("float32"),
|
94 |
+
"audio": datasets.Audio(sampling_rate=16000),
|
95 |
+
}
|
96 |
+
)
|
97 |
+
|
98 |
+
return datasets.DatasetInfo(
|
99 |
+
description=_DESCRIPTION,
|
100 |
+
features=features,
|
101 |
+
supervised_keys=None,
|
102 |
+
homepage=_HOMEPAGE,
|
103 |
+
license=_LICENSE,
|
104 |
+
citation=_CITATION
|
105 |
+
)
|
106 |
+
|
107 |
+
def _split_generators(self, dl_manager):
|
108 |
+
"""Returns SplitGenerators."""
|
109 |
+
subset = self.config.subset
|
110 |
+
|
111 |
+
# Загружаем информацию о количестве шардов
|
112 |
+
n_shards_path = dl_manager.download_and_extract(_N_SHARDS_URL)
|
113 |
+
with open(n_shards_path, encoding="utf-8") as f:
|
114 |
+
n_shards = json.load(f)
|
115 |
+
|
116 |
+
# Проверяем наличие данных для выбранного поднабора
|
117 |
+
if subset not in n_shards:
|
118 |
+
raise ValueError(f"Subset {subset} not found in n_shards.json")
|
119 |
+
|
120 |
+
# Определяем доступные сплиты для этого поднабора
|
121 |
+
splits = list(n_shards[subset].keys())
|
122 |
+
if not splits:
|
123 |
+
raise ValueError(f"No splits found for subset {subset}")
|
124 |
+
|
125 |
+
# Создаем URLs для аудио файлов
|
126 |
+
audio_urls = {}
|
127 |
+
for split in splits:
|
128 |
+
if n_shards[subset][split] > 0:
|
129 |
+
audio_urls[split] = [
|
130 |
+
_AUDIO_URL.format(subset=subset, split=split, shard_idx=i)
|
131 |
+
for i in range(n_shards[subset][split])
|
132 |
+
]
|
133 |
+
|
134 |
+
# Скачиваем ар��ивы
|
135 |
+
archive_paths = dl_manager.download(audio_urls)
|
136 |
+
local_extracted_archive_paths = dl_manager.extract(archive_paths) if not dl_manager.is_streaming else {}
|
137 |
+
|
138 |
+
# Скачиваем метаданные
|
139 |
+
meta_urls = {split: _METADATA_URL.format(subset=subset, split=split) for split in splits}
|
140 |
+
meta_paths = dl_manager.download_and_extract(meta_urls)
|
141 |
+
|
142 |
+
# Определяем генераторы сплитов
|
143 |
+
split_generators = []
|
144 |
+
split_names = {
|
145 |
+
"train": datasets.Split.TRAIN,
|
146 |
+
"validate": datasets.Split.VALIDATION,
|
147 |
+
"test": datasets.Split.TEST,
|
148 |
+
}
|
149 |
+
|
150 |
+
for split in splits:
|
151 |
+
split_generators.append(
|
152 |
+
datasets.SplitGenerator(
|
153 |
+
name=split_names.get(split, split),
|
154 |
+
gen_kwargs={
|
155 |
+
"local_extracted_archive_paths": local_extracted_archive_paths.get(split),
|
156 |
+
"archives": [dl_manager.iter_archive(path) for path in archive_paths[split]],
|
157 |
+
"meta_path": meta_paths[split],
|
158 |
+
},
|
159 |
+
),
|
160 |
+
)
|
161 |
+
|
162 |
+
return split_generators
|
163 |
+
|
164 |
+
def _generate_examples(self, local_extracted_archive_paths, archives, meta_path):
|
165 |
+
"""Yields examples."""
|
166 |
+
data_fields = list(self._info().features.keys())
|
167 |
+
metadata = {}
|
168 |
+
|
169 |
+
with open(meta_path, encoding="utf-8") as f:
|
170 |
+
reader = csv.DictReader(f, delimiter="\t", quoting=csv.QUOTE_NONE)
|
171 |
+
for row in tqdm(reader, desc="Reading metadata..."):
|
172 |
+
# Проверяем наличие всех полей
|
173 |
+
for field in data_fields:
|
174 |
+
if field not in row and field != "audio":
|
175 |
+
row[field] = ""
|
176 |
+
|
177 |
+
metadata[row["path"]] = row
|
178 |
+
|
179 |
+
for i, audio_archive in enumerate(archives):
|
180 |
+
for path, file in audio_archive:
|
181 |
+
_, filename = os.path.split(path)
|
182 |
+
if filename in metadata:
|
183 |
+
result = dict(metadata[filename])
|
184 |
+
# set the audio feature and the path to the extracted file
|
185 |
+
path = os.path.join(local_extracted_archive_paths[i], path) if local_extracted_archive_paths else path
|
186 |
+
result["audio"] = {"path": path, "bytes": file.read()}
|
187 |
+
result["path"] = path
|
188 |
+
yield path, result
|
189 |
+
|