This commit is contained in:
Renato Pfeiler committed 2024-07-31 22:55:42 +02:00
commit 0d963e1826
20 files changed
+396

No files matched your search

+50
View File
@@ -0,0 +1,50 @@
(async function() {
"use strict";
// Dynamically import the Microsoft Cognitive Services Speech SDK
const sdk = await import("microsoft-cognitiveservices-speech-sdk");
const readline = require("readline");
const audioFile = "YourAudioFile.wav";
const speechConfig = sdk.SpeechConfig.fromSubscription("c0d12660f15c4869bf2572fda3cb91ab", "germanywestcentral");
const audioConfig = sdk.AudioConfig.fromAudioFileOutput(audioFile);
// Configure the voice name and language
const voiceName = "de-AT-IngridNeural";
const language = "de-AT";
// Create the speech synthesizer
var synthesizer = new sdk.SpeechSynthesizer(speechConfig, audioConfig);
var rl = readline.createInterface({
input: process.stdin,
output: process.stdout
});
rl.question("Enter text with break tags >\n> ", function (userInput) {
rl.close();
// Construct the SSML string
const ssml = `<speak version="1.0" xmlns="http://www.w3.org/2001/10/synthesis" xml:lang="${language}"><voice name="${voiceName}">${userInput}</voice></speak>`;
// Start the synthesizer and wait for a result
synthesizer.speakSsmlAsync(ssml,
function (result) {
if (result.reason === sdk.ResultReason.SynthesizingAudioCompleted) {
console.log("Synthesis finished.");
} else {
console.error("Speech synthesis canceled, " + result.errorDetails +
"\nDid you set the speech resource key and region values?");
}
synthesizer.close();
synthesizer = null;
},
function (err) {
console.trace("Error - " + err);
synthesizer.close();
synthesizer = null;
});
console.log("Now synthesizing to: " + audioFile);
});
})();