UNPKG

@vonage/voice

Version:

The Voice API lets you create outbound calls, control in-progress calls and get information about historical calls.

107 lines 3 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Talk = void 0; const enums_1 = require("../../enums"); /** * Represents a Talk action in a Nexmo Call Control Object (NCCO). * * This action allows the text-to-speech (TTS) synthesis of spoken words in the call. */ class Talk { /** * The action type for this NCCO action. */ action = enums_1.NCCOActions.TALK; /** * The text to be spoken during the call. */ text; /** * Indicates whether the talk action allows barge-in (optional). */ bargeIn; /** * The number of times to loop the speech (optional). */ loop; /** * The audio level at which to play the speech (optional). */ level; /** * The language for the text-to-speech synthesis (optional). */ language; /** * The speech style (optional). */ style; /** * Indicates whether to use premium text-to-speech (optional). */ premium; /** * Creates a new Talk action. * * @param {string} text - The text to be spoken during the call. * @param {boolean} [bargeIn] - Indicates whether the talk action allows barge-in (optional). * @param {number} [loop] - The number of times to loop the speech (optional). * @param {string} [level] - The audio level at which to play the speech (optional). * @param {TTSLanguages | string} [language] - The language for the text-to-speech synthesis (optional). * @param {string} [style] - The speech style (optional). * @param {boolean} [premium] - Indicates whether to use premium text-to-speech (optional). */ constructor(text, bargeIn, loop, level, language, style, premium) { this.text = text; if (bargeIn) { this.bargeIn = bargeIn; } if (loop) { this.loop = loop; } if (level) { this.level = level; } if (language) { this.language = language; } if (style) { this.style = style; } if (premium) { this.premium = premium; } } /** * Serializes the Talk action to a Nexmo Call Control Object (NCCO). * * @return {TalkAction} - The serialized Talk action. */ serializeToNCCO() { const data = { action: enums_1.NCCOActions.TALK, text: this.text, }; if (this.loop) { data.loop = this.loop; } if (this.bargeIn) { data.bargeIn = this.bargeIn; } if (this.level) { data.level = this.level; } if (this.language) { data.language = this.language; } if (this.style) { data.style = this.style; } if (this.premium) { data.premium = this.premium; } return data; } } exports.Talk = Talk; //# sourceMappingURL=Talk.js.map