1515 **/
1616
1717module . 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 ( / t e x t t o s p e e c h / 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