@@ -85,44 +85,52 @@ app.use(
85
85
var sttAuthService = new watson . AuthorizationV1 (
86
86
Object . assign (
87
87
{
88
- url : watson . SpeechToTextV1 . URL ,
89
88
username : process . env . SPEECH_TO_TEXT_USERNAME , // or hard-code credentials here
90
89
password : process . env . SPEECH_TO_TEXT_PASSWORD
91
90
} ,
92
91
vcapServices . getCredentials ( 'speech_to_text' ) // pulls credentials from environment in bluemix, otherwise returns {}
93
92
)
94
93
) ;
95
94
app . use ( '/api/speech-to-text/token' , function ( req , res ) {
96
- sttAuthService . getToken ( { } , function ( err , token ) {
97
- if ( err ) {
98
- console . log ( 'Error retrieving token: ' , err ) ;
99
- res . status ( 500 ) . send ( 'Error retrieving token' ) ;
100
- return ;
95
+ sttAuthService . getToken (
96
+ {
97
+ url : watson . SpeechToTextV1 . URL
98
+ } ,
99
+ function ( err , token ) {
100
+ if ( err ) {
101
+ console . log ( 'Error retrieving token: ' , err ) ;
102
+ res . status ( 500 ) . send ( 'Error retrieving token' ) ;
103
+ return ;
104
+ }
105
+ res . send ( token ) ;
101
106
}
102
- res . send ( token ) ;
103
- } ) ;
107
+ ) ;
104
108
} ) ;
105
109
106
110
// text to speech token endpoint
107
111
var ttsAuthService = new watson . AuthorizationV1 (
108
112
Object . assign (
109
113
{
110
- url : watson . TextToSpeechV1 . URL ,
111
114
username : process . env . TEXT_TO_SPEECH_USERNAME , // or hard-code credentials here
112
115
password : process . env . TEXT_TO_SPEECH_PASSWORD
113
116
} ,
114
117
vcapServices . getCredentials ( 'text_to_speech' ) // pulls credentials from environment in bluemix, otherwise returns {}
115
118
)
116
119
) ;
117
120
app . use ( '/api/text-to-speech/token' , function ( req , res ) {
118
- ttsAuthService . getToken ( { } , function ( err , token ) {
119
- if ( err ) {
120
- console . log ( 'Error retrieving token: ' , err ) ;
121
- res . status ( 500 ) . send ( 'Error retrieving token' ) ;
122
- return ;
121
+ ttsAuthService . getToken (
122
+ {
123
+ url : watson . TextToSpeechV1 . URL
124
+ } ,
125
+ function ( err , token ) {
126
+ if ( err ) {
127
+ console . log ( 'Error retrieving token: ' , err ) ;
128
+ res . status ( 500 ) . send ( 'Error retrieving token' ) ;
129
+ return ;
130
+ }
131
+ res . send ( token ) ;
123
132
}
124
- res . send ( token ) ;
125
- } ) ;
133
+ ) ;
126
134
} ) ;
127
135
128
136
const port = process . env . PORT || process . env . VCAP_APP_PORT || 3000 ;
0 commit comments