-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmultipartExample.html
More file actions
121 lines (98 loc) · 3.87 KB
/
Copy pathmultipartExample.html
File metadata and controls
121 lines (98 loc) · 3.87 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>meSpeak.js — Multipart Example</title>
<script type="text/javascript" src="mespeak.js"></script>
<script type="text/javascript">
meSpeak.loadConfig("mespeak_config.json");
meSpeak.loadVoice("voices/en/en-us.json");
meSpeak.loadVoice("voices/fr.json");
var parts = [
{ text: "Travel to", voice: "en/en-us", variant: "m3" },
{ text: "Paris", voice: "fr", variant: "f5" },
{ text: "at light speed", voice: "en/en-us", variant: "m3" }
];
function speakIt() {
// called by button
meSpeak.speakMultipart(parts);
}
function speakItWithDefaults() {
// called by button
meSpeak.speakMultipart(parts, {pitch: 35, speed: 160});
}
</script>
<style type="text/css">
body {max-width: 1000px; }
h3 { margin-top: 2em; }
form p
{
margin-top: 0.5em;
margin-bottom: 0.5em;
}
p.codesample
{
margin: 1em 0;
padding: 1em 0 1em 2em;
white-space: pre;
font-family: monospace;
line-height: 120%;
background-color: #f2f2f2;
}
p.codesample strong { color: #111; }
p.action { margin: 1em 0 1em 1.5em; }
</style>
</head>
<body>
<h1>meSpeak.js — Multipart Example</h1>
<p>This is an example for mixing multiple parts into a single utterance using <tt>meSpeak.speakMultipart()</tt>.</p>
<p>We will speak the text <em>"Travel to Paris at light speed."</em> using a female French voice for the word "Paris".</p>
<p>For this, we break up the sentence in multiple parts, each part representing a continous text to be spoken by a voice. Each part is an object, containing the text to be spoken and any options to be applied.</p>
<p class="action">Try it: <button onclick="speakIt();">Speak It</button></p>
<p class="codesample">
meSpeak.loadConfig("mespeak_config.json");
meSpeak.loadVoice("voices/en/en-us.json");
meSpeak.loadVoice("voices/fr.json");
var parts = [
{ text: "Travel to", voice: "en/en-us", variant: "m3" },
{ text: "Paris", voice: "fr", variant: "f5" },
{ text: "at light speed", voice: "en/en-us", variant: "m3" }
];
function speakIt() {
// called by button
meSpeak.speakMultipart(parts);
}
</p>
<p>We even may provide any options to be applied as defaults to the individual parts.<br />
(You may apply any options valid for <tt>meSpeak.speak()</tt>.)</p>
<p class="codesample">
function speakItWithDefaults() {
// called by button
meSpeak.speakMultipart(parts, {pitch: 35, speed: 160});
}
</p>
<p class="action">Try it: <button onclick="speakItWithDefaults();">Speak It</button></p>
<p> </p>
<h2>Syntax</h2>
<p>The general form of <tt>meSpeak.speakMultipart()</tt> is analogous to <tt>meSpeak.speak()</tt>, but with an array of objects (the parts to be spoken) as the first argument (rather than a single text):</p>
<p class="codesample">
<strong>meSpeak.speakMultipart(</strong> <parts-array> [, <options-object> [, <callback-function> ]] <strong>)</strong>;
<strong>meSpeak.speakMultipart(</strong>
[
{ text: "text-1", <other options> ] },
{ text: "text-2", <other options> ] },
...
{ text: "text-n", <other options> ] },
],
{ option1: value1, option2: value2 .. },
callback
<strong>)</strong>;
</p>
<p>Only the the first argument is mandatory, any further arguments are optional.<br />
The <em>parts-array</em> must contain a single element (of type object) at least.<br />
For any other options refer to <tt>meSpeak.speak()</tt>.<br />
The method returns — like <tt>meSpeak.speak()</tt> — either an ID, or, if called with the <tt>"rawdata"</tt> option (in the general options / second argument), a stream-buffer representing the generated wav-file.</p>
<p> </p>
<p>N. Landsteiner, 2014</p>
</body>
</html>