forked from JoKneeMo/enjoy
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvoice.html
More file actions
229 lines (204 loc) · 7.75 KB
/
Copy pathvoice.html
File metadata and controls
229 lines (204 loc) · 7.75 KB
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>🎤 Voice Contribution - Enjoy</title>
<style>
:root {
--bg: #0d1117;
--surface: #161b22;
--border: #30363d;
--text: #c9d1d9;
--accent: #58a6ff;
--success: #3fb950;
--danger: #f85149;
}
<link rel="stylesheet" href="fonts.css">
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
font-family: 'Space Grotesk', -apple-system, system-ui, sans-serif;
font-weight: 300;
letter-spacing: 0.01em;
background: var(--bg);
color: var(--text);
min-height: 100vh;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
padding: 2rem;
}
.container {
max-width: 500px;
width: 100%;
text-align: center;
}
h1 { font-size: 2.5rem; margin-bottom: 0.5rem; }
.subtitle { color: #8b949e; margin-bottom: 2rem; }
.notice {
background: rgba(88, 166, 255, 0.1);
border: 1px solid var(--accent);
border-radius: 12px;
padding: 1rem;
margin-bottom: 2rem;
font-size: 0.9rem;
}
.record-btn {
width: 150px;
height: 150px;
border-radius: 50%;
border: 4px solid var(--border);
background: var(--surface);
color: var(--text);
font-size: 3rem;
cursor: pointer;
transition: all 0.3s;
margin: 2rem 0;
}
.record-btn:hover { border-color: var(--accent); }
.record-btn.recording {
border-color: var(--danger);
animation: pulse 1s infinite;
}
@keyframes pulse {
0%, 100% { transform: scale(1); }
50% { transform: scale(1.05); }
}
.result {
background: var(--surface);
border: 1px solid var(--border);
border-radius: 12px;
padding: 1.5rem;
margin: 1rem 0;
min-height: 80px;
}
.result-word {
font-size: 2rem;
font-weight: 300;
font-family: 'JetBrains Mono', monospace;
letter-spacing: 0.1em;
color: var(--accent);
}
.submit-btn {
background: var(--success);
color: white;
border: none;
padding: 1rem 2rem;
border-radius: 12px;
font-size: 1.1rem;
cursor: pointer;
margin-top: 1rem;
display: none;
}
.submit-btn:hover { opacity: 0.9; }
.submit-btn.show { display: inline-block; }
.status { margin-top: 1rem; font-size: 0.9rem; }
.status.error { color: var(--danger); }
.status.success { color: var(--success); }
.back { margin-top: 2rem; color: var(--accent); text-decoration: none; }
.info { font-size: 0.8rem; color: #8b949e; margin-top: 2rem; }
</style>
</head>
<body>
<div class="container">
<h1>🎤 Voice</h1>
<p class="subtitle">Say your word. No Git needed.</p>
<div class="notice">
📢 Audio is NOT stored. Only the transcribed word is submitted.<br>
A human will review before it joins the game.
</div>
<button class="record-btn" id="recordBtn">🎙️</button>
<p id="instruction">Tap to record</p>
<div class="result" id="result" style="display:none">
<small>Your word:</small>
<div class="result-word" id="wordResult"></div>
</div>
<button class="submit-btn" id="submitBtn">Submit Word</button>
<p class="status" id="status"></p>
<a href="index.html" class="back">← Back to game</a>
<p class="info">
Uses browser speech recognition. Works in Chrome, Edge, Safari.<br>
Your voice is processed locally, never uploaded.
</p>
</div>
<script>
const recordBtn = document.getElementById('recordBtn');
const instruction = document.getElementById('instruction');
const result = document.getElementById('result');
const wordResult = document.getElementById('wordResult');
const submitBtn = document.getElementById('submitBtn');
const status = document.getElementById('status');
let recognition = null;
let isRecording = false;
let transcribedWord = '';
// Check browser support
if (!('webkitSpeechRecognition' in window) && !('SpeechRecognition' in window)) {
instruction.textContent = '❌ Your browser does not support voice input';
recordBtn.disabled = true;
} else {
const SpeechRecognition = window.SpeechRecognition || window.webkitSpeechRecognition;
recognition = new SpeechRecognition();
recognition.continuous = false;
recognition.interimResults = false;
recognition.onresult = (event) => {
const transcript = event.results[0][0].transcript.trim();
// Take only first word
transcribedWord = transcript.split(' ')[0].toUpperCase();
result.style.display = 'block';
wordResult.textContent = transcribedWord;
submitBtn.classList.add('show');
instruction.textContent = 'Tap to record again';
};
recognition.onerror = (event) => {
status.textContent = '❌ ' + event.error;
status.className = 'status error';
stopRecording();
};
recognition.onend = () => {
stopRecording();
};
}
function startRecording() {
isRecording = true;
recordBtn.classList.add('recording');
recordBtn.textContent = '⏺️';
instruction.textContent = 'Listening...';
status.textContent = '';
recognition.start();
}
function stopRecording() {
isRecording = false;
recordBtn.classList.remove('recording');
recordBtn.textContent = '🎙️';
}
recordBtn.addEventListener('click', () => {
if (!recognition) return;
if (isRecording) {
recognition.stop();
} else {
startRecording();
}
});
submitBtn.addEventListener('click', async () => {
if (!transcribedWord) return;
submitBtn.disabled = true;
status.textContent = '⏳ Submitting...';
status.className = 'status';
// Create GitHub Issue via API (needs to be done via a backend or GitHub App)
// For now, redirect to create issue manually with pre-filled data
const issueTitle = `🎤 Voice: ${transcribedWord}`;
const issueBody = `## Voice Contribution
**Word:** ${transcribedWord}
---
*Submitted via voice input*
*Awaiting human approval*`;
const issueUrl = `https://github.com/fabriziosalmi/enjoy/issues/new?` +
`title=${encodeURIComponent(issueTitle)}` +
`&body=${encodeURIComponent(issueBody)}` +
`&labels=voice-contribution`;
window.location.href = issueUrl;
});
</script>
</body>
</html>