Newer
Older
# SPDX-License-Identifier: CECILL-2.1
#######################################################################
const TIMIT_SUBSETS = Dict(
"train" => "train",
"dev" => "dev",
"test" => "test"
)
const TIMIT_DEV_SPK_LIST = Set([
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
"fdac1",
"fjem0",
"mgwt0",
"mjar0",
"mmdb1",
"mmdm2",
"mpdf0",
"fcmh0",
"fkms0",
"mbdg0",
"mbwm0",
"mcsh0",
"fadg0",
"fdms0",
"fedw0",
"mgjf0",
"mglb0",
"mrtk0",
"mtaa0",
"mtdt0",
"mthc0",
"mwjg0",
"fnmr0",
"frew0",
"fsem0",
"mbns0",
"mmjr0",
"mdls0",
"mdlf0",
"mdvc0",
"mers0",
"fmah0",
"fdrw0",
"mrcs0",
"mrjm4",
"fcal1",
"mmwh0",
"fjsj0",
"majc0",
"mjsw0",
"mreb0",
"fgjd0",
"fjmg0",
"mroa0",
"mteb0",
"mjfc0",
"mrjr0",
"fmml0",
"mrws1"
])
const TIMIT_TEST_SPK_LIST = Set([
"mdab0",
"mwbt0",
"felc0",
"mtas1",
"mwew0",
"fpas0",
"mjmp0",
"mlnt0",
"fpkt0",
"mlll0",
"mtls0",
"fjlm0",
"mbpm0",
"mklt0",
"fnlp0",
"mcmj0",
"mjdh0",
"fmgd0",
"mgrt0",
"mnjm0",
"fdhc0",
"mjln0",
"mpam0",
"fmld0"
])
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
TIMIT_PHONE_MAP48 = Dict(
"aa" => "aa",
"ae" => "ae",
"ah" => "ah",
"ao" => "ao",
"aw" => "aw",
"ax" => "ax",
"ax-h" => "ax",
"axr" => "er",
"ay" => "ay",
"b" => "b",
"bcl" => "vcl",
"ch" => "ch",
"d" => "d",
"dcl" => "vcl",
"dh" => "dh",
"dx" => "dx",
"eh" => "eh",
"el" => "el",
"em" => "m",
"en" => "en",
"eng" => "ng",
"epi" => "epi",
"er" => "er",
"ey" => "ey",
"f" => "f",
"g" => "g",
"gcl" => "vcl",
"h#" => "sil",
"hh" => "hh",
"hv" => "hh",
"ih" => "ih",
"ix" => "ix",
"iy" => "iy",
"jh" => "jh",
"k" => "k",
"kcl" => "cl",
"l" => "l",
"m" => "m",
"n" => "n",
"ng" => "ng",
"nx" => "n",
"ow" => "ow",
"oy" => "oy",
"p" => "p",
"pau" => "sil",
"pcl" => "cl",
"q" => "",
"r" => "r",
"s" => "s",
"sh" => "sh",
"t" => "t",
"tcl" => "cl",
"th" => "th",
"uh" => "uh",
"uw" => "uw",
"ux" => "uw",
"v" => "v",
"w" => "w",
"y" => "y",
"z" => "z",
"zh" => "zh"
)
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
TIMIT_PHONE_MAP39 = Dict(
"aa" => "aa",
"ae" => "ae",
"ah" => "ah",
"ao" => "aa",
"aw" => "aw",
"ax" => "ah",
"ax-h" => "ah",
"axr" => "er",
"ay" => "ay",
"b" => "b",
"bcl" => "sil",
"ch" => "ch",
"d" => "d",
"dcl" => "sil",
"dh" => "dh",
"dx" => "dx",
"eh" => "eh",
"el" => "l",
"em" => "m",
"en" => "n",
"eng" => "ng",
"epi" => "sil",
"er" => "er",
"ey" => "ey",
"f" => "f",
"g" => "g",
"gcl" => "sil",
"h#" => "sil",
"hh" => "hh",
"hv" => "hh",
"ih" => "ih",
"ix" => "ih",
"iy" => "iy",
"jh" => "jh",
"k" => "k",
"kcl" => "sil",
"l" => "l",
"m" => "m",
"n" => "n",
"ng" => "ng",
"nx" => "n",
"ow" => "ow",
"oy" => "oy",
"p" => "p",
"pau" => "sil",
"pcl" => "sil",
"q" => "",
"r" => "r",
"s" => "s",
"sh" => "sh",
"t" => "t",
"tcl" => "sil",
"th" => "th",
"uh" => "uh",
"uw" => "uw",
"ux" => "uw",
"v" => "v",
"w" => "w",
"y" => "y",
"z" => "z",
"zh" => "sh"
)
#######################################################################
function timit_prepare(timitdir, dir; audio_fmt="SPHERE")
! isdir(timitdir) && throw(ArgumentError("invalid path $(timitdir)"))
# Create the output directory.
dir = mkpath(dir)
for (subset, subdir) in [("train", "train"), ("dev", "train"), ("test", "test")]
manifestpath = joinpath(dir, "recordings.jsonl")
@debug "preparing $manifestpath"
recordings = timit_recordings(sdir; fmt=audio_fmt)
open(manifestpath, "w") do f
writemanifest(f, recordings)
end
# Supervision
manifestpath = joinpath(dir, "supervisions-$(subset).jsonl")
@debug "Preparing $manifestpath"
supervisions = timit_supervisions(sdir)
open(manifestpath, "w") do f
writemanifest(f, supervisions)
end
end
end
function timit_recordings(dir::AbstractString; fmt="SPHERE")
! isdir(dir) && throw(ArgumentError("expected directory $dir"))
recordings = Dict()
for (root, subdirs, files) in walkdir(dir)
spk = basename(root)
path = joinpath(root, file)
id = "timit_$(spk)_$(name)"
CmdAudioSource(`sph2pipe -f wav $path`)
else
FileAudioSource(path)
end
recordings[id] = Recording(
id,
audio_src;
channels = [1],
samplerate = 16000
)
function timit_supervisions(dir)
! isdir(dir) && throw(ArgumentError("expected directory $dir"))
splitline(line) = rsplit(line, limit=3)
supervisions = Dict()
for (root, subdirs, files) in walkdir(dir)
for file in files
name, ext = splitext(file)
ext != ".wrd" && continue
_, dialect, spk = rsplit(root, "/", limit=3)
path = joinpath(root, file)
id = "timit_$(spk)_$(name)"
slines = map(splitline, eachline(path))
starts, ends, words = zip(slines...)
start_ts = parse(Int, first(starts)) / 16000
end_ts = parse(Int, last(ends)) / 16000
dur = end_ts - start_ts
Dict(
"text" => join(words, " "),
"dialect" => dialect,
"speaker" => spk,
"sex" => string(first(spk))
)
)
function TIMIT(timitdir, dir, subset)
if ! (isfile(joinpath(dir, "recordings.jsonl")) &&
isfile(joinpath(dir, "supervisions-train.jsonl")) &&
isfile(joinpath(dir, "supervisions-dev.jsonl")) &&
isfile(joinpath(dir, "supervisions-test.jsonl")))
timit_prepare(timitdir, dir)