Spaces:
Running
Running
Download index.html from LostSolution/AI-Training: direct link, hf CLI and curl.
- Browser
- Download file 6.78 kB
-
https://huggingface.co/spaces/LostSolution/AI-Training/resolve/main/index.html
- Command line
-
hf download hf://spaces/LostSolution/AI-Training/index.html
-
curl -L -o index.html https://huggingface.co/spaces/LostSolution/AI-Training/resolve/main/index.html
6.78 kB
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
| <meta name="description" content="Ethereal messaging interface with voice input"> | |
| <meta name="theme-color" content="#7e22ce"> | |
| <title>Ethereal Messenger</title> | |
| <link rel="icon" type="image/x-icon" href="/static/favicon.ico"> | |
| <script src="https://cdn.tailwindcss.com"></script> | |
| <script src="https://cdn.jsdelivr.net/npm/feather-icons/dist/feather.min.js"></script> | |
| <script src="https://unpkg.com/feather-icons"></script> | |
| <style> | |
| @import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600&display=swap'); | |
| body { | |
| font-family: 'Inter', sans-serif; | |
| background: linear-gradient(135deg, #7e22ce 0%, #3b82f6 100%); | |
| color: rgba(236, 253, 245, 0.95); | |
| min-height: 100vh; | |
| } | |
| .message-display { | |
| background: rgba(255, 255, 255, 0.08); | |
| backdrop-filter: blur(12px); | |
| border: 1px solid rgba(255, 255, 255, 0.1); | |
| } | |
| .text-input { | |
| background: rgba(255, 255, 255, 0.1); | |
| color: rgba(236, 253, 245, 0.95); | |
| } | |
| .text-input::placeholder { | |
| color: rgba(236, 253, 245, 0.6); | |
| } | |
| .send-btn { | |
| background: rgba(167, 139, 250, 0.3); | |
| transition: all 0.2s ease; | |
| } | |
| .send-btn:hover { | |
| background: rgba(167, 139, 250, 0.5); | |
| } | |
| .voice-btn { | |
| background: rgba(74, 222, 128, 0.3); | |
| transition: all 0.2s ease; | |
| } | |
| .voice-btn:hover { | |
| background: rgba(74, 222, 128, 0.5); | |
| } | |
| </style> | |
| </head> | |
| <body class="flex flex-col"> | |
| <header class="p-4"> | |
| <h1 class="text-2xl font-semibold text-center">Ethereal Messenger</h1> | |
| </header> | |
| <main class="flex-1 p-4 max-w-3xl w-full mx-auto"> | |
| <div id="messageDisplay" class="message-display rounded-xl p-4 h-96 overflow-y-auto mb-4 shadow-lg"> | |
| <!-- Messages will appear here dynamically --> | |
| <div class="text-center text-opacity-60 pt-32"> | |
| <i data-feather="message-circle" class="w-12 h-12 mx-auto opacity-40"></i> | |
| <p class="mt-2">Your messages will appear here</p> | |
| </div> | |
| </div> | |
| <div class="flex space-x-2"> | |
| <input | |
| type="text" | |
| id="messageInput" | |
| class="text-input flex-1 rounded-lg px-4 py-3 focus:outline-none focus:ring-2 focus:ring-purple-300 focus:ring-opacity-50" | |
| placeholder="Type your message..." | |
| autocomplete="off" | |
| > | |
| <button id="sendButton" class="send-btn rounded-lg px-4 flex items-center justify-center"> | |
| <i data-feather="send" class="w-5 h-5"></i> | |
| </button> | |
| <button id="voiceButton" class="voice-btn rounded-lg px-4 flex items-center justify-center"> | |
| <i data-feather="mic" class="w-5 h-5"></i> | |
| </button> | |
| </div> | |
| </main> | |
| <footer class="p-4 text-center text-sm text-opacity-60"> | |
| <p>© 2023 Ethereal Messenger. All rights reserved.</p> | |
| </footer> | |
| ; | |
| <script type="module"> | |
| // import { pipeline } from '@huggingface/transformers' | |
| import { pipeline } from "https://cdn.jsdelivr.net/npm/@xenova/transformers"; | |
| // Initialize Whisper transcription pipeline | |
| window.transcriber = await pipeline( | |
| "automatic-speech-recognition", | |
| "Xenova/whisper-tiny.en" | |
| ); | |
| // Transcribe audio from URL with timestamps | |
| // const url = 'https://huggingface.co/datasets/Xenova/transformers.js-docs/resolve/main/jfk.wav'; | |
| // const result = await transcriber(url, { return_timestamps: true }); | |
| // Show output on screen | |
| // addMessage("Transcription: " + result.text, false); | |
| </script> | |
| <script> | |
| feather.replace(); | |
| // Basic message handling for demonstration | |
| const messageDisplay = document.getElementById('messageDisplay'); | |
| const messageInput = document.getElementById('messageInput'); | |
| const sendButton = document.getElementById('sendButton'); | |
| const voiceButton = document.getElementById('voiceButton'); | |
| function addMessage(text, isUser = true) { | |
| const messageElement = document.createElement('div'); | |
| messageElement.className = `mb-3 p-3 rounded-lg max-w-xs ${isUser ? 'ml-auto bg-purple-500 bg-opacity-30' : 'mr-auto bg-blue-500 bg-opacity-30'}`; | |
| messageElement.textContent = text; | |
| messageDisplay.appendChild(messageElement); | |
| messageDisplay.scrollTop = messageDisplay.scrollHeight; | |
| } | |
| sendButton.addEventListener('click', () => { | |
| const message = messageInput.value.trim(); | |
| if (message) { | |
| addMessage(message); | |
| messageInput.value = ''; | |
| // Simulate response after 1 second | |
| setTimeout(() => { | |
| addMessage("This is a simulated response.", false); | |
| }, 1000); | |
| } | |
| }); | |
| messageInput.addEventListener('keypress', (e) => { | |
| if (e.key === 'Enter') { | |
| sendButton.click(); | |
| } | |
| }); | |
| voiceButton.addEventListener('click', async () => { | |
| console.log("🎤 Voice button clicked"); | |
| addMessage("Listening... 🎤 Say something now"); | |
| const stream = await navigator.mediaDevices.getUserMedia({ audio: true }); | |
| console.log("✅ Microphone access granted"); | |
| const mediaRecorder = new MediaRecorder(stream); | |
| let chunks = []; | |
| mediaRecorder.addEventListener("dataavailable", event => { | |
| chunks.push(event.data); | |
| console.log("📥 Audio chunk received:", event.data); | |
| }); | |
| mediaRecorder.addEventListener("stop", async () => { | |
| console.log("🛑 Recording stopped"); | |
| const blob = new Blob(chunks, { type: 'audio/webm' }); | |
| console.log("🎧 Audio Blob created:", blob); | |
| const result = await window.transcriber(blob); | |
| console.log("Whisper output:", result.text); | |
| messageInput.value = result.text; | |
| messageInput.focus(); | |
| addMessage("Voice input loaded into text box ✔️", false); | |
| }); | |
| mediaRecorder.start(); | |
| console.log("▶️ Recording started"); | |
| setTimeout(() => { | |
| console.log("⏱️ Timer ended — stopping recording..."); | |
| mediaRecorder.stop(); | |
| }, 3000); | |
| }); | |
| </script> | |
| </body> | |
| </html> |