-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvoiceMetadata.html
97 lines (92 loc) · 4.14 KB
/
voiceMetadata.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Voice Metadata</title>
<!-- Tabulator CSS -->
<link href="https://unpkg.com/[email protected]/dist/css/tabulator.min.css" rel="stylesheet">
<!-- Font Awesome CSS -->
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.2/css/all.min.css" rel="stylesheet">
<style>
body {
font-family: Arial, sans-serif;
padding: 20px;
}
#voice-table {
margin-top: 20px;
}
.play-button, .stop-button {
cursor: pointer;
font-size: 1.2em;
}
</style>
</head>
<body>
<h1>Voice Metadata</h1>
<div id="voice-table"></div>
<!-- Tabulator JS -->
<script src="https://unpkg.com/[email protected]/dist/js/tabulator.min.js"></script>
<!-- Font Awesome JS -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.2/js/all.min.js"></script>
<script>
let currentAudio = null;
function playAudio(filePath) {
if (currentAudio) {
currentAudio.pause();
currentAudio.currentTime = 0;
console.log('Stopping current audio');
}
console.log('Playing audio File Path:', filePath);
currentAudio = new Audio(filePath);
currentAudio.play();
}
function stopAudio() {
if (currentAudio) {
currentAudio.pause();
currentAudio.currentTime = 0;
console.log('Stopping current audio');
}
}
document.addEventListener('DOMContentLoaded', function () {
fetch('./samples/voiceMetaData.json')
.then(response => response.json())
.then(data => {
const tableData = data.voices;
new Tabulator('#voice-table', {
data: tableData,
layout: 'fitColumns',
columns: [
{ title: 'Voice Code', field: 'voicecode', width: 250, headerFilter:"input", bottomCalc:"count"},
{ title: 'Voice Name', field: 'voicename', width: 150, headerFilter:"input" },
{ title: 'Gender', field: 'voicegender', width: 150, headerFilter:"input" },
{ title: 'Locale Code', field: 'localeCode', width: 150, headerFilter:"input" },
{ title: 'Country Name', field: 'localeCountryName', width: 200, headerFilter:"input" },
{ title: 'Regions', field: 'regions', width: 200, formatter: "array", headerFilter:"input" },
{
title: 'Play',
formatter: function(cell, formatterParams) {
return '<i class="fas fa-play play-button"></i> <i class="fas fa-stop stop-button"></i>';
},
width: 100,
align: 'center',
cellClick: function(e, cell) {
const data = cell.getRow().getData();
const audioPath = `./samples/microsoft/${data.localeCode}/${data.voicecode}.mp3`;
if (e.target.parentElement.classList.contains('play-button')) {
playAudio(audioPath);
} else if (e.target.parentElement.classList.contains('stop-button')) {
stopAudio();
}
}
}
],
autoColumns: false,
height: "600px",
});
})
.catch(error => console.error('Error fetching voice metadata:', error));
});
</script>
</body>
</html>