Created
April 7, 2022 17:58
-
-
Save met/0f831681374097087fbb5ffe04668037 to your computer and use it in GitHub Desktop.
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
// Using example from https://github.com/Azure-Samples/cognitive-services-speech-sdk | |
function generujZvuk(lang, voice, outputText, outputFilename) { | |
// <code> | |
"use strict"; | |
// pull in the required packages. | |
var sdk = require("microsoft-cognitiveservices-speech-sdk"); | |
var readline = require("readline"); | |
// replace with your own subscription key, | |
// service region (e.g., "westus"), and | |
// the name of the file you save the synthesized audio. | |
var subscriptionKey = "----YOUR SECRET HERE----"; | |
var serviceRegion = "germanywestcentral"; // e.g., "westus" | |
var filename = outputFilename; | |
// we are done with the setup | |
// now create the audio-config pointing to our stream and | |
// the speech config specifying the language. | |
var audioConfig = sdk.AudioConfig.fromAudioFileOutput(filename); | |
var speechConfig = sdk.SpeechConfig.fromSubscription(subscriptionKey, serviceRegion); | |
speechConfig.speechSynthesisOutputFormat = sdk.SpeechSynthesisOutputFormat.Audio16Khz32KBitRateMonoMp3; | |
speechConfig.speechSynthesisLanguage = lang; | |
speechConfig.speechSynthesisVoiceName = voice; | |
// create the speech synthesizer. | |
var synthesizer = new sdk.SpeechSynthesizer(speechConfig, audioConfig); | |
// start the synthesizer and wait for a result. | |
synthesizer.speakTextAsync(outputText, | |
function (result) { | |
if (result.reason === sdk.ResultReason.SynthesizingAudioCompleted) { | |
console.log("synthesis finished."); | |
} else { | |
console.error("Speech synthesis canceled, " + result.errorDetails + | |
"\nDid you update the subscription info?"); | |
} | |
synthesizer.close(); | |
synthesizer = undefined; | |
}, | |
function (err) { | |
console.trace("err - " + err); | |
synthesizer.close(); | |
synthesizer = undefined; | |
}); | |
console.log("Now synthesizing to: " + filename); | |
} | |
/* | |
https://docs.microsoft.com/en-us/azure/cognitive-services/speech-service/language-support?tabs=speechtotext#text-to-speech | |
cs-CZ-VlastaNeural | |
cs-CZ-AntoninNeural | |
uk-UA-PolinaNeural | |
uk-UA-OstapNeural | |
sk-SK-ViktoriaNeural | |
sk-SK-LukasNeural | |
pl-PL-AgnieszkaNeural | |
pl-PL-MarekNeural | |
--pl-PL-ZofiaNeural | |
*/ | |
/* | |
generujZvuk("cs-CZ", "cs-CZ-VlastaNeural", "Ahoj! Jak se máš?", "filename-1.mp3"); | |
generujZvuk("cs-CZ", "cs-CZ-AntoninNeural", "Ahoj! Dobře. Už jsi slyšela o tom projektu, co dělají v Česko Digitál?", "filename-2.mp3"); | |
generujZvuk("cs-CZ", "cs-CZ-VlastaNeural", "Ne, co je zač?", "filename-3.mp3"); | |
generujZvuk("cs-CZ", "cs-CZ-AntoninNeural", "Jmenuje se Movapp.cz a mužeš se s ním učit ukrajinsky.", "filename-4.mp3"); | |
*/ | |
/* | |
generujZvuk("uk-UA", "uk-UA-PolinaNeural", "Привіт! Як справи?", "filename-1.mp3"); | |
generujZvuk("uk-UA", "uk-UA-OstapNeural", "Привіт! добре. Ви чули про проект, який вони виконують у Czech Digital?", "filename-2.mp3"); | |
generujZvuk("uk-UA", "uk-UA-PolinaNeural", "Ні, що це?", "filename-3.mp3"); | |
generujZvuk("uk-UA", "uk-UA-OstapNeural", "Його звуть Movapp.cz і з ним ви можете вивчати українську мову.", "filename-4.mp3"); | |
*/ | |
/* | |
generujZvuk("sk-SK", "sk-SK-ViktoriaNeural", "Ahoj! Ako sa máš?", "sk-filename-1.mp3"); | |
generujZvuk("sk-SK", "sk-SK-LukasNeural", "Ahoj! Dobre. Už si počula o tom projekte, čo robia v Česko Digitál?", "sk-filename-2.mp3"); | |
generujZvuk("sk-SK", "sk-SK-ViktoriaNeural", "Nie, čo je zač?", "sk-filename-3.mp3"); | |
generujZvuk("sk-SK", "sk-SK-LukasNeural", "Volá sa Movapp.cz a môžeš sa s ním učiť po ukrajinsky.", "sk-filename-4.mp3"); | |
*/ | |
generujZvuk("pl-PL", "pl-PL-AgnieszkaNeural", "Hej! Jak się masz?", "pl-filename-1.mp3"); | |
generujZvuk("pl-PL", "pl-PL-MarekNeural", "Hej! Dobry. Czy słyszałeś o projekcie, który realizują w Czech Digital?", "pl-filename-2.mp3"); | |
generujZvuk("pl-PL", "pl-PL-AgnieszkaNeural", "Nie, co to jest?", "pl-filename-3.mp3"); | |
generujZvuk("pl-PL", "pl-PL-MarekNeural", "Nazywa się Movapp.cz i możesz uczyć się z nim ukraińskiego.", "pl-filename-4.mp3"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment