File size: 9,930 Bytes
deeb2be
 
 
 
 
e97881c
 
deeb2be
e97881c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
deeb2be
 
 
e97881c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
deeb2be
 
 
e97881c
 
 
 
 
deeb2be
 
 
e97881c
 
 
deeb2be
 
e97881c
deeb2be
e97881c
 
 
 
 
 
 
 
deeb2be
 
e97881c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
deeb2be
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Nemotron Speech Streaming - UI Preview</title>
    <link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600&display=swap" rel="stylesheet">
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        body {
            background: #0a0a0f;
            font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
            min-height: 100vh;
            overflow: hidden;
        }

        /* Main App Container */
        #app-container {
            position: fixed;
            top: 0;
            left: 0;
            width: 100vw;
            height: 100vh;
            background: linear-gradient(180deg, #0a0a0f 0%, #12121a 50%, #0a0a0f 100%);
            display: flex;
            flex-direction: column;
            overflow: hidden;
        }

        /* Header */
        #header {
            padding: 20px;
            text-align: center;
            z-index: 10;
        }

        #session-badge {
            display: inline-flex;
            align-items: center;
            gap: 8px;
            background: rgba(255, 255, 255, 0.05);
            border: 1px solid rgba(255, 255, 255, 0.1);
            border-radius: 20px;
            padding: 8px 16px;
            color: rgba(255, 255, 255, 0.7);
            font-size: 13px;
            font-weight: 500;
        }

        #live-dot {
            width: 8px;
            height: 8px;
            background: #22c55e;
            border-radius: 50%;
            animation: pulse 2s ease-in-out infinite;
        }

        @keyframes pulse {
            0%, 100% { opacity: 1; transform: scale(1); }
            50% { opacity: 0.5; transform: scale(0.9); }
        }

        /* Transcript Area */
        #transcript-area {
            flex: 1;
            display: flex;
            flex-direction: column;
            justify-content: center;
            align-items: center;
            padding: 40px 20px;
            text-align: center;
            z-index: 10;
        }

        .transcript-current {
            color: #ffffff;
            font-size: clamp(24px, 5vw, 42px);
            font-weight: 400;
            line-height: 1.4;
            max-width: 800px;
            text-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
            animation: fadeIn 0.3s ease-out;
        }

        .transcript-history {
            color: rgba(255, 255, 255, 0.35);
            font-size: clamp(14px, 2.5vw, 18px);
            font-weight: 300;
            line-height: 1.8;
            max-width: 700px;
            margin-top: 30px;
        }

        @keyframes fadeIn {
            from { opacity: 0; transform: translateY(10px); }
            to { opacity: 1; transform: translateY(0); }
        }

        /* Ambient Glow */
        #ambient-glow {
            position: absolute;
            bottom: 0;
            left: 50%;
            transform: translateX(-50%);
            width: 150%;
            height: 50vh;
            background: radial-gradient(ellipse at center bottom, rgba(99, 102, 241, 0.15) 0%, transparent 70%);
            pointer-events: none;
            z-index: 1;
        }

        /* Controls Area */
        #controls-area {
            padding: 30px 20px 50px;
            display: flex;
            justify-content: center;
            align-items: center;
            gap: 40px;
            z-index: 20;
        }

        /* Mic Button */
        #mic-btn {
            width: 80px;
            height: 80px;
            border-radius: 50%;
            background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
            border: none;
            cursor: pointer;
            transition: all 0.2s ease;
            box-shadow: 0 8px 30px rgba(99, 102, 241, 0.4);
            display: flex;
            align-items: center;
            justify-content: center;
        }

        #mic-btn:hover {
            transform: scale(1.05);
            box-shadow: 0 12px 40px rgba(99, 102, 241, 0.5);
        }

        #mic-btn:active,
        #mic-btn.recording {
            transform: scale(0.95);
            background: linear-gradient(135deg, #ef4444 0%, #f97316 100%);
            box-shadow: 0 8px 30px rgba(239, 68, 68, 0.4);
        }

        #mic-btn svg {
            width: 32px;
            height: 32px;
            fill: white;
        }

        /* Reset Button */
        #reset-btn {
            background: rgba(255, 255, 255, 0.05);
            border: 1px solid rgba(255, 255, 255, 0.1);
            color: rgba(255, 255, 255, 0.6);
            padding: 12px 24px;
            border-radius: 12px;
            font-size: 14px;
            font-weight: 500;
            cursor: pointer;
            transition: all 0.2s ease;
            font-family: inherit;
        }

        #reset-btn:hover {
            background: rgba(255, 255, 255, 0.1);
            color: rgba(255, 255, 255, 0.9);
        }

        /* Recording animation */
        @keyframes recording-pulse {
            0%, 100% { box-shadow: 0 8px 30px rgba(239, 68, 68, 0.4); }
            50% { box-shadow: 0 8px 50px rgba(239, 68, 68, 0.7); }
        }

        #mic-btn.recording {
            animation: recording-pulse 1.5s ease-in-out infinite;
        }
    </style>
