-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgoogle-tts.html
More file actions
130 lines (120 loc) · 6.1 KB
/
google-tts.html
File metadata and controls
130 lines (120 loc) · 6.1 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
<script type="text/javascript">
RED.nodes.registerType('google-tts',{
category: 'google',
color: '#F0F0F0',
defaults: {
name: {value:""},
inputField: {value: "payload", required: true},
inputFieldType: {value: "msg"},
outputField: {value: "payload", required: true},
outputFieldType: {value: "msg"},
languageField: {value: "en", required: true},
languageFieldType: {value: "str"},
speedField: {value: "1", required: true},
speedFieldType: {value: "num"},
},
inputs:1,
outputs:1,
icon: "feed.png",
label: function() {
return this.name||"google tts";
},
oneditprepare: function() {
if (!this.inputFieldType) {
this.inputFieldType = 'msg';
}
$("#node-input-inputField").typedInput({
default: 'msg',
types: ['msg','flow','global', 'str'],
typeField: $("#node-input-inputFieldType")
});
if (!this.outputFieldType) {
this.hashFieldType = 'msg';
}
$("#node-input-outputField").typedInput({
default: 'msg',
types: ['msg','flow','global'],
typeField: $("#node-input-outputFieldType")
});
$("#node-input-languageField").typedInput({
default: 'str',
types: ['str','msg','flow','global'],
typeField: $("#node-input-languageFieldType")
});
$("#node-input-speedField").typedInput({
default: 'num',
types: ['num','msg','flow','global'],
typeField: $("#node-input-speedFieldType")
});
}
});
</script>
<script type="text/x-red" data-template-name="google-tts">
<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-inputfield"><i class="fa fa-edit"></i> Input Property</label>
<input type="text" id="node-input-inputField" placeholder="Property containing text" style="width:250px;">
<input type="hidden" id="node-input-inputFieldType">
</div>
<div class="form-row">
<label for="node-input-outputField"><i class="fa fa-edit"></i> Output Property</label>
<input type="text" id="node-input-outputField" placeholder="Property to store speech URL" style="width:250px;">
<input type="hidden" id="node-input-outputFieldType">
</div>
<div class="form-row">
<label for="node-input-languageField"><i class="fa fa-edit"></i> Language Property</label>
<input type="text" id="node-input-languageField" placeholder="Property contain language code" style="width:250px;">
<input type="hidden" id="node-input-languageFieldType">
</div>
<div class="form-row">
<label for="node-input-speedField"><i class="fa fa-edit"></i> Speed Property</label>
<input type="text" id="node-input-speedField" placeholder="Property containing speed value" style="width:250px;">
<input type="hidden" id="node-input-speedFieldType">
</div>
</script>
<script type="text/x-red" data-help-name="google-tts">
<p>Translates text to speech using Google's TTS service.</p>
<h3>Properties</h3>
<dl class="message-properties">
<dt>name <span class="property-type">string</span></dt>
<dd> the node name to display in the editor. </dd>
<dt>input property <span class="property-type">property</span></dt>
<dd> the property containing the text to convert. </dd>
<dt>output property <span class="property-type">property</span></dt>
<dd> the property in which the result will be stored. </dd>
<dt>language property <span class="property-type">property</span></dt>
<dd> the property containing the language code for the voice. </dd>
<dt>speed property <span class="property-type">property</span></dt>
<dd> the property containing the speed for the voice. </dd>
</dl>
<h3>Input</h3>
<dl class="message-properties">
<dt><i>input property</i> <span class="property-type">object</span></dt>
<dd> the value to be converted to speech.</dd>
<dt><i>language property</i> <span class="property-type">string</span></dt>
<dd> the language code for the voice to be used.</dd>
<dt><i>speed property</i> <span class="property-type">number</span></dt>
<dd> a value between and 1 defining the speed of the speech.</dd>
</dl>
<h3>Output</h3>
<dl class="message-properties">
<dt><i>output property</i> <span class="property-type">string</span></dt>
<dd> the URL where the speech audio can be retrieved.</dd>
</dl>
The contents of input messages are passed through unchanged, except for the output property.
<h3>Details</h3>
<p>This node sends a string of text to Google's Text to Speech engine for it to be converted into
speech audio. The result returned is a URL that can be used to download the speech audio file in
MP3 format to be saved or played on a device or browser. The URL can be passed to the
<a href="https://www.npmjs.com/package/node-red-contrib-google-cast">node-red-contrib-google-cast</a>
to be played of Google Home and Chromecast devices.</p>
<p>Google's TTS service has an input string length limit of 200 characters. If the text to be translated is
greater than 200 characters, it will be intelligently broken into segments and the output will consist of
an array of URLs linking to sequential audio files encoding each segment.</p>
<p>The value in the <code>language property</code> defines the voice that will be used to speech audio.
It does not translate the text into that language. Supported code are listed in
<a href="https://cloud.google.com/speech/docs/languages">Google's supported language codes</a>.</p>
</script>