PyxiLabs commited on
Commit
a2dd6e1
·
verified ·
1 Parent(s): e4db6ad

Upload templates_index.html

Browse files
Files changed (1) hide show
  1. templates_index.html +466 -0
templates_index.html ADDED
@@ -0,0 +1,466 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>PyxiLabs._.Vocify - Text to Speech API</title>
7
+ <link href="https://cdnjs.cloudflare.com/ajax/libs/tailwindcss/2.2.19/tailwind.min.css" rel="stylesheet">
8
+ <!-- Favicon -->
9
+ <link rel="icon" href="/static/icon.png" type="image/png">
10
+ <link rel="icon" href="/static/icon.png" sizes="32x32" type="image/png">
11
+ <link rel="icon" href="/static/icon.png" sizes="16x16" type="image/png">
12
+ <link rel="apple-touch-icon" href="/static/icon.png">
13
+ <link rel="icon" href="/static/icon.png" sizes="192x192">
14
+ <style>
15
+ :root {
16
+ --gradient-start: #ff0066;
17
+ --gradient-end: #3366ff;
18
+ }
19
+
20
+ body {
21
+ background-image: url('static/bg3.png');
22
+ background-size: cover;
23
+ background-position: center;
24
+ background-attachment: fixed;
25
+ min-height: 100vh;
26
+ }
27
+
28
+ .gradient-text {
29
+ background: linear-gradient(45deg, var(--gradient-start), var(--gradient-end));
30
+ -webkit-background-clip: text;
31
+ background-clip: text;
32
+ color: transparent;
33
+ text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
34
+ }
35
+
36
+ .custom-shadow {
37
+ box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
38
+ }
39
+
40
+ .content-box {
41
+ background: rgba(0, 0, 0, 0.15);
42
+ backdrop-filter: blur(8px);
43
+ border: 1px solid rgba(255, 255, 255, 0.1);
44
+ }
45
+
46
+ .hover-scale {
47
+ transition: transform 0.2s;
48
+ }
49
+
50
+ .hover-scale:hover {
51
+ transform: scale(1.02);
52
+ }
53
+
54
+ .glass-effect {
55
+ background: rgba(0, 0, 0, 0.1);
56
+ backdrop-filter: blur(8px);
57
+ border: 1px solid rgba(255, 255, 255, 0.1);
58
+ }
59
+
60
+ .input-dark {
61
+ background: rgba(0, 0, 0, 0.1);
62
+ border: 1px solid rgba(255, 255, 255, 0.2);
63
+ color: #fff;
64
+ backdrop-filter: blur(4px);
65
+ }
66
+
67
+ .input-dark::placeholder {
68
+ color: rgba(255, 255, 255, 0.6);
69
+ }
70
+
71
+ .input-dark:focus {
72
+ border-color: var(--gradient-start);
73
+ box-shadow: 0 0 0 2px rgba(255, 0, 102, 0.2);
74
+ background: rgba(0, 0, 0, 0.15);
75
+ }
76
+
77
+ .gradient-btn {
78
+ background: linear-gradient(45deg, var(--gradient-start), var(--gradient-end));
79
+ backdrop-filter: blur(4px);
80
+ transition: all 0.3s ease;
81
+ }
82
+
83
+ .gradient-btn:hover {
84
+ filter: brightness(1.1);
85
+ transform: translateY(-2px);
86
+ background: linear-gradient(45deg, var(--gradient-end), var(--gradient-start));
87
+ }
88
+
89
+ select option {
90
+ background-color: rgba(0, 0, 0, 0.8);
91
+ color: white;
92
+ }
93
+
94
+ audio::-webkit-media-controls-panel {
95
+ background: rgba(0, 0, 0, 0.2);
96
+ backdrop-filter: blur(4px);
97
+ }
98
+
99
+ audio::-webkit-media-controls-current-time-display,
100
+ audio::-webkit-media-controls-time-remaining-display {
101
+ color: white;
102
+ }
103
+
104
+ .text-shadow {
105
+ text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
106
+ }
107
+
108
+ pre {
109
+ background: rgba(0, 0, 0, 0.1) !important;
110
+ backdrop-filter: blur(4px);
111
+ white-space: pre-wrap;
112
+ word-wrap: break-word;
113
+ }
114
+
115
+ .white-text {
116
+ color: rgba(255, 255, 255, 0.9);
117
+ }
118
+
119
+ /* Enhanced Loading Bar */
120
+ .loading-bar-container {
121
+ height: 12px;
122
+ background-color: rgba(255, 255, 255, 0.1);
123
+ border-radius: 10px;
124
+ overflow: hidden;
125
+ margin-top: 1rem;
126
+ position: relative;
127
+ box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
128
+ }
129
+
130
+ .loading-bar {
131
+ height: 100%;
132
+ background: linear-gradient(90deg, #ff0066, #3366ff);
133
+ width: 0%;
134
+ border-radius: 10px;
135
+ transition: width 0.5s ease-in-out;
136
+ position: relative;
137
+ overflow: hidden;
138
+ }
139
+
140
+ .loading-bar::after {
141
+ content: '';
142
+ position: absolute;
143
+ top: 0;
144
+ left: -100%;
145
+ width: 100%;
146
+ height: 100%;
147
+ background: linear-gradient(90deg, rgba(255, 255, 255, 0.2), rgba(255, 255, 255, 0.4), rgba(255, 255, 255, 0.2));
148
+ animation: shimmer 2s infinite;
149
+ }
150
+
151
+ @keyframes shimmer {
152
+ 0% {
153
+ left: -100%;
154
+ }
155
+ 100% {
156
+ left: 100%;
157
+ }
158
+ }
159
+
160
+ .loading-bar-text {
161
+ position: absolute;
162
+ top: 50%;
163
+ left: 50%;
164
+ transform: translate(-50%, -50%);
165
+ color: white;
166
+ font-size: 0.9rem;
167
+ font-weight: bold;
168
+ text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
169
+ background: rgba(0, 0, 0, 0.5);
170
+ padding: 2px 8px;
171
+ border-radius: 12px;
172
+ backdrop-filter: blur(4px);
173
+ }
174
+ </style>
175
+ </head>
176
+ <body class="text-white text-shadow">
177
+ <div class="container mx-auto px-4 py-8 md:py-12 max-w-6xl relative">
178
+ <!-- Header -->
179
+ <header class="text-center mb-8 md:mb-12">
180
+ <div class="glass-effect inline-block px-6 md:px-10 py-4 md:py-6 rounded-3xl mb-6 md:mb-8">
181
+ <h1 class="text-3xl md:text-5xl lg:text-7xl font-bold gradient-text mb-3 md:mb-4 tracking-tight">PyxiLabs._.Vocify</h1>
182
+ <p class="white-text text-lg md:text-xl lg:text-2xl max-w-2xl mx-auto">Transform your text into natural speech with our powerful API</p>
183
+ </div>
184
+ </header>
185
+
186
+ <!-- Main Content -->
187
+ <div class="max-w-3xl mx-auto content-box rounded-3xl custom-shadow p-4 md:p-8 lg:p-10 hover-scale">
188
+ <!-- Model Selection -->
189
+ <div class="mb-6 md:mb-8">
190
+ <label class="block white-text text-base md:text-lg font-medium mb-2 md:mb-3" for="model">
191
+ Select Model
192
+ </label>
193
+ <div class="relative">
194
+ <select id="model" class="w-full px-4 md:px-5 py-3 md:py-4 rounded-xl input-dark focus:outline-none focus:ring-2 focus:ring-red-400 appearance-none text-base md:text-lg">
195
+ </select>
196
+ <div class="pointer-events-none absolute inset-y-0 right-0 flex items-center px-3 md:px-4 text-white">
197
+ <svg class="fill-current h-4 w-4 md:h-5 md:w-5" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20">
198
+ <path d="M9.293 12.95l.707.707L15.657 8l-1.414-1.414L10 10.828 5.757 6.586 4.343 8z"/>
199
+ </svg>
200
+ </div>
201
+ </div>
202
+ </div>
203
+
204
+ <!-- Voice Selection -->
205
+ <div class="mb-6 md:mb-8">
206
+ <label class="block white-text text-base md:text-lg font-medium mb-2 md:mb-3" for="voice">
207
+ Select Voice
208
+ </label>
209
+ <div class="relative">
210
+ <select id="voice" class="w-full px-4 md:px-5 py-3 md:py-4 rounded-xl input-dark focus:outline-none focus:ring-2 focus:ring-red-400 appearance-none text-base md:text-lg">
211
+ </select>
212
+ <div class="pointer-events-none absolute inset-y-0 right-0 flex items-center px-3 md:px-4 text-white">
213
+ <svg class="fill-current h-4 w-4 md:h-5 md:w-5" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20">
214
+ <path d="M9.293 12.95l.707.707L15.657 8l-1.414-1.414L10 10.828 5.757 6.586 4.343 8z"/>
215
+ </svg>
216
+ </div>
217
+ </div>
218
+ </div>
219
+
220
+ <!-- Text Input -->
221
+ <div class="mb-6 md:mb-8">
222
+ <label class="block white-text text-base md:text-lg font-medium mb-2 md:mb-3" for="text">
223
+ Enter Text
224
+ </label>
225
+ <textarea
226
+ id="text"
227
+ rows="4"
228
+ maxlength="5000"
229
+ class="w-full px-4 md:px-5 py-3 md:py-4 rounded-xl input-dark focus:outline-none focus:ring-2 focus:ring-red-400 resize-none text-base md:text-lg"
230
+ placeholder="Enter your text here (max 5000 characters)..."
231
+ ></textarea>
232
+ <p id="char-count" class="text-sm md:text-base white-text mt-2 text-right">0/5000 characters</p>
233
+ </div>
234
+
235
+ <!-- Generate Button -->
236
+ <button
237
+ id="generate"
238
+ class="w-full gradient-btn text-white font-bold py-4 md:py-5 px-6 md:px-8 rounded-xl text-base md:text-lg shadow-lg"
239
+ >
240
+ Generate Speech
241
+ </button>
242
+
243
+ <!-- Loading Bar -->
244
+ <div id="loading-bar-container" class="hidden relative mt-6">
245
+ <div class="loading-bar-container">
246
+ <div id="loading-bar" class="loading-bar"></div>
247
+ </div>
248
+ <div id="loading-bar-text" class="loading-bar-text">0%</div>
249
+ </div>
250
+
251
+ <!-- Audio Player -->
252
+ <div id="audio-container" class="mt-6 md:mt-8 hidden">
253
+ <div class="glass-effect p-4 md:p-6 rounded-xl">
254
+ <audio id="audio-player" controls class="w-full">
255
+ Your browser does not support the audio element.
256
+ </audio>
257
+ </div>
258
+ </div>
259
+
260
+ <!-- Loading Spinner -->
261
+ <div id="loading" class="hidden mt-6 md:mt-8 text-center">
262
+ <div class="inline-block animate-spin rounded-full h-10 w-10 md:h-12 md:w-12 border-4 border-red-500 border-t-transparent"></div>
263
+ </div>
264
+
265
+ <!-- Error Message -->
266
+ <div id="error" class="hidden mt-6 md:mt-8 text-red-400 text-center font-medium glass-effect p-4 md:p-6 rounded-xl">
267
+ </div>
268
+ </div>
269
+
270
+ <!-- API Documentation -->
271
+ <div class="mt-12 md:mt-16 text-center">
272
+ <h2 class="text-2xl md:text-3xl font-bold mb-6 md:mb-8 white-text glass-effect inline-block px-6 md:px-8 py-2 md:py-3 rounded-xl">API Documentation</h2>
273
+ <div class="content-box rounded-xl p-6 md:p-8 custom-shadow inline-block text-left hover-scale max-w-full overflow-x-auto">
274
+ <pre class="p-4 md:p-6 rounded-xl overflow-x-auto text-white"><code class="text-sm md:text-base">POST /v1/audio/speech
275
+ {
276
+ "model": "Pyx r1-voice",
277
+ "input": "Your text here",
278
+ "voice": "selected_voice"
279
+ }
280
+
281
+ Rate Limits (Free Tier):
282
+ - Requests Per Minute (RPM): 10
283
+ - Requests Per Hour (RPH): 100
284
+ - Requests Per Day (RPD): 1,000</code></pre>
285
+ </div>
286
+ </div>
287
+
288
+ <!-- Footer -->
289
+ <footer class="mt-12 md:mt-16 text-center">
290
+ <p class="white-text text-sm md:text-base glass-effect inline-block px-4 md:px-6 py-2 md:py-3 rounded-xl">
291
+ © 2024 PyxiLabs._.Vocify. All rights reserved.
292
+ </p>
293
+ </footer>
294
+ </div>
295
+
296
+ <script>
297
+ const modelSelect = document.getElementById('model');
298
+ const voiceSelect = document.getElementById('voice');
299
+ const textInput = document.getElementById('text');
300
+ const charCount = document.getElementById('char-count');
301
+ const generateBtn = document.getElementById('generate');
302
+ const audioContainer = document.getElementById('audio-container');
303
+ const audioPlayer = document.getElementById('audio-player');
304
+ const loading = document.getElementById('loading');
305
+ const error = document.getElementById('error');
306
+ const loadingBarContainer = document.getElementById('loading-bar-container');
307
+ const loadingBar = document.getElementById('loading-bar');
308
+ const loadingBarText = document.getElementById('loading-bar-text');
309
+
310
+ let modelsData = {};
311
+
312
+ async function fetchModels() {
313
+ try {
314
+ const response = await fetch('/v1/models');
315
+ const data = await response.json();
316
+ modelsData = data.models.reduce((acc, model) => {
317
+ acc[model.id] = model;
318
+ return acc;
319
+ }, {});
320
+
321
+ // Populate model select
322
+ data.models.forEach(model => {
323
+ const option = document.createElement('option');
324
+ option.value = model.id;
325
+ option.textContent = `${model.name} (${model.owner})`;
326
+ modelSelect.appendChild(option);
327
+ });
328
+
329
+ // Initialize voices for first model
330
+ if (data.models.length > 0) {
331
+ updateVoices(data.models[0].id);
332
+ }
333
+ } catch (err) {
334
+ showError('Failed to load models. Please refresh the page.');
335
+ }
336
+ }
337
+
338
+ function updateVoices(modelId) {
339
+ // Clear existing voices
340
+ voiceSelect.innerHTML = '';
341
+
342
+ const model = modelsData[modelId];
343
+ if (model && model.vocals) {
344
+ model.vocals.forEach(voice => {
345
+ const option = document.createElement('option');
346
+ option.value = voice.id;
347
+ option.textContent = voice.id.charAt(0).toUpperCase() + voice.id.slice(1);
348
+ voiceSelect.appendChild(option);
349
+ });
350
+ }
351
+ }
352
+
353
+ modelSelect.addEventListener('change', (e) => {
354
+ updateVoices(e.target.value);
355
+ });
356
+
357
+ textInput.addEventListener('input', () => {
358
+ const length = textInput.value.length;
359
+ charCount.textContent = `${length}/5000 characters`;
360
+
361
+ if (length > 4900) {
362
+ charCount.classList.add('text-red-400');
363
+ charCount.classList.remove('white-text');
364
+ } else {
365
+ charCount.classList.remove('text-red-400');
366
+ charCount.classList.add('white-text');
367
+ }
368
+ });
369
+
370
+ generateBtn.addEventListener('click', async () => {
371
+ const text = textInput.value.trim();
372
+ const model = modelSelect.value;
373
+ const voice = voiceSelect.value;
374
+
375
+ if (!text) {
376
+ showError('Please enter some text to convert to speech');
377
+ return;
378
+ }
379
+
380
+ showLoading();
381
+ hideError();
382
+
383
+ let progress = 0;
384
+ loadingBar.style.width = `${progress}%`;
385
+ loadingBarText.textContent = `${progress}%`;
386
+
387
+ const intervalId = setInterval(() => {
388
+ progress += 10;
389
+ if (progress > 95) progress = 95; // Keep it below 100 until success
390
+ loadingBar.style.width = `${progress}%`;
391
+ loadingBarText.textContent = `${progress}%`;
392
+ }, 300);
393
+
394
+ try {
395
+ const response = await fetch('/v1/audio/speech', {
396
+ method: 'POST',
397
+ headers: {
398
+ 'Content-Type': 'application/json',
399
+ },
400
+ body: JSON.stringify({
401
+ model: model,
402
+ input: text,
403
+ voice: voice
404
+ })
405
+ });
406
+
407
+ clearInterval(intervalId);
408
+
409
+ if (!response.ok) {
410
+ loadingBar.style.width = `100%`;
411
+ loadingBarText.textContent = `Failed`;
412
+ throw new Error('Failed to generate speech. Please try again.');
413
+ }
414
+
415
+ const audioBlob = await response.blob();
416
+ const audioUrl = URL.createObjectURL(audioBlob);
417
+
418
+ loadingBar.style.width = `100%`;
419
+ loadingBarText.textContent = `100%`;
420
+ audioPlayer.src = audioUrl;
421
+ showAudioPlayer();
422
+ audioPlayer.play();
423
+ } catch (err) {
424
+ showError(err.message);
425
+ } finally {
426
+ if (error.classList.contains('hidden')) {
427
+ setTimeout(hideLoading, 500); // Keep the 100% for a bit if successful
428
+ } else {
429
+ hideLoading(); // Hide immediately if there's an error
430
+ }
431
+ }
432
+ });
433
+
434
+ function showLoading() {
435
+ loadingBarContainer.classList.remove('hidden');
436
+ loading.classList.remove('hidden');
437
+ generateBtn.disabled = true;
438
+ generateBtn.classList.add('opacity-50');
439
+ }
440
+
441
+ function hideLoading() {
442
+ loadingBarContainer.classList.add('hidden');
443
+ loading.classList.add('hidden');
444
+ generateBtn.disabled = false;
445
+ generateBtn.classList.remove('opacity-50');
446
+ }
447
+
448
+ function showError(message) {
449
+ error.textContent = message;
450
+ error.classList.remove('hidden');
451
+ error.scrollIntoView({ behavior: 'smooth', block: 'center' });
452
+ }
453
+
454
+ function hideError() {
455
+ error.classList.add('hidden');
456
+ }
457
+
458
+ function showAudioPlayer() {
459
+ audioContainer.classList.remove('hidden');
460
+ }
461
+
462
+ // Initialize the application
463
+ fetchModels();
464
+ </script>
465
+ </body>
466
+ </html>