Speech service return error 1006

XDavidT 6 Reputation points
2022-01-10T21:03:06.687+00:00

Trying to use Speech service (TextToSpeech)
Getting error:

Unable to contact server. StatusCode: 1006, undefined Reason: getaddrinfo ENOTFOUND en-us.tts.speech.microsoft.com

The code I ran is:

const sdk = require("microsoft-cognitiveservices-speech-sdk");
const fs = require("fs");

function synthesizeSpeech() {
    const speechConfig = sdk.SpeechConfig.fromSubscription("348b6847f8ae46adb1116484514081f6", "en-US");
    const audioConfig = sdk.AudioConfig.fromAudioFileOutput("./path-to-file.wav");

    const synthesizer = new sdk.SpeechSynthesizer(speechConfig, audioConfig);
    console.log("starting")
    synthesizer.speakTextAsync(
        "this is a test.",
        result => {
            console.log("Start synthesizer")
            synthesizer.close();
            if (result) {
                // return result as stream
                return fs.createReadStream("./path-to-file.wav");
            }
            console.log(result.resultId);
            console.log(result.errorDetails)
        },
        error => {
            console.log(error);
            console.log(error);
            synthesizer.close();
        });
}

synthesizeSpeech();

Not sure what is wrong (my azure have billing and everything)

Azure AI Speech
Azure AI Speech
An Azure service that integrates speech processing into apps and services.
1,743 questions
{count} vote

1 answer

Sort by: Most helpful
  1. Ramr-msft 17,736 Reputation points
    2022-01-13T03:05:09.957+00:00

    @XDavidT Thanks for the details. The format for the endpoint is {region}.tts.speech.microsoft.com. "en-us" is a locale, not a region. Please use the valid regions include westus, northeurope, etc.

    Use
    const speechConfig = sdk.SpeechConfig.fromSubscription("<my-key>", "westus");

    for a westus key. For a list of regions see here.

    ------------------------------

    • Please don't forget to click on 130616-image.png or upvote 130671-image.png button whenever the information provided helps you. Original posters help the community find answers faster by identifying the correct answer. Here is how
    • Want a reminder to come back and check responses? Here is how to subscribe to a notification
    • If you are interested in joining the VM program and help shape the future of Q&A: Here is how you can be part of Q&A Volunteer Moderators
    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.