How to use the microsoft-cognitiveservices-speech-sdk.SpeechSynthesisOutputFormat function in microsoft-cognitiveservices-speech-sdk

To help you get started, we’ve selected a few microsoft-cognitiveservices-speech-sdk examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Azure-Samples / cognitive-services-speech-sdk / samples / js / node / synthesis.js View on Github external
main: function(settings, filename) {

        // now create the audio-config pointing to the output file.
        // You can also use audio output stream to initialize the audio config, see the docs for details.
        var audioConfig = sdk.AudioConfig.fromAudioFileOutput(filename);
        var speechConfig = sdk.SpeechConfig.fromSubscription(settings.subscriptionKey, settings.serviceRegion);

        // setting the synthesis language, voice name, and output audio format.
        // see https://aka.ms/speech/tts-languages for available languages and voices
        speechConfig.speechSynthesisLanguage = settings.language;
        speechConfig.speechSynthesisVoiceName = "en-US-AriaRUS";
        speechConfig.speechSynthesisOutputFormat = sdk.SpeechSynthesisOutputFormat.Audio16Khz32KBitRateMonoMp3;

        var rl = readline.createInterface({
            input: process.stdin,
            output: process.stdout
        });

        // create the speech synthesizer.
        var synthesizer = new sdk.SpeechSynthesizer(speechConfig, audioConfig);

        // Before beginning speech synthesis, setup the callbacks to be invoked when an event occurs.

        // The event synthesizing signals that a synthesized audio chunk is received.
        // You will receive one or more synthesizing events as a speech phrase is synthesized.
        // You can use this callback to streaming receive the synthesized audio.
        synthesizer.synthesizing = function (s, e) {
            var str = "(synthesizing) Reason: " + sdk.ResultReason[e.result.reason] + " Audio chunk length: " + e.result.audioData.byteLength;