forked from make-an-audio-2/make-an-audio-2.github.io
-
Notifications
You must be signed in to change notification settings - Fork 0
/
helper.js
75 lines (60 loc) · 2.4 KB
/
helper.js
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
function createAudioHTML(path) {
return '<audio controls controlslist="nodownload" class="px-1"> <source src=' +
path +
' type="audio/wav">Your browser does not support the audio element.</audio>';
}
function generateExampleRow(table_row, base_path, filename_ext, col_offset) {
for (var i = 0; i < filename_ext.length; i++) {
let p = base_path + filename_ext[i];
let cell = table_row.cells[col_offset + i];
if (p.endsWith('txt')) {
var req = new XMLHttpRequest();
req.open("GET", p, false);
req.send(null);
cell.innerHTML = '<font size="-1">' + req.responseText + '</font>';
} else {
cell.innerHTML = cell.innerHTML + createAudioHTML(p);
}
}
}
function generateT2A(tableId) {
let table = document.getElementById(tableId);
let ext = ['.txt', '_gt.wav', '_maa2.wav', '_maa1.wav','_ldm.wav', '_tango.wav'];
for (var i = 0; i < 10; i++) {
generateExampleRow(table.rows[1 + i], 'data/t2a/' + i, ext, 0);
}
}
function generateVariable(tableId) {
let table = document.getElementById(tableId);
let ext = ['.txt', '_maa2.wav', '_maa1.wav','_ldm.wav', '_tango.wav'];
for (var i = 0; i < 9; i++) {
generateExampleRow(table.rows[1 + i], 'data/variable_length/' + i, ext, 0);
}
}
function generatePrompting(tableId) {
let table = document.getElementById(tableId);
console.log("got table ", table);
let ext = ['_prompt.wav', '_0.wav', '_1.wav', '_2.wav', '_3.wav'];
let examples = [
[
'201a21a19122da31975501c183a447db_1089_0',
'201a21a19122da31975501c183a447db_1089_2',
'201a21a19122da31975501c183a447db_2094_0',
'201a21a19122da31975501c183a447db_2094_2',
],
[
'1ebe5c38eabb74ee9fc562f3f716dc8c_1089_0',
'1ebe5c38eabb74ee9fc562f3f716dc8c_1089_2',
'1ebe5c38eabb74ee9fc562f3f716dc8c_2094_0',
'1ebe5c38eabb74ee9fc562f3f716dc8c_2094_2',
]
];
for (var i = 0; i < examples[0].length; i++) {
generateExampleRow(table.rows[2 + i], 'data/prompting/' + examples[0][i], ext, 0)
}
for (var i = 0; i < examples[1].length; i++) {
generateExampleRow(table.rows[7 + i], 'data/prompting/' + examples[1][i], ext, 0)
}
}
generateT2A('supervision-efficiency-table');
generateVariable('speech-diversity');