Forked from antirek/yandex-cloud-speechkit-tts-nodejs.js
Created
December 28, 2020 21:17
-
-
Save invincible/bc0a2d61d43f66ce6059210968fc4c9e 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