ssasio commited on
Commit
a45eeac
·
verified ·
1 Parent(s): 47d7807

Delete edge-tts-api-test.html

Browse files
Files changed (1) hide show
  1. edge-tts-api-test.html +0 -258
edge-tts-api-test.html DELETED
@@ -1,258 +0,0 @@
1
- <!doctype html>
2
- <html lang="bg">
3
- <head>
4
- <meta charset="utf-8" />
5
- <meta name="viewport" content="width=device-width, initial-scale=1" />
6
- <title>Edge TTS API Test</title>
7
- <style>
8
- :root {
9
- --bg: #0f1115;
10
- --panel: #171a21;
11
- --panel-2: #1f2430;
12
- --text: #eef2ff;
13
- --muted: #aab4d6;
14
- --accent: #ff4fa3;
15
- --accent-2: #ff7abd;
16
- --border: #2e3443;
17
- --ok: #42d392;
18
- --err: #ff6b6b;
19
- }
20
- * { box-sizing: border-box; }
21
- body {
22
- margin: 0;
23
- font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
24
- background: linear-gradient(180deg, #0d1016, #131722);
25
- color: var(--text);
26
- min-height: 100vh;
27
- }
28
- .wrap {
29
- max-width: 920px;
30
- margin: 0 auto;
31
- padding: 24px;
32
- }
33
- .card {
34
- background: rgba(23, 26, 33, 0.95);
35
- border: 1px solid var(--border);
36
- border-radius: 18px;
37
- padding: 20px;
38
- box-shadow: 0 10px 30px rgba(0,0,0,.25);
39
- }
40
- h1 { margin: 0 0 8px; font-size: 30px; }
41
- p { color: var(--muted); }
42
- .grid {
43
- display: grid;
44
- grid-template-columns: 1fr 1fr;
45
- gap: 16px;
46
- }
47
- .full { grid-column: 1 / -1; }
48
- label {
49
- display: block;
50
- margin: 0 0 8px;
51
- font-size: 14px;
52
- color: var(--muted);
53
- }
54
- input, textarea, select {
55
- width: 100%;
56
- border: 1px solid var(--border);
57
- background: var(--panel-2);
58
- color: var(--text);
59
- border-radius: 12px;
60
- padding: 12px 14px;
61
- font-size: 15px;
62
- }
63
- textarea { min-height: 150px; resize: vertical; }
64
- .row {
65
- display: flex;
66
- gap: 12px;
67
- flex-wrap: wrap;
68
- margin-top: 18px;
69
- }
70
- button {
71
- border: 0;
72
- border-radius: 12px;
73
- padding: 12px 16px;
74
- font-size: 15px;
75
- cursor: pointer;
76
- color: white;
77
- background: linear-gradient(135deg, var(--accent), var(--accent-2));
78
- }
79
- button.secondary {
80
- background: #2b3242;
81
- }
82
- button:disabled { opacity: .6; cursor: wait; }
83
- .status {
84
- margin-top: 14px;
85
- padding: 12px 14px;
86
- border-radius: 12px;
87
- background: #161b25;
88
- border: 1px solid var(--border);
89
- color: var(--muted);
90
- white-space: pre-wrap;
91
- word-break: break-word;
92
- }
93
- .ok { color: var(--ok); }
94
- .err { color: var(--err); }
95
- audio {
96
- width: 100%;
97
- margin-top: 18px;
98
- }
99
- .small { font-size: 13px; color: var(--muted); }
100
- @media (max-width: 760px) {
101
- .grid { grid-template-columns: 1fr; }
102
- }
103
- </style>
104
- </head>
105
- <body>
106
- <div class="wrap">
107
- <div class="card">
108
- <h1>Edge TTS API Test</h1>
109
- <p>HTML тест страница за твоя Hugging Face Space endpoint.</p>
110
-
111
- <div class="grid">
112
- <div class="full">
113
- <label for="baseUrl">API Base URL</label>
114
- <input id="baseUrl" value="https://ssasio-edge-tts-api-1.hf.space" />
115
- </div>
116
-
117
- <div>
118
- <label for="voice">Voice</label>
119
- <input id="voice" value="bg-BG-BorislavNeural" />
120
- </div>
121
-
122
- <div>
123
- <label for="rate">Rate</label>
124
- <input id="rate" value="+0%" />
125
- </div>
126
-
127
- <div>
128
- <label for="volume">Volume</label>
129
- <input id="volume" value="+0%" />
130
- </div>
131
-
132
- <div>
133
- <label for="pitch">Pitch</label>
134
- <input id="pitch" value="+0Hz" />
135
- </div>
136
-
137
- <div class="full">
138
- <label for="text">Text</label>
139
- <textarea id="text">Здравей, това е тест на Edge TTS API от HTML файл.</textarea>
140
- </div>
141
- </div>
142
-
143
- <div class="row">
144
- <button id="healthBtn" type="button">Health</button>
145
- <button id="voicesBtn" type="button" class="secondary">Voices</button>
146
- <button id="ttsBtn" type="button">Generate MP3</button>
147
- <button id="downloadBtn" type="button" class="secondary" disabled>Download MP3</button>
148
- </div>
149
-
150
- <div id="status" class="status">Готово за тест.</div>
151
- <audio id="player" controls></audio>
152
- <div class="small">Ако браузърът блокира заявката, трябва да се добави CORS в FastAPI backend-а.</div>
153
- </div>
154
- </div>
155
-
156
- <script>
157
- const baseUrlEl = document.getElementById('baseUrl');
158
- const voiceEl = document.getElementById('voice');
159
- const rateEl = document.getElementById('rate');
160
- const volumeEl = document.getElementById('volume');
161
- const pitchEl = document.getElementById('pitch');
162
- const textEl = document.getElementById('text');
163
- const statusEl = document.getElementById('status');
164
- const playerEl = document.getElementById('player');
165
- const downloadBtn = document.getElementById('downloadBtn');
166
- const healthBtn = document.getElementById('healthBtn');
167
- const voicesBtn = document.getElementById('voicesBtn');
168
- const ttsBtn = document.getElementById('ttsBtn');
169
-
170
- let currentBlobUrl = null;
171
-
172
- function setStatus(message, type = '') {
173
- statusEl.className = 'status ' + type;
174
- statusEl.textContent = message;
175
- }
176
-
177
- function getBaseUrl() {
178
- return baseUrlEl.value.trim().replace(/\/$/, '');
179
- }
180
-
181
- async function checkHealth() {
182
- setStatus('Проверка на /health ...');
183
- try {
184
- const res = await fetch(getBaseUrl() + '/health');
185
- const txt = await res.text();
186
- setStatus('Health OK:\n' + txt, 'ok');
187
- } catch (e) {
188
- setStatus('Health error: ' + e.message, 'err');
189
- }
190
- }
191
-
192
- async function getVoices() {
193
- setStatus('Зареждане на /voices ...');
194
- try {
195
- const res = await fetch(getBaseUrl() + '/voices');
196
- const data = await res.json();
197
- const short = Array.isArray(data) ? data.slice(0, 20).map(v => v.ShortName).join('\n') : JSON.stringify(data, null, 2);
198
- setStatus('Първи гласове:\n' + short, 'ok');
199
- } catch (e) {
200
- setStatus('Voices error: ' + e.message, 'err');
201
- }
202
- }
203
-
204
- async function generateTts() {
205
- const payload = {
206
- text: textEl.value,
207
- voice: voiceEl.value,
208
- rate: rateEl.value,
209
- volume: volumeEl.value,
210
- pitch: pitchEl.value
211
- };
212
-
213
- ttsBtn.disabled = true;
214
- downloadBtn.disabled = true;
215
- setStatus('Генериране на MP3 ...');
216
-
217
- try {
218
- const res = await fetch(getBaseUrl() + '/tts', {
219
- method: 'POST',
220
- headers: { 'Content-Type': 'application/json' },
221
- body: JSON.stringify(payload)
222
- });
223
-
224
- if (!res.ok) {
225
- const errText = await res.text();
226
- throw new Error('HTTP ' + res.status + ' - ' + errText);
227
- }
228
-
229
- const blob = await res.blob();
230
- if (currentBlobUrl) URL.revokeObjectURL(currentBlobUrl);
231
- currentBlobUrl = URL.createObjectURL(blob);
232
- playerEl.src = currentBlobUrl;
233
- downloadBtn.disabled = false;
234
- setStatus('MP3 е готов. Можеш да го пуснеш от player-а или да го свалиш.', 'ok');
235
- } catch (e) {
236
- setStatus('TTS error: ' + e.message, 'err');
237
- } finally {
238
- ttsBtn.disabled = false;
239
- }
240
- }
241
-
242
- function downloadMp3() {
243
- if (!currentBlobUrl) return;
244
- const a = document.createElement('a');
245
- a.href = currentBlobUrl;
246
- a.download = 'speech.mp3';
247
- document.body.appendChild(a);
248
- a.click();
249
- a.remove();
250
- }
251
-
252
- healthBtn.addEventListener('click', checkHealth);
253
- voicesBtn.addEventListener('click', getVoices);
254
- ttsBtn.addEventListener('click', generateTts);
255
- downloadBtn.addEventListener('click', downloadMp3);
256
- </script>
257
- </body>
258
- </html>