-
Notifications
You must be signed in to change notification settings - Fork 4
/
wavenet.html
260 lines (245 loc) · 12 KB
/
wavenet.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
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
<script type="text/javascript">
RED.nodes.registerType('wavenet', {
category: 'advanced',
color: '#7BCFA9',
defaults: {
name: { value: "Wavenet" },
key: { value: "", type: "wavenet-config" },
voice: { value: "random" },
rate: { value: "1.0" },
pitch: {
value: 0,
validate: function (p) {
if (p <= 20 && p >= -20) {
return true;
} else {
return false;
}
}
},
volume: {
value: 0,
validate: function (v) {
if (v <= 10 && v >= -10) {
return true;
} else {
return false;
}
}
},
sample: { value: 24000 },
encoding: { value: 'MP3' }
},
inputs: 1,
outputs: 1,
icon: "feed.png",
label: function () {
return this.voice || "wavenet";
},
oneditprepare: function() {
$("#node-input-voice").val(this.voice || "random");
$("#node-input-rate").val(this.rate || "1.0");
$("#node-input-pitch").val(this.pitch || 0);
$("#node-input-volume").val(this.volume || 0);
$("#node-input-sample").val(this.sample || 24000);
$("#node-input-encoding").val(this.encoding || 'MP3');
}
});
</script>
<script type="text/javascript">
RED.nodes.registerType('wavenet-config', {
category: 'config',
defaults: {
speech_api: { value: "", required: true }
},
// label: 'Google Speech API Key',
label: function () {
return 'Google Speech API Key - ' + this.speech_api.substr(0, 5);
}
});
</script>
<script type="text/x-red" data-template-name="wavenet">
<div class="form-row">
<label for="node-input-name"><i class="icon-tag"></i>Name</label>
<input type="text" id="node-input-name" placeholder="Name">
</div>
<div class="form-row">
<label for="node-input-key"><i class="icon-tag"></i>API Key</label>
<input type="text" id="node-input-key" placeholder="API Key">
<h6><p>Sign in to <a href="https://cloud.google.com/text-to-speech/">Google Developer Console</a> to get a Speech API key.</p></h6>
</div>
<div class="form-row">
<label for="node-input-voice"><i class="icon-tag"></i>Voice</label>
<select id="node-input-voice">
<option value='random' selected>Random</option>
<option value='mathew'>Mathew (American male)</option>
<option value='justin'>Justin (American male)</option>
<option value='joanna'>Joanna (American female)</option>
<option value='ivy'>Ivy (American female)</option>
<option value='kimberly'>Kimberly (American female)</option>
<option value='salli'>Salli (American female)</option>
<option value='amina'>Amina (Arabian female)</option>
<option value='amir'>Amir (Arabian male)</option>
<option value='russel'>Russel (Australian male)</option>
<option value='thomas'>Thomas (Australian male)</option>
<option value='nicole'>Nicole (Australian female)</option>
<option value='mary'>Mary (Australian female)</option>
<option value='brian'>Brian (British male)</option>
<option value='emma'>Emma (British female)</option>
<option value='amy'>Amy (British female)</option>
<option value='chen'>Chen (Chinese Mandarin female)</option>
<option value='chang'>Chang (Chinese Mandarin male)</option>
<option value='hu'>Hu (Chinese Mandarin male)</option>
<option value='mei'>Mei (Chinese Mandarin female)</option>
<option value='lucie'>Lucie (Czech female)</option>
<option value='anne'>Anne (Danish female)</option>
<option value='lucas'>Lucas (Danish male)</option>
<option value='janjaap'>Janjaap (Dutch male)</option>
<option value='kees'>Kees (Dutch male)</option>
<option value='sjaan'>Sjaan (Dutch female)</option>
<option value='bep'>Bep (Dutch female)</option>
<option value='miep'>Miep (Dutch female)</option>
<option value='ella'>Ella (Finnish female)</option>
<option value='sofia'>Sofia (German female)</option>
<option value='ben'>Ben (German male)</option>
<option value='lyra'>Lyra (Greek female)</option>
<option value='aparna'>Aparna (Inidan female)</option>
<option value='rahul'>Rahul (Indian male)</option>
<option value='darna'>Darna (Filippino female)</option>
<option value='olivia'>Olivia (French Canadian female)</option>
<option value='liam'>Liam (French Canadian male)</option>
<option value='sarah'>Sarah (French female)</option>
<option value='victor'>Victor (French male)</option>
<option value='simran'>Simran (Hindi female)</option>
<option value='jai'>Jai (Hindi male)</option>
<option value='nora'>Nora (Hungarian female)</option>
<option value='melati'>Melati (Indonesian female)</option>
<option value='agung'>Agung (Indonesian male)</option>
<option value='gabriella'>Gabriella (Italian female)</option>
<option value='antonio'>Antonio (Italian male)</option>
<option value='yuna'>Yuna (Japanese female)</option>
<option value='asahi'>Asahi (Japanese male)</option>
<option value='misun'>Misun (Korean female)</option>
<option value='kyong'>Kyong (Korean male)</option>
<option value='leah'>Leah (Norwegian female)</option>
<option value='lucas'>Lucas (Norwegian male)</option>
<option value='amelia'>Amelia (Polish female)</option>
<option value='filip'>Filip (Polish male)</option>
<option value='maria'>Maria (Portugese female)</option>
<option value='tomas'>Tomas (Portugese male)</option>
<option value='nadia'>Nadia (Russian female)</option>
<option value='anatoly'>Anatoly (Russian male)</option>
<option value='laura'>Laura (Slovak female)</option>
<option value='lilly'>Lilly (Swedish female)</option>
<option value='defne'>Defne (Turkish female)</option>
<option value='yusuf'>Yusuf (Turkish male)</option>
<option value='alina'>Alina (Ukranian female)</option>
<option value='bian'>Bian (Vietnamese female)</option>
<option value='danh'>Danh (Vietnamese male)</option>
</select>
</div>
<div class="form-row">
<label for="node-input-rate"><i class="icon-tag"></i>Speaking rate</label>
<select id="node-input-rate">
<option value=0.25>0.25</option>
<option value=0.50>0.50</option>
<option value=0.75>0.75</option>
<option value=1.0 selected>1.0</option>
<option value=1.25>1.25</option>
<option value=1.50>1.50</option>
<option value=1.75>1.75</option>
<option value=2.0>2.0</option>
<option value=2.25>2.25</option>
<option value=2.50>2.50</option>
<option value=2.75>2.75</option>
<option value=3.0>3.0</option>
<option value=3.25>3.25</option>
<option value=3.50>3.50</option>
<option value=3.75>3.75</option>
<option value=4.0>4.0</option>
</select>
</div>
<div class="form-row">
<label for="node-input-pitch"><i class="icon-tag"></i>Pitch</label>
<input type="number" value=0 id="node-input-pitch">
</div>
<div class="form-row">
<label for="node-input-volume"><i class="icon-tag"></i>Volume gain</label>
<input type="number" value=0 id="node-input-volume">
</div>
<div class="form-row">
<label for="node-input-sample"><i class="icon-tag"></i>Sample rate (Hz)</label>
<input type="number" id="node-input-sample" value="24000" placeholder="sample rate (Hz)">
</div>
<div class="form-row">
<label for="node-input-encoding"><i class="icon-tag"></i>Audio encoding</label>
<select id="node-input-encoding">
<option value='MP3' selected>MP3</option>
<option value='LINEAR16'>LINEAR16</option>
<option value='OGG_OPUS'>OGG_OPUS</option>
</select>
</div>
<div>
<h6><p>Learn more about audio config options <a href="https://cloud.google.com/text-to-speech/docs/reference/rest/v1/text/synthesize">here</a></p></h6>
</div>
</script>
<script type="text/x-red" data-template-name="wavenet-config">
<div class="form-row">
<label for="node-config-input-speech_api"><i class="icon-bookmark"></i> API Key</label>
<input type="text" id="node-config-input-speech_api">
</div>
</script>
<script type="text/x-red" data-help-name="wavenet">
<h2>Convert text to speech using Google Wavenet voice.</h2>
<br>
<p>
Wavenet voice represents a new way of creating synthetic speech, using a <strong>WaveNet</strong> model, the same technology used to produce speech for Google Assistant, Google Search and Google Translate.
</p>
<br>
Takes a <code>string</code> as an input. Returns a <code>base64</code> encoded array buffer. Attach a file node to save it as an audio on your disk.
<br>
<img src="https://raw.githubusercontent.com/balsimpson/node-red-contrib-wavenet/master/wavenet_screenshot.png" alt="main flow">
<br>
#### Sign in to <a href="https://cloud.google.com/text-to-speech/">Google Developer Console</a> to get a Speech API key.
<h3>Inputs</h3>
<dl class="message-properties">
<dt>payload
<span class="property-type">string</span>
</dt>
<dd> Use SSML in your text string to give it more personality. You can use all SSML elements mentioned <a href="https://cloud.google.com/text-to-speech/docs/reference/rest/v1/text/synthesize">here.</a></dd>
<dt>voice
<span class="property-type">string</span>
</dt>
<dd> Choose a specific voice or random</dd>
<dt>Speaking rate
<span class="property-type">number | 0.25 to 4.0</span>
</dt>
<dd> In the range of 0.25 to 4.0. 1.0 is the normal native speed. 2.0 is twice as fast, and 0.5 is half as fast.</dd>
<dt>Pitch
<span class="property-type">number | -20 to +20</span>
</dt>
<dd> In the range -20.0 to 20.0. 20 means increase 20 semitones from the original pitch. -20 means decrease 20 semitones from the original pitch.</dd>
<dt>Volume
<span class="property-type">number | -6 to +6</span>
</dt>
<dd> A value of -6.0 (dB) will play at approximately half the amplitude and a value of +6.0 (dB) will play at approximately twice the amplitude of the normal native signal.</dd>
<dt>Sample rate
<span class="property-type">number</span>
</dt>
<dd> The synthesis sample rate (in hertz). When this is specified, the synthesizer will honor this request by converting to the desired sample rate. Default is 24000.</dd>
<dt>Audio encoding
<span class="property-type">string</span>
</dt>
<dd> The encoding format of the audio byte stream can be MP3, LINEAR16 or OGG_OPUS</dd>
</dl>
<h3>Outputs</h3>
<ol class="node-ports">
<li>Standard output
<dl class="message-properties">
<dt>payload <span class="property-type">string | base64</span></dt>
<dd> A base64-encoded string that is wrapped in containers according to the encoding specified.
</dd>
</dl>
</li>
</ol>
</script>