Created
July 19, 2019 10:33
-
-
Save antirek/8f81097bef058b258248960ed40a6716 to your computer and use it in GitHub Desktop.
Yandex Cloud SpeechKit (TTS) Example on Node.js - Пример работы с API технологии синтеза речи Yandex Cloud SpeechKit
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fetch = require('node-fetch'); | |
const api_key = 'API_KEY'; | |
const { URLSearchParams } = require('url'); | |
const fs = require('fs'); | |
const params = new URLSearchParams(); | |
const text = 'Добрый день, у нас новая акция! Пицца Добряк сегодня за полцены, закажите по телефону 222. Уже ждем вашего заказа :) ' | |
params.append('text', text); | |
params.append('voice', 'zahar'); | |
params.append('emotion', 'good'); | |
params.append('lang', 'ru-RU'); | |
params.append('speed', '1.0'); | |
params.append('format', 'oggopus'); | |
fetch('https://tts.api.cloud.yandex.net/speech/v1/tts:synthesize', { | |
method: 'post', | |
body: params, | |
headers: { | |
// 'Content-Type': 'application/x-www-form-urlencoded', | |
'Authorization': 'Api-Key ' + api_key, | |
}, | |
}) | |
.then(res => { | |
console.log(res); | |
// return res.json(); | |
const dest = fs.createWriteStream('./octocat.ogg'); | |
res.body.pipe(dest); | |
}) | |
.catch(err => console.error(err)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
То-же самое можно провернуть и через axios