| <!DOCTYPE html> |
| <html lang="en"> |
| <head> |
| <meta charset="UTF-8"> |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> |
| <title>PyxiLabs._.Vocify - Text to Speech API</title> |
| <link href="https://cdnjs.cloudflare.com/ajax/libs/tailwindcss/2.2.19/tailwind.min.css" rel="stylesheet"> |
| |
| <link rel="icon" href="/static/icon.png" type="image/png"> |
| <link rel="icon" href="/static/icon.png" sizes="32x32" type="image/png"> |
| <link rel="icon" href="/static/icon.png" sizes="16x16" type="image/png"> |
| <link rel="apple-touch-icon" href="/static/icon.png"> |
| <link rel="icon" href="/static/icon.png" sizes="192x192"> |
| <style> |
| :root { |
| --gradient-start: #ff0066; |
| --gradient-end: #3366ff; |
| } |
| |
| body { |
| background-image: url('static/bg3.png'); |
| background-size: cover; |
| background-position: center; |
| background-attachment: fixed; |
| min-height: 100vh; |
| } |
| |
| .gradient-text { |
| background: linear-gradient(45deg, var(--gradient-start), var(--gradient-end)); |
| -webkit-background-clip: text; |
| background-clip: text; |
| color: transparent; |
| text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2); |
| } |
| |
| .custom-shadow { |
| box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4); |
| } |
| |
| .content-box { |
| background: rgba(0, 0, 0, 0.15); |
| backdrop-filter: blur(8px); |
| border: 1px solid rgba(255, 255, 255, 0.1); |
| } |
| |
| .hover-scale { |
| transition: transform 0.2s; |
| } |
| |
| .hover-scale:hover { |
| transform: scale(1.02); |
| } |
| |
| .glass-effect { |
| background: rgba(0, 0, 0, 0.1); |
| backdrop-filter: blur(8px); |
| border: 1px solid rgba(255, 255, 255, 0.1); |
| } |
| |
| .input-dark { |
| background: rgba(0, 0, 0, 0.1); |
| border: 1px solid rgba(255, 255, 255, 0.2); |
| color: #fff; |
| backdrop-filter: blur(4px); |
| } |
| |
| .input-dark::placeholder { |
| color: rgba(255, 255, 255, 0.6); |
| } |
| |
| .input-dark:focus { |
| border-color: var(--gradient-start); |
| box-shadow: 0 0 0 2px rgba(255, 0, 102, 0.2); |
| background: rgba(0, 0, 0, 0.15); |
| } |
| |
| .gradient-btn { |
| background: linear-gradient(45deg, var(--gradient-start), var(--gradient-end)); |
| backdrop-filter: blur(4px); |
| transition: all 0.3s ease; |
| } |
| |
| .gradient-btn:hover { |
| filter: brightness(1.1); |
| transform: translateY(-2px); |
| background: linear-gradient(45deg, var(--gradient-end), var(--gradient-start)); |
| } |
| |
| select option { |
| background-color: rgba(0, 0, 0, 0.8); |
| color: white; |
| } |
| |
| audio::-webkit-media-controls-panel { |
| background: rgba(0, 0, 0, 0.2); |
| backdrop-filter: blur(4px); |
| } |
| |
| audio::-webkit-media-controls-current-time-display, |
| audio::-webkit-media-controls-time-remaining-display { |
| color: white; |
| } |
| |
| .text-shadow { |
| text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3); |
| } |
| |
| pre { |
| background: rgba(0, 0, 0, 0.1) !important; |
| backdrop-filter: blur(4px); |
| white-space: pre-wrap; |
| word-wrap: break-word; |
| } |
| |
| .white-text { |
| color: rgba(255, 255, 255, 0.9); |
| } |
| |
| |
| .loading-bar-container { |
| height: 12px; |
| background-color: rgba(255, 255, 255, 0.1); |
| border-radius: 10px; |
| overflow: hidden; |
| margin-top: 1rem; |
| position: relative; |
| box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2); |
| } |
| |
| .loading-bar { |
| height: 100%; |
| background: linear-gradient(90deg, #ff0066, #3366ff); |
| width: 0%; |
| border-radius: 10px; |
| transition: width 0.5s ease-in-out; |
| position: relative; |
| overflow: hidden; |
| } |
| |
| .loading-bar::after { |
| content: ''; |
| position: absolute; |
| top: 0; |
| left: -100%; |
| width: 100%; |
| height: 100%; |
| background: linear-gradient(90deg, rgba(255, 255, 255, 0.2), rgba(255, 255, 255, 0.4), rgba(255, 255, 255, 0.2)); |
| animation: shimmer 2s infinite; |
| } |
| |
| @keyframes shimmer { |
| 0% { |
| left: -100%; |
| } |
| 100% { |
| left: 100%; |
| } |
| } |
| |
| .loading-bar-text { |
| position: absolute; |
| top: 50%; |
| left: 50%; |
| transform: translate(-50%, -50%); |
| color: white; |
| font-size: 0.9rem; |
| font-weight: bold; |
| text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3); |
| background: rgba(0, 0, 0, 0.5); |
| padding: 2px 8px; |
| border-radius: 12px; |
| backdrop-filter: blur(4px); |
| } |
| </style> |
| </head> |
| <body class="text-white text-shadow"> |
| <div class="container mx-auto px-4 py-8 md:py-12 max-w-6xl relative"> |
| |
| <header class="text-center mb-8 md:mb-12"> |
| <div class="glass-effect inline-block px-6 md:px-10 py-4 md:py-6 rounded-3xl mb-6 md:mb-8"> |
| <h1 class="text-3xl md:text-5xl lg:text-7xl font-bold gradient-text mb-3 md:mb-4 tracking-tight">PyxiLabs._.Vocify</h1> |
| <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> |
| </div> |
| </header> |
|
|
| |
| <div class="max-w-3xl mx-auto content-box rounded-3xl custom-shadow p-4 md:p-8 lg:p-10 hover-scale"> |
| |
| <div class="mb-6 md:mb-8"> |
| <label class="block white-text text-base md:text-lg font-medium mb-2 md:mb-3" for="model"> |
| Select Model |
| </label> |
| <div class="relative"> |
| <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"> |
| </select> |
| <div class="pointer-events-none absolute inset-y-0 right-0 flex items-center px-3 md:px-4 text-white"> |
| <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"> |
| <path d="M9.293 12.95l.707.707L15.657 8l-1.414-1.414L10 10.828 5.757 6.586 4.343 8z"/> |
| </svg> |
| </div> |
| </div> |
| </div> |
|
|
| |
| <div class="mb-6 md:mb-8"> |
| <label class="block white-text text-base md:text-lg font-medium mb-2 md:mb-3" for="voice"> |
| Select Voice |
| </label> |
| <div class="relative"> |
| <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"> |
| </select> |
| <div class="pointer-events-none absolute inset-y-0 right-0 flex items-center px-3 md:px-4 text-white"> |
| <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"> |
| <path d="M9.293 12.95l.707.707L15.657 8l-1.414-1.414L10 10.828 5.757 6.586 4.343 8z"/> |
| </svg> |
| </div> |
| </div> |
| </div> |
|
|
| |
| <div class="mb-6 md:mb-8"> |
| <label class="block white-text text-base md:text-lg font-medium mb-2 md:mb-3" for="text"> |
| Enter Text |
| </label> |
| <textarea |
| id="text" |
| rows="4" |
| maxlength="5000" |
| 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" |
| placeholder="Enter your text here (max 5000 characters)..." |
| ></textarea> |
| <p id="char-count" class="text-sm md:text-base white-text mt-2 text-right">0/5000 characters</p> |
| </div> |
|
|
| |
| <button |
| id="generate" |
| 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" |
| > |
| Generate Speech |
| </button> |
|
|
| |
| <div id="loading-bar-container" class="hidden relative mt-6"> |
| <div class="loading-bar-container"> |
| <div id="loading-bar" class="loading-bar"></div> |
| </div> |
| <div id="loading-bar-text" class="loading-bar-text">0%</div> |
| </div> |
|
|
| |
| <div id="audio-container" class="mt-6 md:mt-8 hidden"> |
| <div class="glass-effect p-4 md:p-6 rounded-xl"> |
| <audio id="audio-player" controls class="w-full"> |
| Your browser does not support the audio element. |
| </audio> |
| </div> |
| </div> |
|
|
| |
| <div id="loading" class="hidden mt-6 md:mt-8 text-center"> |
| <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> |
| </div> |
|
|
| |
| <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"> |
| </div> |
| </div> |
|
|
| |
| <div class="mt-12 md:mt-16 text-center"> |
| <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> |
| <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"> |
| <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 |
| { |
| "model": "Pyx r1-voice", |
| "input": "Your text here", |
| "voice": "selected_voice" |
| } |
|
|
| Rate Limits (Free Tier): |
| - Requests Per Minute (RPM): 10 |
| - Requests Per Hour (RPH): 100 |
| - Requests Per Day (RPD): 1,000</code></pre> |
| </div> |
| </div> |
|
|
| |
| <footer class="mt-12 md:mt-16 text-center"> |
| <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"> |
| © 2024 PyxiLabs._.Vocify. All rights reserved. |
| </p> |
| </footer> |
| </div> |
|
|
| <script> |
| const modelSelect = document.getElementById('model'); |
| const voiceSelect = document.getElementById('voice'); |
| const textInput = document.getElementById('text'); |
| const charCount = document.getElementById('char-count'); |
| const generateBtn = document.getElementById('generate'); |
| const audioContainer = document.getElementById('audio-container'); |
| const audioPlayer = document.getElementById('audio-player'); |
| const loading = document.getElementById('loading'); |
| const error = document.getElementById('error'); |
| const loadingBarContainer = document.getElementById('loading-bar-container'); |
| const loadingBar = document.getElementById('loading-bar'); |
| const loadingBarText = document.getElementById('loading-bar-text'); |
| |
| let modelsData = {}; |
| |
| async function fetchModels() { |
| try { |
| const response = await fetch('/v1/models'); |
| const data = await response.json(); |
| modelsData = data.models.reduce((acc, model) => { |
| acc[model.id] = model; |
| return acc; |
| }, {}); |
| |
| |
| data.models.forEach(model => { |
| const option = document.createElement('option'); |
| option.value = model.id; |
| option.textContent = `${model.name} (${model.owner})`; |
| modelSelect.appendChild(option); |
| }); |
| |
| |
| if (data.models.length > 0) { |
| updateVoices(data.models[0].id); |
| } |
| } catch (err) { |
| showError('Failed to load models. Please refresh the page.'); |
| } |
| } |
| |
| function updateVoices(modelId) { |
| |
| voiceSelect.innerHTML = ''; |
| |
| const model = modelsData[modelId]; |
| if (model && model.vocals) { |
| model.vocals.forEach(voice => { |
| const option = document.createElement('option'); |
| option.value = voice.id; |
| option.textContent = voice.id.charAt(0).toUpperCase() + voice.id.slice(1); |
| voiceSelect.appendChild(option); |
| }); |
| } |
| } |
| |
| modelSelect.addEventListener('change', (e) => { |
| updateVoices(e.target.value); |
| }); |
| |
| textInput.addEventListener('input', () => { |
| const length = textInput.value.length; |
| charCount.textContent = `${length}/5000 characters`; |
| |
| if (length > 4900) { |
| charCount.classList.add('text-red-400'); |
| charCount.classList.remove('white-text'); |
| } else { |
| charCount.classList.remove('text-red-400'); |
| charCount.classList.add('white-text'); |
| } |
| }); |
| |
| generateBtn.addEventListener('click', async () => { |
| const text = textInput.value.trim(); |
| const model = modelSelect.value; |
| const voice = voiceSelect.value; |
| |
| if (!text) { |
| showError('Please enter some text to convert to speech'); |
| return; |
| } |
| |
| showLoading(); |
| hideError(); |
| |
| let progress = 0; |
| loadingBar.style.width = `${progress}%`; |
| loadingBarText.textContent = `${progress}%`; |
| |
| const intervalId = setInterval(() => { |
| progress += 10; |
| if (progress > 95) progress = 95; |
| loadingBar.style.width = `${progress}%`; |
| loadingBarText.textContent = `${progress}%`; |
| }, 300); |
| |
| try { |
| const response = await fetch('/v1/audio/speech', { |
| method: 'POST', |
| headers: { |
| 'Content-Type': 'application/json', |
| }, |
| body: JSON.stringify({ |
| model: model, |
| input: text, |
| voice: voice |
| }) |
| }); |
| |
| clearInterval(intervalId); |
| |
| if (!response.ok) { |
| loadingBar.style.width = `100%`; |
| loadingBarText.textContent = `Failed`; |
| throw new Error('Failed to generate speech. Please try again.'); |
| } |
| |
| const audioBlob = await response.blob(); |
| const audioUrl = URL.createObjectURL(audioBlob); |
| |
| loadingBar.style.width = `100%`; |
| loadingBarText.textContent = `100%`; |
| audioPlayer.src = audioUrl; |
| showAudioPlayer(); |
| audioPlayer.play(); |
| } catch (err) { |
| showError(err.message); |
| } finally { |
| if (error.classList.contains('hidden')) { |
| setTimeout(hideLoading, 500); |
| } else { |
| hideLoading(); |
| } |
| } |
| }); |
| |
| function showLoading() { |
| loadingBarContainer.classList.remove('hidden'); |
| loading.classList.remove('hidden'); |
| generateBtn.disabled = true; |
| generateBtn.classList.add('opacity-50'); |
| } |
| |
| function hideLoading() { |
| loadingBarContainer.classList.add('hidden'); |
| loading.classList.add('hidden'); |
| generateBtn.disabled = false; |
| generateBtn.classList.remove('opacity-50'); |
| } |
| |
| function showError(message) { |
| error.textContent = message; |
| error.classList.remove('hidden'); |
| error.scrollIntoView({ behavior: 'smooth', block: 'center' }); |
| } |
| |
| function hideError() { |
| error.classList.add('hidden'); |
| } |
| |
| function showAudioPlayer() { |
| audioContainer.classList.remove('hidden'); |
| } |
| |
| |
| fetchModels(); |
| </script> |
| </body> |
| </html> |