-
Notifications
You must be signed in to change notification settings - Fork 3
/
index.html
350 lines (307 loc) · 11.5 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
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
159
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
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8"><title>Piper Voice Samples</title>
<style type="text/css">
body {
margin: auto;
max-width: 90%;
}
#modelCard {
font-family: monospace;
width: 100%;
}
#key {
font-weight: bold;
margin-left: 10px;
}
#languages {
margin-bottom: 15px;
}
#logo {
margin-left: -30px;
height: 6em;
}
#sponsored {
position: absolute;
right: 75px;
top: 20px;
}
</style>
</head>
<body>
<a href="https://github.com/rhasspy/piper" title="Piper TTS">
<img id="logo" src="img/logo.png" alt="Piper logo">
</a>
<a href="https://nabucasa.com" title="Sponsored by Nabu Casa">
<img id="sponsored" src="img/nabu_casa_sponsored.png" alt="Sponsored by Nabu Casa">
</a>
<p>
Below are samples for <a href="https://github.com/rhasspy/piper" title="Piper TTS">Piper</a>, a fast and local text to speech system.
Samples were generated from the first paragraph of the Wikipedia entry for <a href="https://en.wikipedia.org/wiki/Rainbow">rainbow</a>.
</p>
<select id="languages" onchange="setLanguage()">
<option value="">Language</option>
</select>
<select id="voice" onchange="setVoice()">
<option value="">Voice</option>
</select>
<select id="quality" onchange="setQuality()">
<option value="">Quality</option>
</select>
<select id="speaker" onchange="setSpeaker()">
<option value="">Speaker</option>
</select>
<span id="key"></span>
<br />
<div id="info" hidden>
<audio id="audio" controls></audio>
<br />
<a id="download" target="_blank">Download</a>
<br />
<p id="text"></p>
<textarea id="modelCard" readonly rows=15></textarea>
</div>
<h2>Quality</h2>
Voices are trained at one of 4 "quality" levels:
<ul>
<li>
<b>x_low</b> - 16Khz audio, 5-7M params
</li>
<li>
<b>low</b> - 16Khz audio, 15-20M params
</li>
<li>
<b>medium</b> - 22.05Khz audio, 15-20M params
</li>
<li>
<b>high</b> - 22.05Khz audio, 28-32M params
</li>
</ul>
<h2>Multi-Speaker</h2>
Some voices contain multiple speakers, which captures the style of multiple people within a single model.
<br />
Multi-speaker models can quickly switch between different speakers, but the quality of an individual speaker may be less than a single speaker model.
<script type="text/javascript">
var voices = {};
const qualitySort = {
"x_low": 0,
"low": 1,
"medium": 2,
"high": 3,
};
var languageToSelect = null;
var voiceToSelect = null;
var qualityToSelect = null;
function q(selector) {return document.querySelector(selector)}
function setAudio(name) {
var audio = q("#audio-" + name);
var speaker = q("#speaker-" + name);
audio.src = "samples/" + name + "/" + speaker.value + "/sample.mp3";
}
function setLanguage() {
var language = q("#languages").value;
if (language.length > 0) {
var voiceSelect = q("#voice");
while (voiceSelect.options.length > 1) {
voiceSelect.remove(voiceSelect.options.length - 1);
}
let names = [];
for (key in voices) {
let voice = voices[key];
if (voice.language.code == language) {
names.push(voice.name);
}
}
names = Array.from(new Set(names)).sort();
for (i in names) {
let name = names[i];
let option = document.createElement("option");
option.text = name;
option.value = name;
voiceSelect.add(option);
}
if (voiceToSelect) {
voiceSelect.value = voiceToSelect;
voiceToSelect = null;
setVoice();
} else if (voiceSelect.options.length > 1) {
// Select first voice
voiceSelect.selectedIndex = 1;
setVoice();
}
}
}
function setVoice() {
var language = q("#languages").value;
var voiceName = q("#voice").value;
if (voiceName.length > 0) {
var qualitySelect = q("#quality");
while (qualitySelect.options.length > 1) {
qualitySelect.remove(qualitySelect.options.length - 1);
}
let qualities = [];
for (key in voices) {
let voice = voices[key];
if ((voice.language.code == language) && (voice.name == voiceName)) {
qualities.push(voice.quality);
}
}
qualities = Array.from(new Set(qualities)).sort((a, b) => qualitySort[a] - qualitySort[b]);
for (i in qualities) {
let quality = qualities[i];
let option = document.createElement("option");
option.text = quality;
option.value = quality;
qualitySelect.add(option);
}
if (qualityToSelect) {
qualitySelect.value = qualityToSelect;
qualityToSelect = null;
setQuality();
} else if (qualitySelect.options.length > 1) {
// Select highest quality
qualitySelect.selectedIndex = qualitySelect.options.length - 1;
setQuality();
}
}
}
function setQuality() {
var language = q("#languages").value;
var voiceName = q("#voice").value;
var quality = q("#quality").value;
if (quality.length > 0) {
var speakerSelect = q("#speaker");
while (speakerSelect.options.length > 1) {
speakerSelect.remove(speakerSelect.options.length - 1);
}
var numSpeakers = 1;
var speakerIdMap = {};
for (key in voices) {
let voice = voices[key];
if ((voice.language.code == language)
&& (voice.name == voiceName)
&& (voice.quality == quality)) {
numSpeakers = voice.num_speakers;
speakerIdMap = voice.speaker_id_map;
break;
}
}
if (numSpeakers <= 1) {
// Single speaker model
let option = document.createElement("option");
option.text = "default";
option.value = "0";
speakerSelect.add(option);
} else {
// Multi-speaker model
let sortedSpeakers = Object.keys(speakerIdMap).sort((a, b) => speakerIdMap[a] - speakerIdMap[b]);
for (i in sortedSpeakers) {
let speaker = sortedSpeakers[i];
let option = document.createElement("option");
option.text = speaker + " (" + i.toString() + ")";
option.value = i.toString();
speakerSelect.add(option);
}
}
if (speakerSelect.options.length > 1) {
// Select first speaker
speakerSelect.selectedIndex = 1;
setSpeaker();
}
}
}
function setSpeaker() {
var language = q("#languages").value;
let languageFamily = language.split("_")[0];
var voiceName = q("#voice").value;
var quality = q("#quality").value;
var speaker = q("#speaker").value;
var audio = q("#audio");
if (speaker.length > 0) {
for (key in voices) {
let voice = voices[key];
if ((voice.language.code == language)
&& (voice.name == voiceName)
&& (voice.quality == quality)) {
q("#key").innerHTML = key;
q("#download").href = "https://huggingface.co/rhasspy/piper-voices/tree/main/"
+ languageFamily
+ "/"
+ language
+ "/"
+ voiceName
+ "/"
+ quality
+ "/";
q("#info").hidden = false;
let sampleDir = "samples/"
+ languageFamily
+ "/"
+ language
+ "/"
+ voiceName
+ "/"
+ quality;
audio.src = sampleDir
+"/speaker_"
+ speaker
+ ".mp3";
fetch(sampleDir + "/sample.txt")
.then(response => response.text())
.then(text => {
q("#text").innerHTML = text;
});
fetch(sampleDir + "/MODEL_CARD")
.then(response => response.text())
.then(text => {
q("#modelCard").innerHTML = text;
});
break;
}
}
}
}
window.onload = function(e) {
let hash = window.location.hash;
if (hash.length > 0) {
let voiceIdRegexp = RegExp("^#([^-]+)-([^-]+)-([^-]+)$");
let match = voiceIdRegexp.exec(hash);
if (match) {
languageToSelect = match[1];
voiceToSelect = match[2];
qualityToSelect = match[3];
}
}
fetch("voices.json")
.then(response => response.json())
.then(response_obj => {
voices = response_obj;
let voiceLanguages = [];
let languageNames = {};
for (key in voices) {
let voice = voices[key];
voiceLanguages.push(voice.language.code);
languageNames[voice.language.code] = voice.language.name_native
+ " (" + voice.language.name_english + ", "
+ voice.language.country_english + ")";
}
let sortedLanguages = Array.from(new Set(voiceLanguages)).sort();
let languagesSelect = q("#languages");
for (i in sortedLanguages) {
let language = sortedLanguages[i];
let option = document.createElement("option");
option.text = languageNames[language];
option.value = language;
languagesSelect.add(option);
}
if (languageToSelect) {
languagesSelect.value = languageToSelect;
languageToSelect = null;
setLanguage();
}
});
}
</script>
</body>
</html>