Skip to content

Commit 17ab8b4

Browse files
authored
Merge pull request #232 from chughts/sttupdate
STT diarization support
2 parents 5ad5890 + 0ae2b75 commit 17ab8b4

File tree

7 files changed

+41
-24
lines changed

7 files changed

+41
-24
lines changed

README.md

+4
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ Node-RED Watson Nodes for IBM Bluemix
77

88
<a href="https://cla-assistant.io/watson-developer-cloud/node-red-node-watson"><img src="https://cla-assistant.io/readme/badge/watson-developer-cloud/node-red-node-watson" alt="CLA assistant" /></a>
99

10+
### New in version 0.4.32
11+
- Added diarization support to STT Node via the parameter speaker_labels
12+
- STT and TTS node use url based services utility to detect bound service.
13+
1014
### New in version 0.4.31
1115
- New V1 Query Builder Node for the Discovery Node
1216

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "node-red-node-watson",
3-
"version": "0.4.31",
3+
"version": "0.4.32",
44
"description": "A collection of Node-RED nodes for IBM Watson services",
55
"dependencies": {
66
"alchemy-api": "^1.3.0",

services/language_translator_identify/v2.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
</script>
3636

3737
<script type="text/x-red" data-help-name="watson-language-translator-identify">
38-
<p>Packaged in with release 0.4.31 of node-red-node-watson</p>
38+
<p>Packaged in with release 0.4.32 of node-red-node-watson</p>
3939
<p>The Watson Language Translator service can be used to identify languages used in a text input. <p>
4040
<p>Node input : </p>
4141
<ul>

services/speech_to_text/v1.html

+12
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,12 @@
6262
<input type="checkbox" id="node-input-continuous"></input>
6363
</select>
6464
</div>
65+
<div class="form-row">
66+
<label for="node-input-speakerlabels"><i class="fa fa-audio-o"></i> Speaker Labels</label>
67+
<input type="checkbox" id="node-input-speakerlabels"></input>
68+
</select>
69+
</div>
70+
6571

6672
</script>
6773

@@ -82,6 +88,8 @@
8288
source sampling rates, <b>Narrowband (8KHz) and Broadband (16Khz)</b>. Higher sample rates will be downsampled
8389
automatically but the is not true in reverse.</p>
8490
<p>Use the continuous property to choose whether the decoding should stop at the first pause or wait until the end of the file.</p>
91+
<p>Use the speaker label property to identify which individuals spoke which words in a multi-participant exchange.
92+
</p>
8593
<p>The returned audio transcription will be returned on <code>msg.transcription</code>.</p>
8694
<p>The full response, including alternative transcriptions can be found on
8795
<code>msg.fullresult</code>.</p>
@@ -126,6 +134,7 @@
126134
$('#credentials-not-found').show();
127135
$('label#node-label-message').parent().hide();
128136
$('input#node-input-continuous').parent().hide();
137+
$('input#node-input-speakerlabels').parent().hide();
129138
$('select#node-input-lang').parent().hide();
130139
$('select#node-input-band').parent().hide();
131140
}
@@ -137,11 +146,13 @@
137146
if (stt.models) {
138147
$('label#node-label-message').parent().hide();
139148
$('input#node-input-continuous').parent().show();
149+
$('input#node-input-speakerlabels').parent().show();
140150
$('select#node-input-lang').parent().show();
141151
$('select#node-input-band').parent().show();
142152
} else {
143153
$('label#node-label-message').parent().hide();
144154
$('input#node-input-continuous').parent().hide();
155+
$('input#node-input-speakerlabels').parent().hide();
145156
$('select#node-input-lang').parent().hide();
146157
$('select#node-input-band').parent().hide();
147158
}
@@ -323,6 +334,7 @@
323334
defaults: {
324335
name: {value: ''},
325336
continuous: {value: true},
337+
speakerlabels: {value: true},
326338
lang: {value: ''},
327339
langhidden: {value: ''},
328340
band: {value: ''},

services/speech_to_text/v1.js

+12-11
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,16 @@
1515
**/
1616

1717
module.exports = function (RED) {
18-
var request = require('request');
19-
var cfenv = require('cfenv');
20-
var temp = require('temp');
21-
var url = require('url');
22-
var fs = require('fs');
23-
var fileType = require('file-type');
24-
//var watson = require('watson-developer-cloud');
25-
var sttV1 = require('watson-developer-cloud/speech-to-text/v1');
26-
27-
var service = cfenv.getAppEnv().getServiceCreds(/speech to text/i);
18+
const SERVICE_IDENTIFIER = 'speech-to-text';
19+
var request = require('request'),
20+
cfenv = require('cfenv'),
21+
temp = require('temp'),
22+
url = require('url'),
23+
fs = require('fs'),
24+
fileType = require('file-type'),
25+
serviceutils = require('../../utilities/service-utils'),
26+
sttV1 = require('watson-developer-cloud/speech-to-text/v1'),
27+
service = serviceutils.getServiceCreds(SERVICE_IDENTIFIER);
2828

2929
// Require the Cloud Foundry Module to pull credentials from bound service
3030
// If they are found then the username and password will be stored in
@@ -174,7 +174,8 @@ module.exports = function (RED) {
174174
audio: audio,
175175
content_type: 'audio/' + format,
176176
model: model,
177-
continuous: config.continuous
177+
continuous: config.continuous ? config.continuous : false,
178+
speaker_labels: config.speakerlabels ? config.speakerlabels : false
178179
};
179180

180181
node.status({fill:'blue', shape:'dot', text:'requesting'});

services/text_to_speech/v1.html

+1
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@
9393
'de-DE': 'German',
9494
'zh-CN': 'Mandarin',
9595
'es-ES': 'Spanish',
96+
'es-LA': 'Latin American Spanish',
9697
'es-US': 'US Spanish',
9798
'ar-AR': 'Arablic',
9899
'ja-JP': 'Japanese'

services/text_to_speech/v1.js

+10-11
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,10 @@
1515
**/
1616

1717
module.exports = function(RED) {
18+
const SERVICE_IDENTIFIER = 'text-to-speech';
1819
var cfenv = require('cfenv');
19-
var watson = require('watson-developer-cloud');
20+
var TextToSpeechV1 = require('watson-developer-cloud/text-to-speech/v1');
21+
var serviceutils = require('../../utilities/service-utils');
2022

2123
// Require the Cloud Foundry Module to pull credentials from bound service
2224
// If they are found then the username and password will be stored in
@@ -30,7 +32,8 @@ module.exports = function(RED) {
3032

3133
var username, password, sUsername, sPassword;
3234

33-
var service = cfenv.getAppEnv().getServiceCreds(/text to speech/i)
35+
//var service = cfenv.getAppEnv().getServiceCreds(/text to speech/i)
36+
var service = serviceutils.getServiceCreds(SERVICE_IDENTIFIER);
3437

3538
if (service) {
3639
sUsername = service.username;
@@ -44,11 +47,9 @@ module.exports = function(RED) {
4447

4548
// API used by widget to fetch available models
4649
RED.httpAdmin.get('/watson-text-to-speech/voices', function (req, res) {
47-
var tts = watson.text_to_speech({
50+
var tts = new TextToSpeechV1({
4851
username: sUsername ? sUsername : req.query.un,
49-
password: sPassword ? sPassword : req.query.pwd,
50-
version: 'v1',
51-
url: 'https://stream.watsonplatform.net/text-to-speech/api'
52+
password: sPassword ? sPassword : req.query.pwd
5253
});
5354

5455
tts.voices({}, function(err, voices){
@@ -75,19 +76,17 @@ module.exports = function(RED) {
7576
}
7677

7778
username = sUsername || this.credentials.username;
78-
password = sPassword || this.credentials.password || config.password;
79+
password = sPassword || this.credentials.password || config.password;
7980

8081
if (!username || !password) {
8182
var message = 'Missing Speech To Text service credentials';
8283
node.error(message, msg);
8384
return;
8485
}
8586

86-
var text_to_speech = watson.text_to_speech({
87+
var text_to_speech = new TextToSpeechV1({
8788
username: username,
88-
password: password,
89-
version: 'v1',
90-
url: 'https://stream.watsonplatform.net/text-to-speech/api'
89+
password: password
9190
});
9291

9392
var params = {

0 commit comments

Comments
 (0)