How to use the ibm-cloud-sdk-core.qs.stringify function in ibm-cloud-sdk-core

To help you get started, we’ve selected a few ibm-cloud-sdk-core examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github watson-developer-cloud / node-sdk / lib / recognize-stream.ts View on Github external
// 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',
github watson-developer-cloud / node-sdk / lib / synthesize-stream.ts View on Github external
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,