Spaces:
Build error
Build error
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
| <title>Dia Text-to-Speech Converter</title> | |
| <link href="https://cdn.jsdelivr.net/npm/tailwindcss@2.2.16/dist/tailwind.min.css" rel="stylesheet"> | |
| </head> | |
| <body class="bg-gray-100 min-h-screen flex items-center justify-center p-4"> | |
| <div class="container max-w-3xl mx-auto p-8 bg-white rounded-xl shadow-lg"> | |
| <h1 class="text-3xl font-bold text-center text-indigo-700 mb-8">Dia Text-to-Speech Converter</h1> | |
| <form action="/convertor" method="post" enctype="multipart/form-data" class="space-y-6"> | |
| <div class="mb-6"> | |
| <label for="paragraph" class="block text-gray-700 font-semibold mb-2">Enter Text to Convert</label> | |
| <textarea | |
| id="paragraph" | |
| name="paragraph" | |
| rows="6" | |
| class="w-full p-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500 transition" | |
| placeholder="Type or paste your text here..." | |
| required | |
| ></textarea> | |
| </div> | |
| <div class="mb-6"> | |
| <label for="action" class="block text-gray-700 font-semibold mb-2">Choose Action</label> | |
| <select | |
| id="action" | |
| name="action" | |
| class="w-full p-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500 transition" | |
| > | |
| <option value="audio">Convert to Audio</option> | |
| <option value="summarize" disabled>Summarize (Coming Soon)</option> | |
| </select> | |
| </div> | |
| <div class="flex justify-center"> | |
| <button | |
| type="submit" | |
| class="bg-indigo-600 hover:bg-indigo-700 text-white font-bold py-3 px-8 rounded-lg shadow-md transition duration-300 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-opacity-50" | |
| > | |
| Generate Audio | |
| </button> | |
| </div> | |
| </form> | |
| <div id="result" class="mt-8 text-center"> | |
| <!-- Audio player will appear here after conversion --> | |
| </div> | |
| <div class="mt-8 text-center text-gray-600 text-sm"> | |
| <p>Powered by Dia-1.6B AI Text-to-Speech Model</p> | |
| </div> | |
| </div> | |
| <script> | |
| document.addEventListener('DOMContentLoaded', function() { | |
| const form = document.querySelector('form'); | |
| const resultDiv = document.getElementById('result'); | |
| form.addEventListener('submit', async function(e) { | |
| e.preventDefault(); | |
| const submitButton = form.querySelector('button[type="submit"]'); | |
| submitButton.disabled = true; | |
| submitButton.innerHTML = 'Processing...'; | |
| try { | |
| const formData = new FormData(form); | |
| const response = await fetch('/convertor', { | |
| method: 'POST', | |
| body: formData | |
| }); | |
| if (response.ok) { | |
| const blob = await response.blob(); | |
| const audioUrl = URL.createObjectURL(blob); | |
| resultDiv.innerHTML = ` | |
| <h2 class="text-xl font-semibold text-gray-800 mb-4">Your Audio is Ready!</h2> | |
| <audio controls class="mx-auto mb-4"> | |
| <source src="${audioUrl}" type="audio/wav"> | |
| Your browser does not support the audio element. | |
| </audio> | |
| <a href="${audioUrl}" download="generated_audio.wav" class="inline-block bg-green-600 hover:bg-green-700 text-white font-bold py-2 px-4 rounded-lg shadow-md transition duration-300"> | |
| Download Audio | |
| </a> | |
| `; | |
| } else { | |
| const errorData = await response.json(); | |
| resultDiv.innerHTML = `<p class="text-red-600">Error: ${errorData.detail}</p>`; | |
| } | |
| } catch (error) { | |
| resultDiv.innerHTML = `<p class="text-red-600">Error: ${error.message}</p>`; | |
| } finally { | |
| submitButton.disabled = false; | |
| submitButton.innerHTML = 'Generate Audio'; | |
| } | |
| }); | |
| }); | |
| </script> | |
| </body> | |
| </html> |