UNPKG

umbot

Version:

Universal bot(vk, telegram, viber) or skills for Yandex.Alisa, Маруся and sber

48 lines (47 loc) 1.84 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.VkSound = void 0; const utils_1 = require("../../../utils"); const SoundTokens_1 = require("../../../models/SoundTokens"); const YandexSpeechKit_1 = require("../../../api/YandexSpeechKit"); class VkSound { async getSounds(sounds, text = '') { const data = []; if (sounds) { for (let i = 0; i < sounds.length; i++) { const sound = sounds[i]; if (sound) { if (typeof sound.sounds !== 'undefined' && typeof sound.key !== 'undefined') { let sText = utils_1.Text.getText(sound.sounds); if ((0, utils_1.isFile)(sText) || utils_1.Text.isUrl(sText)) { const sModel = new SoundTokens_1.SoundTokens(); sModel.type = SoundTokens_1.SoundTokens.T_VK; sModel.path = sText; sText = await sModel.getToken(); } if (sText) { data.push(sText); } } } } } if (text) { const speechKit = new YandexSpeechKit_1.YandexSpeechKit(); const content = await speechKit.getTts(text); let sText = null; if (content) { const sModel = new SoundTokens_1.SoundTokens(); sModel.type = SoundTokens_1.SoundTokens.T_VK; sModel.isAttachContent = true; sModel.path = content; sText = await sModel.getToken(); } if (sText) { data.push(sText); } } return data; } } exports.VkSound = VkSound;