-
-
Notifications
You must be signed in to change notification settings - Fork 99
/
tts.html
94 lines (90 loc) · 2.95 KB
/
tts.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Speech Synthesis Languages</title>
<style>
body {
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
background-color: #333;
color: #ddd;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
margin: 0;
padding: 20px;
}
.container {
text-align: center;
max-width: 800px;
}
#languageSelect, table {
margin-top: 20px;
padding: 10px;
font-size: 16px;
background-color: #555;
color: #fff;
border: none;
border-radius: 5px;
}
table {
border-collapse: collapse;
width: 100%;
}
th, td {
border: 1px solid #777;
padding: 8px;
text-align: left;
}
th {
background-color: #444;
}
tr:nth-child(even) {
background-color: #555;
}
</style>
</head>
<body>
<div class="container">
<h1>Available TTS Language Options</h1>
<select style="display:none;" id="languageSelect"></select>
<table id="voicesTable">
<tr>
<th>Name</th>
<th>Language</th>
<th>Local Service</th>
<th>Default</th>
</tr>
<!-- Rows will be populated here -->
</table>
<button id="asdf" onclick="populateVoices();">load list</button>
</div>
<script>
document.addEventListener('DOMContentLoaded', () => {
const select = document.getElementById('languageSelect');
const table = document.getElementById('voicesTable');
speechSynthesis.onvoiceschanged = populateVoices;
});
function populateVoices() {
const select = document.getElementById('languageSelect');
select.innerHTML = "";
const table = document.getElementById('voicesTable');
table.innerHTML = "<tr><th>Name</th><th>Language</th><th>Local Service</th><th>Default</th></tr>";
const voices = speechSynthesis.getVoices();
voices.forEach(voice => {
if (document.getElementById("asdf")){document.getElementById("asdf").remove();};
const option = document.createElement('option');
option.textContent = `${voice.name} (${voice.lang})`;
select.appendChild(option);
const row = table.insertRow();
row.insertCell().textContent = voice.name;
row.insertCell().textContent = voice.lang;
row.insertCell().textContent = voice.localService ? 'Yes' : 'No';
row.insertCell().textContent = voice.default ? 'Yes' : 'No';
});
}
</script>
</body>
</html>