You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<p>For more information about the Speech To Text service, read the <ahref="https://www.ibm.com/smarterplanet/us/en/ibmwatson/developercloud/speech-to-text.html">documentation</a>.</p>
80
90
</script>
81
91
82
92
<scripttype="text/javascript">
93
+
varmodels=null;
94
+
varlanguages=null;
95
+
varbands=null;
96
+
97
+
varlanguage_selected='';
98
+
varband_selected='';
99
+
100
+
varLANGUAGES={'en-US' : 'US English',
101
+
'pt-BR': 'Portuguese Braziilian',
102
+
'en-UK': 'UK English',
103
+
'zh-CN': 'Mandarin',
104
+
'es-ES': 'Spanish',
105
+
'ar-AR': 'Arablic',
106
+
'ja-JP': 'Japanese'
107
+
};
108
+
109
+
110
+
// sorting functions
111
+
functiononlyUnique(value,index,self){
112
+
returnself.indexOf(value)===index;
113
+
}
114
+
115
+
// Function to be used at the start, as don't want to expose any fields, unless the models are
116
+
// available. The models can only be fetched if the credentials are available.
117
+
functionhideEverything(){
118
+
if(!models){
119
+
$('#credentials-not-found').show();
120
+
$('label#node-label-message').parent().hide();
121
+
$('input#node-input-continuous').parent().hide();
122
+
$('select#node-input-lang').parent().hide();
123
+
$('select#node-input-band').parent().hide();
124
+
}
125
+
}
126
+
127
+
// Check if there is a model then can show the fields.
128
+
// available. The models can only be fetched if the credentials are available.
129
+
functionvisibilityCheck(){
130
+
if(models){
131
+
$('label#node-label-message').parent().hide();
132
+
$('input#node-input-continuous').parent().show();
133
+
$('select#node-input-lang').parent().show();
134
+
$('select#node-input-band').parent().show();
135
+
}else{
136
+
$('label#node-label-message').parent().hide();
137
+
$('input#node-input-continuous').parent().hide();
138
+
$('select#node-input-lang').parent().hide();
139
+
$('select#node-input-band').parent().hide();
140
+
}
141
+
}
142
+
143
+
144
+
// Simple check that is only invoked if the service is not bound into bluemix. In this case the
145
+
// user has to provide credentials. Once there are credentials, then the models are retrieved.
146
+
functioncheckCredentials(){
147
+
varu=$('#node-input-username').val();
148
+
varp=$('#node-input-password').val();
149
+
150
+
if(u&&u.length&&p){
151
+
if(!models){
152
+
getModels();
153
+
}
154
+
}
155
+
}
156
+
157
+
// Populate the quality select field
158
+
functionpopulateBands(){
159
+
if(!bands&&models){
160
+
bands=models.map(function(m){
161
+
returnm.name.split('_')[1];
162
+
});
163
+
varunique_bands=bands.filter(onlyUnique);
164
+
bands=unique_bands;
165
+
}
166
+
167
+
if(bands){
168
+
$('select#node-input-band').empty();
169
+
170
+
bands.forEach(function(b){
171
+
varselectedText='';
172
+
if(band_selected===b){
173
+
selectedText='selected="selected"';
174
+
}
175
+
$('select#node-input-band')
176
+
.append('<option value='
177
+
+'"'+b+'"'
178
+
+selectedText
179
+
+'>'
180
+
+b
181
+
+'</option>');
182
+
});
183
+
}
184
+
}
185
+
186
+
// Register the handlers for the fields
187
+
functionhandlersUI(){
188
+
$('#node-input-username').change(function(val){
189
+
checkCredentials();
190
+
});
191
+
$('#node-input-password').change(function(val){
192
+
checkCredentials();
193
+
});
194
+
195
+
$('#node-input-lang').change(function(val){
196
+
language_selected=$('#node-input-lang').val();
197
+
populateBands();
198
+
});
199
+
200
+
$('#node-input-band').change(function(val){
201
+
band_selected=$('#node-input-band').val();
202
+
});
203
+
}
204
+
205
+
// Function called when either when the models have been retrieved, or
206
+
// on dialog load, if the model has already been retrieved
207
+
functionpostModelCheck(){
208
+
processModels();
209
+
visibilityCheck();
210
+
}
211
+
212
+
// Retrieve the available models from the server, if data is returned, then
0 commit comments