Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
);
// set up webpack-dev-middleware to serve Webpack bundles for examples
const compiler = webpack(webpackConfig);
app.use(
webpackDevMiddleware(compiler, {
publicPath: '/' // Same as `output.publicPath` in most cases.
})
);
const sttCredentials = Object.assign(
{
username: process.env.SPEECH_TO_TEXT_USERNAME, // or hard-code credentials here
password: process.env.SPEECH_TO_TEXT_PASSWORD,
iam_apikey: process.env.SPEECH_TO_TEXT_IAM_APIKEY, // if using an RC service
url: process.env.SPEECH_TO_TEXT_URL ? process.env.SPEECH_TO_TEXT_URL : SpeechToTextV1.URL
},
vcapServices.getCredentials('speech_to_text') // pulls credentials from environment in bluemix, otherwise returns {}
);
// speech to text token endpoint
app.use('/api/speech-to-text/token', function(req, res) {
const sttAuthService = new AuthorizationV1(sttCredentials);
sttAuthService.getToken(function(err, response) {
if (err) {
console.log('Error retrieving token: ', err);
res.status(500).send('Error retrieving token');
return;
}
const token = response.token || response;
if (process.env.SPEECH_TO_TEXT_IAM_APIKEY) {
res.json({ accessToken: token, url: sttCredentials.url });