-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdemo.html
More file actions
78 lines (72 loc) · 3.15 KB
/
demo.html
File metadata and controls
78 lines (72 loc) · 3.15 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
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Text Reader Demo | Portable Embed</title>
<link rel="stylesheet" href="demo.css">
</head>
<body>
<header>
<p class="pill">Portable Demo</p>
<h1>Highlight text and click “Listen”.</h1>
<p class="muted">This page uses only the CSS in <code>demo.css</code>. The script injects its own button—no extra styles needed.</p>
</header>
<main>
<div class="card">
<h2>Why this demo?</h2>
<p class="muted">To show the text reader works on any site without shared classes or global CSS. The script inserts its own control and uses the Web Speech API.</p>
<ul>
<li>Namespaced classes and inline styles avoid collisions.</li>
<li>No external dependencies; it just works where SpeechSynthesis is available.</li>
<li>Preferences like language, rate, and pitch are configurable via <code>window.hwReaderConfig</code>.</li>
</ul>
</div>
<div class="grid">
<div class="card">
<h3>Embed it</h3>
<p class="muted">Copy <code>text-reader.js</code> to your project and include it with <code>defer</code> near the end of <code>body</code>.</p>
<pre><code><script src="/js/text-reader.js" defer></script></code></pre>
</div>
<div class="card">
<h3>Optional config</h3>
<p class="muted">Set language and voice options before loading:</p>
<pre><code><script>
window.hwReaderConfig = { lang: 'en-US', rate: 1, pitch: 1 };
</script>
<script src="/js/text-reader.js" defer></script></code></pre>
</div>
<div class="card">
<h3>API hooks</h3>
<p class="muted">After load, control it programmatically:</p>
<ul>
<li><code>hwReader.speak('text')</code></li>
<li><code>hwReader.cancel()</code></li>
</ul>
</div>
</div>
<div class="card">
<h2>Cloud TTS (optional)</h2>
<p class="muted">Use your own TTS service (e.g., cloud or GPU-backed) and fall back to browser speech if unavailable.</p>
<pre><code><script>
window.hwReaderConfig = {
lang: 'en-US',
ttsEndpoint: 'https://your-tts-endpoint',
ttsApiKey: 'YOUR_KEY',
ttsVoice: 'en-US'
};
</script>
<script src="/js/text-reader.js" defer></script></code></pre>
<p class="muted">If the endpoint/key is not set or fails, the script automatically uses the browser’s SpeechSynthesis.</p>
</div>
<div class="card">
<h2>Try it now</h2>
<p class="muted">Highlight any of this text and click “Listen” when the button appears at the bottom.</p>
</div>
</main>
<footer>
Built to be copied anywhere. No dependencies beyond this folder.
</footer>
<script src="text-reader.js" defer></script>
</body>
</html>