albertvillanova HF staff commited on
Commit
7611c36
1 Parent(s): bd63f52

Delete loading script

Browse files
Files changed (1) hide show
  1. lj_speech.py +0 -116
lj_speech.py DELETED
@@ -1,116 +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
- """LJ automatic speech recognition dataset."""
18
-
19
-
20
- import csv
21
- import os
22
-
23
- import datasets
24
- from datasets.tasks import AutomaticSpeechRecognition
25
-
26
-
27
- _CITATION = """\
28
- @misc{ljspeech17,
29
- author = {Keith Ito and Linda Johnson},
30
- title = {The LJ Speech Dataset},
31
- howpublished = {\\url{https://keithito.com/LJ-Speech-Dataset/}},
32
- year = 2017
33
- }
34
- """
35
-
36
- _DESCRIPTION = """\
37
- This is a public domain speech dataset consisting of 13,100 short audio clips of a single speaker reading
38
- passages from 7 non-fiction books in English. A transcription is provided for each clip. Clips vary in length
39
- from 1 to 10 seconds and have a total length of approximately 24 hours.
40
-
41
- Note that in order to limit the required storage for preparing this dataset, the audio
42
- is stored in the .wav format and is not converted to a float32 array. To convert the audio
43
- file to a float32 array, please make use of the `.map()` function as follows:
44
-
45
-
46
- ```python
47
- import soundfile as sf
48
-
49
- def map_to_array(batch):
50
- speech_array, _ = sf.read(batch["file"])
51
- batch["speech"] = speech_array
52
- return batch
53
-
54
- dataset = dataset.map(map_to_array, remove_columns=["file"])
55
- ```
56
- """
57
-
58
- _URL = "https://keithito.com/LJ-Speech-Dataset/"
59
- _DL_URL = "https://data.keithito.com/data/speech/LJSpeech-1.1.tar.bz2"
60
-
61
-
62
- class LJSpeech(datasets.GeneratorBasedBuilder):
63
- """LJ Speech dataset."""
64
-
65
- VERSION = datasets.Version("1.1.0")
66
-
67
- BUILDER_CONFIGS = [
68
- datasets.BuilderConfig(name="main", version=VERSION, description="The full LJ Speech dataset"),
69
- ]
70
-
71
- def _info(self):
72
- return datasets.DatasetInfo(
73
- description=_DESCRIPTION,
74
- features=datasets.Features(
75
- {
76
- "id": datasets.Value("string"),
77
- "audio": datasets.Audio(sampling_rate=22050),
78
- "file": datasets.Value("string"),
79
- "text": datasets.Value("string"),
80
- "normalized_text": datasets.Value("string"),
81
- }
82
- ),
83
- supervised_keys=("file", "text"),
84
- homepage=_URL,
85
- citation=_CITATION,
86
- task_templates=[AutomaticSpeechRecognition(audio_column="audio", transcription_column="text")],
87
- )
88
-
89
- def _split_generators(self, dl_manager):
90
- root_path = dl_manager.download_and_extract(_DL_URL)
91
- root_path = os.path.join(root_path, "LJSpeech-1.1")
92
- wav_path = os.path.join(root_path, "wavs")
93
- csv_path = os.path.join(root_path, "metadata.csv")
94
-
95
- return [
96
- datasets.SplitGenerator(
97
- name=datasets.Split.TRAIN, gen_kwargs={"wav_path": wav_path, "csv_path": csv_path}
98
- ),
99
- ]
100
-
101
- def _generate_examples(self, wav_path, csv_path):
102
- """Generate examples from an LJ Speech archive_path."""
103
-
104
- with open(csv_path, encoding="utf-8") as csv_file:
105
- csv_reader = csv.reader(csv_file, delimiter="|", quotechar=None, skipinitialspace=True)
106
- for row in csv_reader:
107
- uid, text, norm_text = row
108
- filename = f"{uid}.wav"
109
- example = {
110
- "id": uid,
111
- "file": os.path.join(wav_path, filename),
112
- "audio": os.path.join(wav_path, filename),
113
- "text": text,
114
- "normalized_text": norm_text,
115
- }
116
- yield uid, example