Skip to content

Commit

Permalink
fix: stabilize package by reverting to old recognize-stream class tha…
Browse files Browse the repository at this point in the history
…t includes iam bug fixes
  • Loading branch information
dpopp07 committed Mar 18, 2019
1 parent c1442b4 commit c3d835b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
4 changes: 2 additions & 2 deletions examples/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ var sttAuthService = new AuthorizationV1(
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
password: process.env.SPEECH_TO_TEXT_PASSWORD
// iam_apikey: process.env.SPEECH_TO_TEXT_IAM_APIKEY // if using an RC service
},
vcapServices.getCredentials('speech_to_text') // pulls credentials from environment in bluemix, otherwise returns {}
)
Expand Down
18 changes: 16 additions & 2 deletions speech-to-text/recognize-stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,15 @@ var OPENING_MESSAGE_PARAMS_ALLOWED = [
'speaker_labels'
];

var QUERY_PARAMS_ALLOWED = ['customization_id', 'acoustic_customization_id', 'model', 'watson-token', 'access_token', 'X-Watson-Learning-Opt-Out'];
var QUERY_PARAMS_ALLOWED = [
'language_customization_id',
'customization_id',
'acoustic_customization_id',
'model',
'watson-token',
'access_token',
'X-Watson-Learning-Opt-Out'
];

/**
* pipe()-able Node.js Duplex stream - accepts binary audio and emits text/objects in it's `data` events.
Expand Down Expand Up @@ -144,8 +152,14 @@ RecognizeStream.prototype.initialize = function() {
options['X-Watson-Learning-Opt-Out'] = options['X-WDC-PL-OPT-OUT'];
}

// compatibility code for the deprecated param, customization_id
if (options.customization_id && !options.language_customization_id) {
options.language_customization_id = options.customization_id;
delete options.customization_id;
}

var queryParams = util._extend(
'customization_id' in options ? pick(options, QUERY_PARAMS_ALLOWED) : { model: 'en-US_BroadbandModel' },
'language_customization_id' in options ? pick(options, QUERY_PARAMS_ALLOWED) : { model: 'en-US_BroadbandModel' },
pick(options, QUERY_PARAMS_ALLOWED)
);

Expand Down

0 comments on commit c3d835b

Please sign in to comment.