watson-developer-cloud
Version:
Client library to use the IBM Watson Services
76 lines (75 loc) • 3.73 kB
TypeScript
/**
* Copyright 2014 IBM Corp. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License
*/
/// <reference types="node" />
import { Readable } from 'stream';
interface SynthesizeStream extends Readable {
_readableState: any;
}
/**
* pipe()-able Node.js Readable stream - accepts text in the constructor and emits binary audio data in its 'message' events
*
* Cannot be instantiated directly, instead created by calling #synthesizeUsingWebSocket()
*
* Uses WebSockets under the hood.
* @param {Object} options
* @constructor
*/
declare class SynthesizeStream extends Readable {
static WEBSOCKET_CONNECTION_ERROR: string;
private options;
private socket;
private initialized;
private authenticated;
/**
* pipe()-able Node.js Readable stream - accepts text and emits binary audio data in its 'message' events
*
* Uses WebSockets under the hood.
*
*
* Note that the WebSocket connection is not established until the first chunk of data is recieved. This allows for IAM token request management by the SDK.
*
* @param {Object} options
* @param {String} options.text - The text that us to be synthesized. Provide plain text or text that is annotated with SSML. SSML input can include the SSML <mark> element. Pass a maximum of 5 KB of text.
* @param {String} options.accept - The requested audio format (MIME type) of the audio.
* @param {String[]} [options.timings] - An array that specifies whether the service is to return word timing information for all strings of the input text
* @param {String} [options.voice='en-US_MichaelVoice'] - The voice that is to be used for the synthesis.
* @param {String} [options.customization_id] - The customization ID (GUID) of a custom voice model that is to be used for the synthesis.
* @param {String} [options.url='wss://stream.watsonplatform.net/speech-to-text/api'] base URL for service
* @param {String} [options.watson-token] - Auth token
* @param {String} [options.access_token] - IAM auth token
* @param {Object} [options.headers] - Only works in Node.js, not in browsers. Allows for custom headers to be set, including an Authorization header (preventing the need for auth tokens)
* @param {Boolean} [options.x-watson-learning-opt-out=false] - set to true to opt-out of allowing Watson to use this request to improve it's services
* @param {String} [options.x-watson-metadata] - Associates a customer ID with data that is passed over the connection.
* @param {IamTokenManagerV1} [options.token_manager] - Token manager for authenticating with IAM
* @param {Boolean} [options.rejectUnauthorized] - If true, disable SSL verification for the WebSocket connection
*
* @constructor
*/
constructor(options: any);
initialize(): void;
_read(): void;
/**
* This function retrieves an IAM access token and stores it in the
* request header before calling the callback function, which will
* execute the next iteration of `_read()`
*
*
* @private
* @param {Function} callback
*/
setAuthorizationHeaderToken(callback: any): void;
}
export = SynthesizeStream;