gigant commited on
Commit
879f7b8
1 Parent(s): 48288d1

Upload m-ailabs_speech_dataset_fr.py

Browse files
Files changed (1) hide show
  1. m-ailabs_speech_dataset_fr.py +91 -0
m-ailabs_speech_dataset_fr.py ADDED
@@ -0,0 +1,91 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ # This script for Hugging Face's datasets library was written by Théo Gigant
3
+
4
+
5
+ import csv
6
+ import json
7
+ import os
8
+ import wave
9
+
10
+ import datasets
11
+
12
+ _CITATION = """\
13
+
14
+ """
15
+
16
+ _DESCRIPTION = """\
17
+ The M-AILABS Speech Dataset is the first large dataset that we are providing free-of-charge, freely usable as training data for speech recognition and speech synthesis.
18
+
19
+ Most of the data is based on LibriVox and Project Gutenberg. The training data consist of nearly thousand hours of audio and the text-files in prepared format.
20
+
21
+ A transcription is provided for each clip. Clips vary in length from 1 to 20 seconds and have a total length of approximately shown in the list (and in the respective info.txt-files) below.
22
+
23
+
24
+ The texts were published between 1884 and 1964, and are in the public domain. The audio was recorded by the LibriVox project and is also in the public domain – except for Ukrainian.
25
+
26
+ Ukrainian audio was kindly provided either by Nash Format or Gwara Media for machine learning purposes only (please check the data info.txt files for details).
27
+ """
28
+
29
+ _HOMEPAGE = "https://www.caito.de/2019/01/the-m-ailabs-speech-dataset/"
30
+
31
+ _LICENSE = ""
32
+
33
+ _URLS = {
34
+ "fr": "https://data.solak.de/data/Training/stt_tts/fr_FR.tgz",
35
+ }
36
+
37
+ class MAILABSSpeechDataset(datasets.GeneratorBasedBuilder):
38
+
39
+ VERSION = datasets.Version("0.9.0")
40
+
41
+ BUILDER_CONFIGS = [
42
+ datasets.BuilderConfig(name="fr", version=VERSION, description=""),
43
+ ]
44
+
45
+ DEFAULT_CONFIG_NAME = "fr"
46
+
47
+ def _info(self):
48
+ features = datasets.Features(
49
+ {
50
+ "sentence": datasets.Value("string"),
51
+ "audio": datasets.features.Audio(sampling_rate=16_000),
52
+ }
53
+ )
54
+ return datasets.DatasetInfo(
55
+ description=_DESCRIPTION,
56
+ features=features,
57
+ homepage=_HOMEPAGE,
58
+ license=_LICENSE,
59
+ citation=_CITATION,
60
+ )
61
+
62
+ def _split_generators(self, dl_manager):
63
+ urls = _URLS[self.config.name]
64
+ data_dir = dl_manager.download_and_extract(urls)
65
+ return [
66
+ datasets.SplitGenerator(
67
+ name=datasets.Split.TRAIN,
68
+ gen_kwargs={
69
+ "datapath": data_dir
70
+ },
71
+ ),
72
+ ]
73
+
74
+ def _generate_examples(self, datapath):
75
+ key = 0
76
+ try :
77
+ for gender in ["male", "female", "mix"]:
78
+ for name in os.listdir(os.path.join(datapath, "fr_FR", gender)):
79
+ for book in os.listdir(os.path.join(datapath, "fr_FR", gender, name)):
80
+ with open(os.path.join(datapath, "fr_FR", gender, name, book, "metadata.csv"), encoding="utf-8") as meta:
81
+ for line in meta.readlines():
82
+ line = line.split("|")
83
+ filename = f"{line[0]}.wav"
84
+ local_path = os.path.join("fr_FR", gender, name, book, "wavs", filename)
85
+ yield key, {
86
+ "sentence": line[1],
87
+ "audio": os.path.join(datapath, local_path)
88
+ }
89
+ key += 1
90
+ except:
91
+ pass