Abhisksks commited on
Commit
a9674c6
·
verified ·
1 Parent(s): ff16eb0

Create templates/index.html

Browse files
Files changed (1) hide show
  1. templates/index.html +196 -0
templates/index.html ADDED
@@ -0,0 +1,196 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ <!DOCTYPE html>
3
+ <html lang="en">
4
+ <head>
5
+ <meta charset="UTF-8">
6
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
7
+ <style>
8
+ body {
9
+ background-color: white; /* Ensure the iframe has a white background */
10
+ }
11
+
12
+
13
+ </style>
14
+ </head>
15
+ <body>
16
+ <!DOCTYPE html>
17
+ <html lang="en">
18
+ <head>
19
+ <meta charset="UTF-8">
20
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
21
+ <title>Edge TTS Generator</title>
22
+ <style>
23
+ body {
24
+ font-family: Arial, sans-serif;
25
+ margin: 20px;
26
+ padding: 20px;
27
+ background-color: #f4f4f9;
28
+ }
29
+ h1 {
30
+ text-align: center;
31
+ }
32
+ .container {
33
+ max-width: 800px;
34
+ margin: 0 auto;
35
+ background: white;
36
+ padding: 20px;
37
+ border-radius: 8px;
38
+ box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
39
+ }
40
+ label {
41
+ display: block;
42
+ margin-bottom: 5px;
43
+ font-weight: bold;
44
+ }
45
+ select, textarea, input[type="text"] {
46
+ width: 100%;
47
+ padding: 10px;
48
+ margin-bottom: 15px;
49
+ border: 1px solid #ccc;
50
+ border-radius: 4px;
51
+ }
52
+ button {
53
+ display: block;
54
+ width: 100%;
55
+ padding: 10px;
56
+ background-color: #007bff;
57
+ color: white;
58
+ border: none;
59
+ border-radius: 4px;
60
+ cursor: pointer;
61
+ }
62
+ button:hover {
63
+ background-color: #0056b3;
64
+ }
65
+ .audio-output {
66
+ margin-top: 20px;
67
+ text-align: center;
68
+ }
69
+ .audio-output audio {
70
+ width: 100%;
71
+ }
72
+ </style>
73
+ </head>
74
+ <body>
75
+ <h1>Edge TTS Generator</h1>
76
+ <div class="container">
77
+ <form id="ttsForm">
78
+ <label for="language">Select Language:</label>
79
+ <select id="language" name="language" required>
80
+ <option value="" disabled selected>Select a language</option>
81
+ {% for lang, voice_list in voices.items() %}
82
+ <option value="{{ lang }}">{{ lang }}</option>
83
+ {% endfor %}
84
+ </select>
85
+
86
+ <label for="voice">Select Voice:</label>
87
+ <select id="voice" name="voice" required>
88
+ <option value="" disabled selected>Select a voice</option>
89
+ </select>
90
+
91
+ <label for="style">Select Style:</label>
92
+ <select id="style" name="style">
93
+ <option value="default">Default</option>
94
+ </select>
95
+
96
+ <label for="rate">Rate (%):</label>
97
+ <input type="text" id="rate" name="rate" value="0">
98
+
99
+ <label for="volume">Volume (%):</label>
100
+ <input type="text" id="volume" name="volume" value="0">
101
+
102
+ <label for="pitch">Pitch (Hz):</label>
103
+ <input type="text" id="pitch" name="pitch" value="0">
104
+
105
+ <label for="text">Enter Text:</label>
106
+ <textarea id="text" name="text" rows="5" required></textarea>
107
+
108
+ <button type="submit">Generate Audio</button>
109
+ </form>
110
+
111
+ <div class="audio-output" id="audioOutput">
112
+ <audio controls id="audioPlayer"></audio>
113
+ <a id="downloadLink" style="display: none;">Download Audio</a>
114
+ </div>
115
+ </div>
116
+
117
+ <script>
118
+ document.getElementById('language').addEventListener('change', function () {
119
+ const language = this.value;
120
+ const voiceDropdown = document.getElementById('voice');
121
+ voiceDropdown.innerHTML = '<option value="" disabled selected>Select a voice</option>';
122
+ if (!language) return;
123
+
124
+ fetch(`/get_voice_info?language=${language}`)
125
+ .then(response => response.json())
126
+ .then(data => {
127
+ for (const [voiceName, voiceData] of Object.entries(data)) {
128
+ const option = document.createElement('option');
129
+ option.value = voiceName;
130
+ option.textContent = voiceName;
131
+ voiceDropdown.appendChild(option);
132
+ }
133
+ });
134
+ });
135
+
136
+ document.getElementById('voice').addEventListener('change', function () {
137
+ const language = document.getElementById('language').value;
138
+ const voice = this.value;
139
+ const styleDropdown = document.getElementById('style');
140
+ styleDropdown.innerHTML = '<option value="default">Default</option>';
141
+ if (!language || !voice) return;
142
+
143
+ fetch(`/get_voice_info?language=${language}&voice_id=${voice}`)
144
+ .then(response => response.json())
145
+ .then(data => {
146
+ if (data.styles && data.styles.length > 1) {
147
+ data.styles.forEach(style => {
148
+ if (style !== 'default') {
149
+ const option = document.createElement('option');
150
+ option.value = style;
151
+ option.textContent = style.charAt(0).toUpperCase() + style.slice(1);
152
+ styleDropdown.appendChild(option);
153
+ }
154
+ });
155
+ }
156
+ });
157
+ });
158
+
159
+ document.getElementById('ttsForm').addEventListener('submit', async function (event) {
160
+ event.preventDefault();
161
+ const formData = new FormData(this);
162
+
163
+ const response = await fetch('/generate_audio', {
164
+ method: 'POST',
165
+ body: formData,
166
+ });
167
+
168
+ const result = await response.json();
169
+
170
+ if (result.success) {
171
+ const audioPlayer = document.getElementById('audioPlayer');
172
+ const downloadLink = document.getElementById('downloadLink');
173
+
174
+ audioPlayer.src = result.audio_path;
175
+ audioPlayer.load();
176
+ audioPlayer.play();
177
+
178
+ downloadLink.href = `/download_audio/${result.filename}`;
179
+ downloadLink.textContent = `Download ${result.filename}`;
180
+ downloadLink.style.display = 'block';
181
+ } else {
182
+ alert(`Error: ${result.error}`);
183
+ }
184
+ });
185
+ </script>
186
+ </body>
187
+ </html>
188
+
189
+
190
+
191
+ <script>
192
+
193
+ </script>
194
+ </body>
195
+ </html>
196
+