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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
<style>
|
| 9 |
+
:root {
|
| 10 |
+
--gradient-start: #ff0066;
|
| 11 |
+
--gradient-end: #3366ff;
|
| 12 |
+
}
|
| 13 |
+
|
| 14 |
+
body {
|
| 15 |
+
background-image: url('static/background.png');
|
| 16 |
+
background-size: cover;
|
| 17 |
+
background-position: center;
|
| 18 |
+
background-attachment: fixed;
|
| 19 |
+
min-height: 100vh;
|
| 20 |
+
}
|
| 21 |
+
.gradient-text {
|
| 22 |
+
background: linear-gradient(45deg, var(--gradient-start), var(--gradient-end));
|
| 23 |
+
-webkit-background-clip: text;
|
| 24 |
+
background-clip: text;
|
| 25 |
+
color: transparent;
|
| 26 |
+
text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
|
| 27 |
+
}
|
| 28 |
+
.custom-shadow {
|
| 29 |
+
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
|
| 30 |
+
}
|
| 31 |
+
.content-box {
|
| 32 |
+
background: rgba(0, 0, 0, 0.15);
|
| 33 |
+
backdrop-filter: blur(8px);
|
| 34 |
+
border: 1px solid rgba(255, 255, 255, 0.1);
|
| 35 |
+
}
|
| 36 |
+
.hover-scale {
|
| 37 |
+
transition: transform 0.2s;
|
| 38 |
+
}
|
| 39 |
+
.hover-scale:hover {
|
| 40 |
+
transform: scale(1.02);
|
| 41 |
+
}
|
| 42 |
+
.glass-effect {
|
| 43 |
+
background: rgba(0, 0, 0, 0.1);
|
| 44 |
+
backdrop-filter: blur(8px);
|
| 45 |
+
border: 1px solid rgba(255, 255, 255, 0.1);
|
| 46 |
+
}
|
| 47 |
+
.input-dark {
|
| 48 |
+
background: rgba(0, 0, 0, 0.1);
|
| 49 |
+
border: 1px solid rgba(255, 255, 255, 0.2);
|
| 50 |
+
color: #fff;
|
| 51 |
+
backdrop-filter: blur(4px);
|
| 52 |
+
}
|
| 53 |
+
.input-dark::placeholder {
|
| 54 |
+
color: rgba(255, 255, 255, 0.6);
|
| 55 |
+
}
|
| 56 |
+
.input-dark:focus {
|
| 57 |
+
border-color: var(--gradient-start);
|
| 58 |
+
box-shadow: 0 0 0 2px rgba(255, 0, 102, 0.2);
|
| 59 |
+
background: rgba(0, 0, 0, 0.15);
|
| 60 |
+
}
|
| 61 |
+
.gradient-btn {
|
| 62 |
+
background: linear-gradient(45deg, var(--gradient-start), var(--gradient-end));
|
| 63 |
+
backdrop-filter: blur(4px);
|
| 64 |
+
transition: all 0.3s ease;
|
| 65 |
+
}
|
| 66 |
+
.gradient-btn:hover {
|
| 67 |
+
filter: brightness(1.1);
|
| 68 |
+
transform: translateY(-2px);
|
| 69 |
+
background: linear-gradient(45deg, var(--gradient-end), var(--gradient-start));
|
| 70 |
+
}
|
| 71 |
+
select option {
|
| 72 |
+
background-color: rgba(0, 0, 0, 0.8);
|
| 73 |
+
color: white;
|
| 74 |
+
}
|
| 75 |
+
audio::-webkit-media-controls-panel {
|
| 76 |
+
background: rgba(0, 0, 0, 0.2);
|
| 77 |
+
backdrop-filter: blur(4px);
|
| 78 |
+
}
|
| 79 |
+
audio::-webkit-media-controls-current-time-display,
|
| 80 |
+
audio::-webkit-media-controls-time-remaining-display {
|
| 81 |
+
color: white;
|
| 82 |
+
}
|
| 83 |
+
.text-shadow {
|
| 84 |
+
text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
|
| 85 |
+
}
|
| 86 |
+
pre {
|
| 87 |
+
background: rgba(0, 0, 0, 0.1) !important;
|
| 88 |
+
backdrop-filter: blur(4px);
|
| 89 |
+
white-space: pre-wrap;
|
| 90 |
+
word-wrap: break-word;
|
| 91 |
+
}
|
| 92 |
+
.white-text {
|
| 93 |
+
color: rgba(255, 255, 255, 0.9);
|
| 94 |
+
}
|
| 95 |
+
|
| 96 |
+
/* Responsive styles */
|
| 97 |
+
@media (max-width: 768px) {
|
| 98 |
+
.container {
|
| 99 |
+
padding: 1rem;
|
| 100 |
+
}
|
| 101 |
+
|
| 102 |
+
header h1 {
|
| 103 |
+
font-size: 2.5rem !important;
|
| 104 |
+
}
|
| 105 |
+
|
| 106 |
+
header p {
|
| 107 |
+
font-size: 1.1rem !important;
|
| 108 |
+
}
|
| 109 |
+
|
| 110 |
+
.content-box {
|
| 111 |
+
padding: 1.5rem !important;
|
| 112 |
+
}
|
| 113 |
+
|
| 114 |
+
.input-dark, .gradient-btn {
|
| 115 |
+
padding: 0.75rem !important;
|
| 116 |
+
}
|
| 117 |
+
|
| 118 |
+
pre code {
|
| 119 |
+
font-size: 0.8rem !important;
|
| 120 |
+
}
|
| 121 |
+
}
|
| 122 |
+
|
| 123 |
+
@media (max-width: 480px) {
|
| 124 |
+
header h1 {
|
| 125 |
+
font-size: 2rem !important;
|
| 126 |
+
}
|
| 127 |
+
|
| 128 |
+
header p {
|
| 129 |
+
font-size: 1rem !important;
|
| 130 |
+
}
|
| 131 |
+
|
| 132 |
+
.glass-effect {
|
| 133 |
+
padding: 1rem !important;
|
| 134 |
+
}
|
| 135 |
+
|
| 136 |
+
.content-box {
|
| 137 |
+
padding: 1rem !important;
|
| 138 |
+
}
|
| 139 |
+
}
|
| 140 |
+
|
| 141 |
+
/* Tablet specific styles */
|
| 142 |
+
@media (min-width: 769px) and (max-width: 1024px) {
|
| 143 |
+
header h1 {
|
| 144 |
+
font-size: 3.5rem !important;
|
| 145 |
+
}
|
| 146 |
+
|
| 147 |
+
.container {
|
| 148 |
+
padding: 2rem;
|
| 149 |
+
}
|
| 150 |
+
|
| 151 |
+
.content-box {
|
| 152 |
+
padding: 2rem !important;
|
| 153 |
+
}
|
| 154 |
+
}
|
| 155 |
+
</style>
|
| 156 |
+
</head>
|
| 157 |
+
<body class="text-white text-shadow">
|
| 158 |
+
<div class="container mx-auto px-4 py-8 md:py-12 max-w-6xl relative">
|
| 159 |
+
<!-- Header -->
|
| 160 |
+
<header class="text-center mb-8 md:mb-12">
|
| 161 |
+
<div class="glass-effect inline-block px-6 md:px-10 py-4 md:py-6 rounded-3xl mb-6 md:mb-8">
|
| 162 |
+
<h1 class="text-3xl md:text-5xl lg:text-7xl font-bold gradient-text mb-3 md:mb-4 tracking-tight">PyxiLabs._.Vocify</h1>
|
| 163 |
+
<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>
|
| 164 |
+
</div>
|
| 165 |
+
</header>
|
| 166 |
+
|
| 167 |
+
<!-- Main Content -->
|
| 168 |
+
<div class="max-w-3xl mx-auto content-box rounded-3xl custom-shadow p-4 md:p-8 lg:p-10 hover-scale">
|
| 169 |
+
<!-- Voice Selection -->
|
| 170 |
+
<div class="mb-6 md:mb-8">
|
| 171 |
+
<label class="block white-text text-base md:text-lg font-medium mb-2 md:mb-3" for="voice">
|
| 172 |
+
Select Voice
|
| 173 |
+
</label>
|
| 174 |
+
<div class="relative">
|
| 175 |
+
<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">
|
| 176 |
+
</select>
|
| 177 |
+
<div class="pointer-events-none absolute inset-y-0 right-0 flex items-center px-3 md:px-4 text-white">
|
| 178 |
+
<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">
|
| 179 |
+
<path d="M9.293 12.95l.707.707L15.657 8l-1.414-1.414L10 10.828 5.757 6.586 4.343 8z"/>
|
| 180 |
+
</svg>
|
| 181 |
+
</div>
|
| 182 |
+
</div>
|
| 183 |
+
</div>
|
| 184 |
+
|
| 185 |
+
<!-- Text Input -->
|
| 186 |
+
<div class="mb-6 md:mb-8">
|
| 187 |
+
<label class="block white-text text-base md:text-lg font-medium mb-2 md:mb-3" for="text">
|
| 188 |
+
Enter Text
|
| 189 |
+
</label>
|
| 190 |
+
<textarea
|
| 191 |
+
id="text"
|
| 192 |
+
rows="4"
|
| 193 |
+
maxlength="500"
|
| 194 |
+
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"
|
| 195 |
+
placeholder="Enter your text here (max 500 characters)..."
|
| 196 |
+
></textarea>
|
| 197 |
+
<p id="char-count" class="text-sm md:text-base white-text mt-2 text-right">0/500 characters</p>
|
| 198 |
+
</div>
|
| 199 |
+
|
| 200 |
+
<!-- Generate Button -->
|
| 201 |
+
<button
|
| 202 |
+
id="generate"
|
| 203 |
+
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"
|
| 204 |
+
>
|
| 205 |
+
Generate Speech
|
| 206 |
+
</button>
|
| 207 |
+
|
| 208 |
+
<!-- Audio Player -->
|
| 209 |
+
<div id="audio-container" class="mt-6 md:mt-8 hidden">
|
| 210 |
+
<div class="glass-effect p-4 md:p-6 rounded-xl">
|
| 211 |
+
<audio id="audio-player" controls class="w-full">
|
| 212 |
+
Your browser does not support the audio element.
|
| 213 |
+
</audio>
|
| 214 |
+
</div>
|
| 215 |
+
</div>
|
| 216 |
+
|
| 217 |
+
<!-- Loading State -->
|
| 218 |
+
<div id="loading" class="hidden mt-6 md:mt-8 text-center">
|
| 219 |
+
<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>
|
| 220 |
+
</div>
|
| 221 |
+
|
| 222 |
+
<!-- Error Message -->
|
| 223 |
+
<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">
|
| 224 |
+
</div>
|
| 225 |
+
</div>
|
| 226 |
+
|
| 227 |
+
<!-- API Documentation -->
|
| 228 |
+
<div class="mt-12 md:mt-16 text-center">
|
| 229 |
+
<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>
|
| 230 |
+
<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">
|
| 231 |
+
<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
|
| 232 |
+
{
|
| 233 |
+
"model": "eleven_multilingual_v2",
|
| 234 |
+
"input": "Your text here",
|
| 235 |
+
"voice": "selected_voice"
|
| 236 |
+
}</code></pre>
|
| 237 |
+
</div>
|
| 238 |
+
</div>
|
| 239 |
+
|
| 240 |
+
<!-- Footer -->
|
| 241 |
+
<footer class="mt-12 md:mt-16 text-center">
|
| 242 |
+
<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">
|
| 243 |
+
© 2024 PyxiLabs._.Vocify. All rights reserved.
|
| 244 |
+
</p>
|
| 245 |
+
</footer>
|
| 246 |
+
</div>
|
| 247 |
+
|
| 248 |
+
<script>
|
| 249 |
+
const voiceSelect = document.getElementById('voice');
|
| 250 |
+
const textInput = document.getElementById('text');
|
| 251 |
+
const charCount = document.getElementById('char-count');
|
| 252 |
+
const generateBtn = document.getElementById('generate');
|
| 253 |
+
const audioContainer = document.getElementById('audio-container');
|
| 254 |
+
const audioPlayer = document.getElementById('audio-player');
|
| 255 |
+
const loading = document.getElementById('loading');
|
| 256 |
+
const error = document.getElementById('error');
|
| 257 |
+
|
| 258 |
+
async function fetchVoices() {
|
| 259 |
+
try {
|
| 260 |
+
const response = await fetch('/v1/voices');
|
| 261 |
+
const data = await response.json();
|
| 262 |
+
|
| 263 |
+
data.voices.sort().forEach(voice => {
|
| 264 |
+
const option = document.createElement('option');
|
| 265 |
+
option.value = voice;
|
| 266 |
+
option.textContent = voice.charAt(0).toUpperCase() + voice.slice(1);
|
| 267 |
+
voiceSelect.appendChild(option);
|
| 268 |
+
});
|
| 269 |
+
} catch (err) {
|
| 270 |
+
showError('Failed to load voices. Please refresh the page.');
|
| 271 |
+
}
|
| 272 |
+
}
|
| 273 |
+
|
| 274 |
+
textInput.addEventListener('input', () => {
|
| 275 |
+
const length = textInput.value.length;
|
| 276 |
+
charCount.textContent = `${length}/500 characters`;
|
| 277 |
+
|
| 278 |
+
if (length > 450) {
|
| 279 |
+
charCount.classList.add('text-red-400');
|
| 280 |
+
charCount.classList.remove('white-text');
|
| 281 |
+
} else {
|
| 282 |
+
charCount.classList.remove('text-red-400');
|
| 283 |
+
charCount.classList.add('white-text');
|
| 284 |
+
}
|
| 285 |
+
});
|
| 286 |
+
|
| 287 |
+
generateBtn.addEventListener('click', async () => {
|
| 288 |
+
const text = textInput.value.trim();
|
| 289 |
+
const voice = voiceSelect.value;
|
| 290 |
+
|
| 291 |
+
if (!text) {
|
| 292 |
+
showError('Please enter some text to convert to speech');
|
| 293 |
+
return;
|
| 294 |
+
}
|
| 295 |
+
|
| 296 |
+
showLoading();
|
| 297 |
+
hideError();
|
| 298 |
+
|
| 299 |
+
try {
|
| 300 |
+
const response = await fetch('/v1/audio/speech', {
|
| 301 |
+
method: 'POST',
|
| 302 |
+
headers: {
|
| 303 |
+
'Content-Type': 'application/json',
|
| 304 |
+
},
|
| 305 |
+
body: JSON.stringify({
|
| 306 |
+
model: 'eleven_multilingual_v2',
|
| 307 |
+
input: text,
|
| 308 |
+
voice: voice
|
| 309 |
+
})
|
| 310 |
+
});
|
| 311 |
+
|
| 312 |
+
if (!response.ok) {
|
| 313 |
+
throw new Error('Failed to generate speech. Please try again.');
|
| 314 |
+
}
|
| 315 |
+
|
| 316 |
+
const audioBlob = await response.blob();
|
| 317 |
+
const audioUrl = URL.createObjectURL(audioBlob);
|
| 318 |
+
|
| 319 |
+
audioPlayer.src = audioUrl;
|
| 320 |
+
showAudioPlayer();
|
| 321 |
+
audioPlayer.play();
|
| 322 |
+
} catch (err) {
|
| 323 |
+
showError(err.message);
|
| 324 |
+
} finally {
|
| 325 |
+
hideLoading();
|
| 326 |
+
}
|
| 327 |
+
});
|
| 328 |
+
|
| 329 |
+
function showLoading() {
|
| 330 |
+
loading.classList.remove('hidden');
|
| 331 |
+
generateBtn.disabled = true;
|
| 332 |
+
generateBtn.classList.add('opacity-50');
|
| 333 |
+
}
|
| 334 |
+
|
| 335 |
+
function hideLoading() {
|
| 336 |
+
loading.classList.add('hidden');
|
| 337 |
+
generateBtn.disabled = false;
|
| 338 |
+
generateBtn.classList.remove('opacity-50');
|
| 339 |
+
}
|
| 340 |
+
|
| 341 |
+
function showError(message) {
|
| 342 |
+
error.textContent = message;
|
| 343 |
+
error.classList.remove('hidden');
|
| 344 |
+
error.scrollIntoView({ behavior: 'smooth', block: 'center' });
|
| 345 |
+
}
|
| 346 |
+
|
| 347 |
+
function hideError() {
|
| 348 |
+
error.classList.add('hidden');
|
| 349 |
+
}
|
| 350 |
+
|
| 351 |
+
function showAudioPlayer() {
|
| 352 |
+
audioContainer.classList.remove('hidden');
|
| 353 |
+
}
|
| 354 |
+
|
| 355 |
+
// Initialize the application
|
| 356 |
+
fetchVoices();
|
| 357 |
+
</script>
|
| 358 |
+
</body>
|
| 359 |
+
</html>
|