2

I run a flask server in which this function is called whenever an specific action occurs on the page :

def generate_audio(text, target):
    # create the path
    tmp_dir = os.path.join(os.getcwd(), "app/data/audio")
    if not os.path.exists(tmp_dir):
        os.mkdir(tmp_dir)
    path = os.path.join(tmp_dir, f'{target}-{text}.wav')

    # query the API
    speech_config = SpeechConfig(
        subscription=cfg['speech']['key'], region=cfg['speech']['location'])
    audio_config = AudioOutputConfig(filename=path)
    synthesizer = SpeechSynthesizer(
        speech_config=speech_config, audio_config=audio_config)
    synthesizer.speak_text("A simple test")

At the end of the execution, the file containing the audio is just an empty 0B file. I literally copy pasted the quick start guide, so I do not know what is wrong.

What I did try is to change the subscription key to something random and no error was raised. In the logs from the azure service webpage nothing comes up either.

Here's the cancellation details

SpeechSynthesisCancellationDetails(reason=CancellationReason.Error, error_details="Connection failed (no connection to the remote host). Internal error: 11. Error details: Code: 0. USP state: 2. Received audio size: 0 bytes.")

Here's the log

https://pastebin.com/aapsMXYc

truvaking
  • 347
  • 2
  • 10
  • it seems the problem could have been with the location. i changed from switzerland north to france central and now it works flawlessly. – truvaking Dec 27 '20 at 14:30

1 Answers1

1

I was also facing the same issue and found that I was entering incorrect location name. E.g. in resource, you will see a location name like Central India but in SDK it should be entered as centralindia (this name I found under key management). Hope this will help in resolving this issue.

Thanks

Gautam Gupta
  • 525
  • 1
  • 4
  • 5