</head>
<body>
    <div id="app-container">
        <div id="header">
            <div id="session-badge">
                <div id="live-dot"></div>
                <span>Live Session • DEMO_MODE</span>
            </div>
        </div>

        <div id="transcript-area">
            <div class="transcript-current" id="current-text">Tap the microphone to start speaking...</div>
            <div class="transcript-history" id="history-text"></div>
        </div>

        <div id="ambient-glow"></div>

        <div id="controls-area">
            <button id="mic-btn" aria-label="Start recording">
                <svg viewBox="0 0 24 24">
                    <path d="M12 14c1.66 0 3-1.34 3-3V5c0-1.66-1.34-3-3-3S9 3.34 9 5v6c0 1.66 1.34 3 3 3z"/>
                    <path d="M17 11c0 2.76-2.24 5-5 5s-5-2.24-5-5H5c0 3.53 2.61 6.43 6 6.92V21h2v-3.08c3.39-.49 6-3.39 6-6.92h-2z"/>
                </svg>
            </button>
            <button id="reset-btn">Reset</button>
        </div>
    </div>

    <script>
        const micBtn = document.getElementById('mic-btn');
        const resetBtn = document.getElementById('reset-btn');
        const currentText = document.getElementById('current-text');
        const historyText = document.getElementById('history-text');

        let isRecording = false;
        let recognition = null;
        let transcript = [];

        // Check for Web Speech API support
        if ('webkitSpeechRecognition' in window || 'SpeechRecognition' in window) {
            const SpeechRecognition = window.SpeechRecognition || window.webkitSpeechRecognition;
            recognition = new SpeechRecognition();
            recognition.continuous = true;
            recognition.interimResults = true;
            recognition.lang = 'en-US';

            recognition.onresult = (event) => {
                let interimTranscript = '';
                let finalTranscript = '';

                for (let i = event.resultIndex; i < event.results.length; i++) {
                    const result = event.results[i];
                    if (result.isFinal) {
                        finalTranscript += result[0].transcript;
                    } else {
                        interimTranscript += result[0].transcript;
                    }
                }

                if (finalTranscript) {
                    transcript.push(finalTranscript.trim());
                    updateDisplay();
                } else if (interimTranscript) {
                    currentText.textContent = interimTranscript;
                }
            };

            recognition.onerror = (event) => {
                console.error('Speech recognition error:', event.error);
                stopRecording();
            };

            recognition.onend = () => {
                if (isRecording) {
                    recognition.start(); // Restart if still in recording mode
                }
            };
        }

        function updateDisplay() {
            if (transcript.length > 0) {
                currentText.textContent = transcript[transcript.length - 1];
                if (transcript.length > 1) {
                    historyText.innerHTML = transcript.slice(0, -1).join('<br>');
                }
            }
        }

        function startRecording() {
            if (recognition) {
                isRecording = true;
                micBtn.classList.add('recording');
                currentText.textContent = 'Listening...';
                recognition.start();
            } else {
                // Fallback demo mode
                isRecording = true;
                micBtn.classList.add('recording');
                currentText.textContent = 'Listening... (Demo mode - no speech recognition)';
            }
        }

        function stopRecording() {
            isRecording = false;
            micBtn.classList.remove('recording');
            if (recognition) {
                recognition.stop();
            }
        }

        function resetSession() {
            stopRecording();
            transcript = [];
            currentText.textContent = 'Tap the microphone to start speaking...';
            historyText.innerHTML = '';
        }

        micBtn.addEventListener('click', () => {
            if (isRecording) {
                stopRecording();
            } else {
                startRecording();
            }
        });

        resetBtn.addEventListener('click', resetSession);
    </script>
</body>
</html>