forked from discordier/sam
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
92 lines (90 loc) · 2.99 KB
/
index.html
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
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>SAM: Software Automatic Mouth</title>
<style>
body {
max-width: 12cm;
margin: 0 auto;
font-family: sans-serif;
}
h1, h2 {
text-align: center;
}
label, input {
display: inline-block;
}
label { width: 30%}
input { width: 60%}
input[type="submit"] { width: 100%;}
input[type="range"] { transform: rotate(180deg);}
</style>
</head>
<body>
<h1> SAM Software Automatic Mouth</h1>
<h2>What is SAM?</h2>
<p>
Sam is a very small Text-To-Speech (TTS) program written in Javascript,
that runs on most popular platforms. It is an adaption to Javascript of
the speech software SAM (Software Automatic Mouth) for the Commodore
C64 published in the year 1982 by Don't Ask Software
(now SoftVoice, Inc.). It includes a Text-To-Phoneme converter called
reciter and a Phoneme-To-Speech routine for the final output.
</p>
<p>
Currently compatible with Firefox, Chrome, Safari + iOS.
The conversion was done by hand from the C source code by
<a href="https://github.com/s-macke/SAM">Sebastian Macke</a>,
and the refactored versions by
<a href="https://github.com/vidarh/SAM">Vidar Hokstad</a> and
<a href="https://github.com/8BitPimp/SAM">8BitPimp</a>
</p>
<script src="dist/samjs.js"></script>
<script>
opts = {
debug: 1,
pitch: 64,
speed: 72,
mouth: 128,
throat: 128
};
document.addEventListener('DOMContentLoaded', function() {
['speed', 'pitch', 'mouth', 'throat'].forEach(
(name) => {
var e = document.getElementById(name);
e.onchange = function (e) {
opts[e.target.id] = e.target.value;
document.getElementById(e.target.id + '-lbl').innerText =
e.target.id.charAt(0).toUpperCase() + e.target.id.substr(1) + ': ' + e.target.value;
};
e.value = opts[name];
}
);
var speech;
document.getElementById('playground').addEventListener('submit', function (e) {
e.preventDefault();
var sam = new SamJs(opts);
if (speech) speech.abort();
speech = sam.speak(this.textfield.value);
speech.catch(() => {});
});
});
</script>
<hr>
<form id="playground">
<div>
<label for="speechinput">Text to speak:</label>
<input size="60" id="speechinput" name="textfield" value="Hello, my name is SAM.">
<hr>
<label id="pitch-lbl" for="pitch">Pitch: </label><input type="range" id="pitch" min="0" max="255" value="0" />
<label id="speed-lbl" for="speed">Speed: </label><input type="range" id="speed" min="1" max="255" value="0" />
<label id="mouth-lbl" for="mouth">Mouth: </label><input type="range" id="mouth" min="0" max="255" value="0" />
<label id="throat-lbl" for="throat">Throat: </label><input type="range" id="throat" min="0" max="255" value="0" />
<input type="submit" name="Text 1" value="Say">
</div>
</form>
<hr>
<a href="https://github.com/discordier/sam">Github Repository with the source code</a>
</body>
</html>