-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
362 lines (340 loc) · 18 KB
/
Copy pathindex.html
File metadata and controls
362 lines (340 loc) · 18 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
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
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Digital Human Studio — Avatar Lip Sync & TTS</title>
<link rel="stylesheet" href="css/styles.css?v=2" />
</head>
<body>
<header class="topbar">
<div class="brand">
<span class="dot"></span>
<h1>Digital Human Studio</h1>
<span class="tag">avatar · TTS · lip sync</span>
</div>
<div class="topbar-actions">
<span id="engineBadge" class="badge badge-local">Local engine</span>
<button id="btnHelp" class="ghost">Help</button>
</div>
</header>
<main class="layout">
<!-- ───────────────────────── LEFT: inputs ───────────────────────── -->
<section class="panel" id="panelInputs">
<h2>1 · Avatar</h2>
<label class="dropzone" id="avatarDrop">
<input type="file" id="avatarFile" accept="image/*" hidden />
<div class="dz-inner">
<strong>Drop a portrait</strong>
<span>PNG / JPG · front-facing works best</span>
</div>
</label>
<div class="samples">
<span class="samples-label">or try a sample</span>
<div class="sample-row">
<button class="sample" data-sample="woman-neutral" title="Neutral portrait">
<img src="samples/thumb-woman-neutral.jpg" alt="Woman, neutral expression" />
</button>
<button class="sample" data-sample="man-glasses" title="Studio headshot">
<img src="samples/thumb-man-glasses.jpg" alt="Man with glasses" />
</button>
<button class="sample" data-sample="man-headshot" title="Headshot">
<img src="samples/thumb-man-headshot.jpg" alt="Man, headshot" />
</button>
</div>
</div>
<div class="row">
<button id="btnEditFace" class="secondary" disabled>Adjust mouth & eyes</button>
<button id="btnAutoFace" class="secondary" disabled>Auto-detect</button>
</div>
<p class="hint" id="faceHint">Drop a photo anywhere on the page. The face is detected automatically; a closed-mouth, front-facing portrait works best.</p>
<h2>2 · Script</h2>
<textarea id="script" rows="7" placeholder="Type or paste what your avatar should say…">Hello, and welcome to Digital Human Studio. Upload a portrait, paste a script, and watch me speak it back with synchronised lips.</textarea>
<div class="row between">
<label class="file-inline">
<input type="file" id="scriptFile" accept=".txt,.md,text/plain" hidden />
<span>Load .txt</span>
</label>
<span class="hint" id="scriptStats">0 words · ~0s</span>
</div>
<div class="row">
<button id="btnDraft" class="secondary" title="Turn whatever is in the box into a spoken script, using your local Ollama model">
✦ Draft with Ollama
</button>
<input type="text" id="ollamaModel" value="gemma4" aria-label="Ollama model" />
</div>
<p class="hint">Runs against your local Ollama. Gemma <b>writes</b> the script — it can't speak it; no local LLM can. Pick a voice engine below for that.</p>
<h2>3 · Voice</h2>
<div class="field">
<label for="ttsEngine">Engine</label>
<select id="ttsEngine">
<option value="browser">Browser TTS (offline, free)</option>
<option value="piper">Piper / local server</option>
<option value="gemini">Gemini TTS (API key)</option>
<option value="elevenlabs">ElevenLabs (API key)</option>
<option value="openai">OpenAI TTS (API key)</option>
<option value="upload">Use my own audio file</option>
</select>
</div>
<div class="engine-pane" data-engine="browser">
<div class="field">
<label for="voice">Voice</label>
<select id="voice"></select>
</div>
<div class="field-grid">
<div class="field"><label for="rate">Rate <b id="rateVal">1.00</b></label>
<input type="range" id="rate" min="0.5" max="2" step="0.05" value="1" /></div>
<div class="field"><label for="pitch">Pitch <b id="pitchVal">1.00</b></label>
<input type="range" id="pitch" min="0" max="2" step="0.05" value="1" /></div>
</div>
<p class="hint">Offline and instant, but browsers won't let us capture its audio — use it for preview. For <b>video export</b> pick any other engine.</p>
</div>
<div class="engine-pane" data-engine="piper" hidden>
<div class="field">
<label for="piperUrl">Piper HTTP endpoint</label>
<input type="text" id="piperUrl" value="http://localhost:5000" />
</div>
<div class="field">
<label for="piperVoice">Voice model</label>
<input type="text" id="piperVoice" value="en_US-amy-medium" />
</div>
<p class="hint">Runs fully offline. See README for the one-line Piper server.</p>
</div>
<div class="engine-pane" data-engine="gemini" hidden>
<div class="field">
<label for="gmKey">API key <span class="hint-inline">aistudio.google.com → Get API key</span></label>
<input type="password" id="gmKey" placeholder="AIza…" />
</div>
<div class="field">
<label for="gmVoice">Voice</label>
<select id="gmVoice">
<optgroup label="Female">
<option value="Kore">Kore — firm</option>
<option value="Zephyr">Zephyr — bright</option>
<option value="Leda">Leda — youthful</option>
<option value="Aoede">Aoede — breezy</option>
<option value="Callirrhoe">Callirrhoe — easy-going</option>
<option value="Despina">Despina — smooth</option>
<option value="Erinome">Erinome — clear</option>
<option value="Laomedeia">Laomedeia — upbeat</option>
<option value="Achernar">Achernar — soft</option>
<option value="Gacrux">Gacrux — mature</option>
<option value="Sulafat">Sulafat — warm</option>
<option value="Vindemiatrix">Vindemiatrix — gentle</option>
</optgroup>
<optgroup label="Male">
<option value="Puck">Puck — upbeat</option>
<option value="Charon">Charon — informative</option>
<option value="Fenrir">Fenrir — excitable</option>
<option value="Orus">Orus — firm</option>
<option value="Enceladus">Enceladus — breathy</option>
<option value="Iapetus">Iapetus — clear</option>
<option value="Umbriel">Umbriel — easy-going</option>
<option value="Algieba">Algieba — smooth</option>
<option value="Algenib">Algenib — gravelly</option>
<option value="Rasalgethi">Rasalgethi — informative</option>
<option value="Achird">Achird — friendly</option>
<option value="Schedar">Schedar — even</option>
</optgroup>
</select>
</div>
<div class="row">
<button id="btnPreviewGm" class="secondary">▶ Preview voice</button>
</div>
<p class="hint">Recordable, so video export works. Gender grouping is approximate — Google doesn't label these formally, so preview before you commit. Gemini <b>cannot clone</b> a voice; switch to ElevenLabs for that.</p>
</div>
<div class="engine-pane" data-engine="elevenlabs" hidden>
<div class="field"><label for="elKey">API key</label><input type="password" id="elKey" placeholder="sk_…" /></div>
<div class="field">
<label for="elPreset">Voice</label>
<select id="elPreset">
<optgroup label="Female">
<option value="21m00Tcm4TlvDq8ikWAM">Rachel — calm narration</option>
<option value="EXAVITQu4vr4xnSDxMaL">Sarah — soft news</option>
<option value="AZnzlk1XvdvUeBnXmlld">Domi — strong</option>
<option value="MF3mGyEYCl7XYWbV9V6O">Elli — young</option>
</optgroup>
<optgroup label="Male">
<option value="pNInz6obpgDQGcFmaJgB">Adam — deep</option>
<option value="ErXwobaYiN019PkySvjV">Antoni — warm</option>
<option value="TxGEqnHWrfWFTfGW9XjX">Josh — young</option>
<option value="VR6AewLTigWG4xSOukaG">Arnold — crisp</option>
</optgroup>
<optgroup label="Custom">
<option value="custom">Cloned / custom voice ID…</option>
</optgroup>
</select>
</div>
<div class="field" id="elCustomField" hidden>
<label for="elVoice">Voice ID</label>
<input type="text" id="elVoice" value="21m00Tcm4TlvDq8ikWAM" />
</div>
<div class="row"><button id="btnPreviewEl" class="secondary">▶ Preview voice</button></div>
<p class="hint">Routed through the local Python server, so the key never touches a third party beyond ElevenLabs. Leave it blank to use <code>ELEVENLABS_API_KEY</code> from <code>.env</code>.</p>
<details class="clone" id="clonePanel">
<summary>Clone a voice from a video or audio clip</summary>
<label class="dropzone small" id="cloneDrop">
<input type="file" id="cloneFile" accept="video/*,audio/*" hidden />
<div class="dz-inner">
<strong>Drop a clip</strong>
<span>MP4 / MOV / MP3 / WAV · ~1 minute of clean speech</span>
</div>
</label>
<div class="field">
<label for="cloneName">Voice name</label>
<input type="text" id="cloneName" placeholder="e.g. My narrator" />
</div>
<button id="btnClone" class="secondary" disabled>Clone voice</button>
<div id="cloneStatus" class="status" hidden></div>
<p class="hint">
Video is fine — the audio track is extracted locally with ffmpeg, then only that audio is sent to
ElevenLabs, which returns a voice ID and fills it in above. <b>Only clone a voice you own or have
explicit permission to use.</b>
</p>
</details>
</div>
<div class="engine-pane" data-engine="openai" hidden>
<div class="field"><label for="oaKey">API key</label><input type="password" id="oaKey" placeholder="sk-…" /></div>
<div class="field">
<label for="oaVoice">Voice</label>
<select id="oaVoice">
<option>alloy</option><option>echo</option><option>fable</option>
<option>onyx</option><option>nova</option><option>shimmer</option>
</select>
</div>
</div>
<div class="engine-pane" data-engine="upload" hidden>
<label class="dropzone small" id="audioDrop">
<input type="file" id="audioFile" accept="audio/*" hidden />
<div class="dz-inner"><strong>Drop an audio file</strong><span>MP3 / WAV / M4A</span></div>
</label>
<p class="hint">The script is still used — it drives which mouth shapes appear; the audio drives when.</p>
</div>
<h2>4 · Lip sync</h2>
<div class="field">
<label for="lipEngine">Renderer</label>
<select id="lipEngine">
<option value="local">Live preview — in-browser, instant, free (drawn mouth)</option>
<option value="wav2lip">Wav2Lip — local, fastest (~16s), soft mouth</option>
<option value="musetalk">MuseTalk — local, photoreal (~75s), needs a GPU</option>
<option value="heygen">HeyGen — cloud, moves the head, costs credits</option>
</select>
</div>
<p class="hint">
<b>Live preview</b> is instant and free, but the mouth is drawn geometry — good for timing a script.
The other three render a real video: <b>Wav2Lip</b> (local, fastest, but the mouth is a 96×96 model
upscaled, so it is soft at 1080p), <b>MuseTalk</b> (local, generates real mouth pixels — teeth, lips,
shadow — but needs a GPU and ~75s), and <b>HeyGen</b> (cloud, the only one that also moves the head
and blinks, and the only one that costs credits). Pick one, then press <b>Render video</b>.
</p>
<div class="engine-pane" data-lip="local">
<div class="field-grid">
<div class="field"><label>Mouth openness <b id="gainVal">1.00</b></label>
<input type="range" id="gain" min="0.3" max="2" step="0.05" value="1" /></div>
<div class="field"><label>Smoothing <b id="smoothVal">0.55</b></label>
<input type="range" id="smooth" min="0" max="0.9" step="0.05" value="0.55" /></div>
</div>
<div class="checks">
<label><input type="checkbox" id="optFrame" checked /> Frame to head</label>
<label><input type="checkbox" id="optSway" checked /> Head motion</label>
<label><input type="checkbox" id="optBreath" checked /> Breathing</label>
<label><input type="checkbox" id="optDebug" /> Show rig</label>
</div>
<p class="hint">“Frame to head” crops the stage to a portrait around the rig — leave it on for full-body or group photos.</p>
</div>
<div class="engine-pane" data-lip="heygen" hidden>
<div class="field"><label for="hgKey">HeyGen API key</label><input type="password" id="hgKey" placeholder="Paste key" /></div>
<div class="field">
<label for="hgAvatar">Avatar <span class="hint-inline">from your HeyGen account</span></label>
<select id="hgAvatar"><option value="">Loading…</option></select>
</div>
<div class="field">
<label for="hgVoice">Voice</label>
<select id="hgVoice"><option value="">Loading…</option></select>
</div>
<div class="row">
<button id="btnHgUpload" class="secondary" disabled>Upload my portrait as an avatar</button>
</div>
<p class="hint">
Renders on HeyGen's servers (v3) and <b>costs credits</b>. It animates the head and
blinks, which MuseTalk doesn't — but MuseTalk is free, local, and keeps your photo
on your machine. HeyGen caps photo avatars per plan, so uploading may be refused.
</p>
<div id="hgStatus" class="status" hidden></div>
</div>
</section>
<!-- ───────────────────────── RIGHT: stage ───────────────────────── -->
<section class="stage">
<div class="stage-canvas" id="stageWrap">
<canvas id="stage" width="720" height="900"></canvas>
<video id="hgVideo" playsinline hidden></video>
<div class="stage-empty" id="stageEmpty">
<p>Your avatar appears here</p>
</div>
<div class="viseme-readout" id="visemeReadout" hidden><span>—</span></div>
</div>
<div class="transport">
<button id="btnSpeak" class="primary" disabled title="Play the script in the browser preview (instant, drawn mouth)">▶ Start Speaking</button>
<button id="btnStop" class="secondary" disabled>■ Stop</button>
<button id="btnRender" class="secondary" disabled title="Saves the browser preview as a video — NOT the selected engine.">⬇ Export preview</button>
<button id="btnPhotoreal" class="accent" disabled title="Renders a real video with the engine chosen in the Renderer dropdown">
✨ Render video
</button>
<label class="loop-toggle" title="Replay the rendered video when it reaches the end">
<input type="checkbox" id="loopVideo" /> Loop
</label>
<div class="spacer"></div>
<div class="meter"><div class="meter-fill" id="meterFill"></div></div>
</div>
<p><button id="btnGetWeights" class="secondary" hidden></button></p>
<p class="statusline" id="engineNote" style="margin:.4rem 0 0;opacity:.75">Start Speaking plays the instant browser preview — the mouth is drawn geometry, not a real render.</p>
<!-- Wav2Lip/MuseTalk report real percentages; HeyGen only says processing/completed,
so its bar is an elapsed-time estimate that stops at 95%. -->
<div class="render-prog" id="renderProg" hidden>
<div class="rp-head">
<span id="rpLabel">Rendering…</span>
<span id="rpPct">0%</span>
</div>
<div class="rp-track"><div class="rp-fill" id="rpFill"></div></div>
</div>
<div class="scrub">
<input type="range" id="scrubber" min="0" max="1000" value="0" step="1" disabled />
<span class="time" id="timeLabel">0:00 / 0:00</span>
</div>
<p class="statusline" id="statusLine">Ready.</p>
</section>
</main>
<dialog id="faceDialog">
<form method="dialog">
<h3>Align the rig</h3>
<p class="hint">Drag the handles onto the mouth corners and the eyes. Scroll to zoom, drag the photo to pan — useful when the face is small in the frame. Everything else is derived from these four points.</p>
<div class="face-editor"><canvas id="faceCanvas"></canvas></div>
<div class="row end">
<button value="cancel" class="secondary">Cancel</button>
<button value="ok" class="primary">Save rig</button>
</div>
</form>
</dialog>
<dialog id="helpDialog">
<form method="dialog">
<h3>How it works</h3>
<ul class="help">
<li><b>Local engine</b> — your script is converted to phonemes, phonemes to visemes (mouth shapes), and the timeline is stretched onto the real audio. Live loudness modulates jaw drop, so pauses actually close the mouth. Nothing leaves your machine.</li>
<li><b>Export</b> — Browser TTS audio can't be captured by the page, so exporting needs Piper, ElevenLabs, OpenAI, or an uploaded audio file.</li>
<li><b>Render photoreal</b> — hands the shot to <b>MuseTalk</b>, a neural model that generates real mouth pixels on your own machine (~1 min). This is the one to use for anything you'd actually show someone.</li>
<li><b>HeyGen</b> — renders in the cloud and costs credits, but it's the only engine that also moves the head and blinks.</li>
</ul>
<div class="row end"><button value="ok" class="primary">Got it</button></div>
</form>
</dialog>
<footer class="site-footer">
<p class="powered-by">Powered by <a href="https://www.tertiaryinfotech.com/" target="_blank" rel="noopener">Tertiary Infotech Academy Pte Ltd</a></p>
</footer>
<script src="js/visemes.js?v=2"></script>
<script src="js/face.js?v=2"></script>
<script src="js/renderer.js?v=2"></script>
<script src="js/tts.js?v=2"></script>
<script src="js/heygen.js?v=2"></script>
<script src="js/app.js?v=2"></script>
</body>
</html>