UNPKG

@vonage/voice

Version:

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

126 lines (124 loc) 3.38 kB
"use strict"; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __hasOwnProp = Object.prototype.hasOwnProperty; var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); // lib/classes/NCCO/Talk.ts var Talk_exports = {}; __export(Talk_exports, { Talk: () => Talk }); module.exports = __toCommonJS(Talk_exports); var Talk = class { /** * The action type for this NCCO action. */ action = "talk" /* 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: "talk" /* 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; } }; // Annotate the CommonJS export names for ESM import in node: 0 && (module.exports = { Talk });