sanchit-gandhi
commited on
Commit
·
5be9148
1
Parent(s):
7d6b249
convert to parquet
Browse files- README.md +30 -0
- clean/validation-00000-of-00001.parquet +3 -0
- librispeech_asr.py.lock +0 -0
- librispeech_asr_dummy.py +0 -137
- librispeech_asr_dummy.py.lock +0 -0
README.md
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
dataset_info:
|
| 3 |
+
config_name: clean
|
| 4 |
+
features:
|
| 5 |
+
- name: file
|
| 6 |
+
dtype: string
|
| 7 |
+
- name: audio
|
| 8 |
+
dtype:
|
| 9 |
+
audio:
|
| 10 |
+
sampling_rate: 16000
|
| 11 |
+
- name: text
|
| 12 |
+
dtype: string
|
| 13 |
+
- name: speaker_id
|
| 14 |
+
dtype: int64
|
| 15 |
+
- name: chapter_id
|
| 16 |
+
dtype: int64
|
| 17 |
+
- name: id
|
| 18 |
+
dtype: string
|
| 19 |
+
splits:
|
| 20 |
+
- name: validation
|
| 21 |
+
num_bytes: 9677021.0
|
| 22 |
+
num_examples: 73
|
| 23 |
+
download_size: 9192059
|
| 24 |
+
dataset_size: 9677021.0
|
| 25 |
+
configs:
|
| 26 |
+
- config_name: clean
|
| 27 |
+
data_files:
|
| 28 |
+
- split: validation
|
| 29 |
+
path: clean/validation-*
|
| 30 |
+
---
|
clean/validation-00000-of-00001.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:4e69a06fa5edc90921e5e7e39a7084881f8b3ed9c805c574f4f39c6fde27c603
|
| 3 |
+
size 9192059
|
librispeech_asr.py.lock
DELETED
|
File without changes
|
librispeech_asr_dummy.py
DELETED
|
@@ -1,137 +0,0 @@
|
|
| 1 |
-
# coding=utf-8
|
| 2 |
-
# Copyright 2021 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 |
-
"""Librispeech automatic speech recognition dataset."""
|
| 18 |
-
|
| 19 |
-
from __future__ import absolute_import, division, print_function
|
| 20 |
-
|
| 21 |
-
import glob
|
| 22 |
-
import os
|
| 23 |
-
|
| 24 |
-
import datasets
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
_CITATION = """\
|
| 28 |
-
@inproceedings{panayotov2015librispeech,
|
| 29 |
-
title={Librispeech: an ASR corpus based on public domain audio books},
|
| 30 |
-
author={Panayotov, Vassil and Chen, Guoguo and Povey, Daniel and Khudanpur, Sanjeev},
|
| 31 |
-
booktitle={Acoustics, Speech and Signal Processing (ICASSP), 2015 IEEE International Conference on},
|
| 32 |
-
pages={5206--5210},
|
| 33 |
-
year={2015},
|
| 34 |
-
organization={IEEE}
|
| 35 |
-
}
|
| 36 |
-
"""
|
| 37 |
-
|
| 38 |
-
_DESCRIPTION = """\
|
| 39 |
-
LibriSpeech is a corpus of approximately 1000 hours of read English speech with sampling rate of 16 kHz,
|
| 40 |
-
prepared by Vassil Panayotov with the assistance of Daniel Povey. The data is derived from read
|
| 41 |
-
audiobooks from the LibriVox project, and has been carefully segmented and aligned.
|
| 42 |
-
|
| 43 |
-
Note that in order to limit the required storage for preparing this dataset, the audio
|
| 44 |
-
is stored in the .flac format and is not converted to a float32 array. To convert, the audio
|
| 45 |
-
file to a float32 array, please make use of the `.map()` function as follows:
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
```python
|
| 49 |
-
import soundfile as sf
|
| 50 |
-
|
| 51 |
-
def map_to_array(batch):
|
| 52 |
-
speech_array, _ = sf.read(batch["file"])
|
| 53 |
-
batch["speech"] = speech_array
|
| 54 |
-
return batch
|
| 55 |
-
|
| 56 |
-
dataset = dataset.map(map_to_array, remove_columns=["file"])
|
| 57 |
-
```
|
| 58 |
-
"""
|
| 59 |
-
|
| 60 |
-
_URL = "http://www.openslr.org/12"
|
| 61 |
-
_DL_URL = "https://s3.amazonaws.com/datasets.huggingface.co/librispeech_asr/2.1.0/"
|
| 62 |
-
_DL_URL = "https://s3.amazonaws.com/datasets.huggingface.co/librispeech_asr/2.1.0/"
|
| 63 |
-
|
| 64 |
-
_DL_URLS = {
|
| 65 |
-
"clean": {
|
| 66 |
-
"dev": _DL_URL + "dev_clean.tar.gz",
|
| 67 |
-
}
|
| 68 |
-
}
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
class LibrispeechASRConfig(datasets.BuilderConfig):
|
| 72 |
-
"""BuilderConfig for LibriSpeechASR."""
|
| 73 |
-
|
| 74 |
-
def __init__(self, **kwargs):
|
| 75 |
-
"""
|
| 76 |
-
Args:
|
| 77 |
-
data_dir: `string`, the path to the folder containing the files in the
|
| 78 |
-
downloaded .tar
|
| 79 |
-
citation: `string`, citation for the data set
|
| 80 |
-
url: `string`, url for information about the data set
|
| 81 |
-
**kwargs: keyword arguments forwarded to super.
|
| 82 |
-
"""
|
| 83 |
-
super(LibrispeechASRConfig, self).__init__(version=datasets.Version("2.1.0", ""), **kwargs)
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
class LibrispeechASR(datasets.GeneratorBasedBuilder):
|
| 87 |
-
"""Librispeech dataset."""
|
| 88 |
-
|
| 89 |
-
BUILDER_CONFIGS = [
|
| 90 |
-
LibrispeechASRConfig(name="clean", description="'Clean' speech."),
|
| 91 |
-
LibrispeechASRConfig(name="other", description="'Other', more challenging, speech."),
|
| 92 |
-
]
|
| 93 |
-
|
| 94 |
-
def _info(self):
|
| 95 |
-
return datasets.DatasetInfo(
|
| 96 |
-
description=_DESCRIPTION,
|
| 97 |
-
features=datasets.Features(
|
| 98 |
-
{
|
| 99 |
-
"file": datasets.Value("string"),
|
| 100 |
-
"audio": datasets.features.Audio(sampling_rate=16_000),
|
| 101 |
-
"text": datasets.Value("string"),
|
| 102 |
-
"speaker_id": datasets.Value("int64"),
|
| 103 |
-
"chapter_id": datasets.Value("int64"),
|
| 104 |
-
"id": datasets.Value("string"),
|
| 105 |
-
}
|
| 106 |
-
),
|
| 107 |
-
supervised_keys=("speech", "text"),
|
| 108 |
-
homepage=_URL,
|
| 109 |
-
citation=_CITATION,
|
| 110 |
-
)
|
| 111 |
-
|
| 112 |
-
def _split_generators(self, dl_manager):
|
| 113 |
-
archive_path = dl_manager.download_and_extract(_DL_URLS[self.config.name])
|
| 114 |
-
return [
|
| 115 |
-
datasets.SplitGenerator(name=datasets.Split.VALIDATION, gen_kwargs={"archive_path": archive_path["dev"], "split_name": f"dev_{self.config.name}"}),
|
| 116 |
-
]
|
| 117 |
-
|
| 118 |
-
def _generate_examples(self, archive_path, split_name):
|
| 119 |
-
"""Generate examples from a Librispeech archive_path."""
|
| 120 |
-
transcripts_glob = os.path.join(archive_path, split_name, "*/*/*.txt")
|
| 121 |
-
for transcript_file in sorted(glob.glob(transcripts_glob)):
|
| 122 |
-
path = os.path.dirname(transcript_file)
|
| 123 |
-
with open(os.path.join(path, transcript_file)) as f:
|
| 124 |
-
for line in f:
|
| 125 |
-
line = line.strip()
|
| 126 |
-
key, transcript = line.split(" ", 1)
|
| 127 |
-
audio_file = f"{key}.flac"
|
| 128 |
-
speaker_id, chapter_id = [int(el) for el in key.split("-")[:2]]
|
| 129 |
-
example = {
|
| 130 |
-
"id": key,
|
| 131 |
-
"speaker_id": speaker_id,
|
| 132 |
-
"chapter_id": chapter_id,
|
| 133 |
-
"file": os.path.join(path, audio_file),
|
| 134 |
-
"audio": os.path.join(path, audio_file),
|
| 135 |
-
"text": transcript,
|
| 136 |
-
}
|
| 137 |
-
yield key, example
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
librispeech_asr_dummy.py.lock
DELETED
|
File without changes
|