Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// process query params
const queryParamsAllowed: string[] = [
'access_token',
'watson-token',
'model',
'language_customization_id',
'acoustic_customization_id',
'base_model_version',
'x-watson-learning-opt-out',
'x-watson-metadata',
];
const queryParams = processUserParameters(options, queryParamsAllowed);
if (!queryParams.language_customization_id && !queryParams.model) {
queryParams.model = 'en-US_BroadbandModel';
}
const queryString = qs.stringify(queryParams);
// synthesize the url
const url =
(options.url || 'wss://stream.watsonplatform.net/speech-to-text/api'
).replace(/^http/, 'ws') +
'/v1/recognize?' +
queryString;
// process opening payload params
const openingMessageParamsAllowed: string[] = [
'customization_weight',
'processing_metrics',
'processing_metrics_interval',
'audio_metrics',
'inactivity_timeout',
'timestamps',
initialize() {
const options = this.options;
// process query params
const queryParamsAllowed = [
'access_token',
'watson-token',
'voice',
'customization_id',
'x-watson-learning-opt-out',
'x-watson-metadata',
];
const queryParams = processUserParameters(options, queryParamsAllowed);
const queryString = qs.stringify(queryParams);
// synthesize the url
const url =
(options.url || 'wss://stream.watsonplatform.net/text-to-speech/api')
.replace(/^http/, 'ws') +
'/v1/synthesize?' +
queryString;
// add custom agent in the request options if given by user
// default request options to null
const { agent } = options;
const requestOptions: RequestOptions = agent ? { agent } : null;
const socket = (this.socket = new w3cWebSocket(
url,
null,