TTS always gets me back: "Failed to initialize platform (azure-c-shared). Error: 2153"

Geronimo Tutusaus 10 Reputation points
2023-11-06T17:31:10.5066667+00:00

Problem

I get the following error "Runtime error: Failed to initialize platform (azure-c-shared). Error: 2153" when trying to execute the following python line

speech_synthesizer = speechsdk.SpeechSynthesizer(speech_config=speech_config, audio_config=audio_config)

Here's the whole snippet code. I am trying basically to do simply text-to-speech.

speech_synthesizer = speechsdk.SpeechSynthesizer(speech_config=speech_config, audio_config=audio_config)
    ```

Here's the whole snippet code. **I am trying basically to do simply text-to-speech.**


```python
subscription_key = 'xxxxxxxxxxxxxx' 
region = 'eastus'

#https://eastus.api.cognitive.microsoft.com/sts/v1.0/issuetoken


def text_to_speech(text, language, output_file, speech_rate):
    speech_config = speechsdk.SpeechConfig(subscription=subscription_key, region=region)

    audio_config = speechsdk.audio.AudioOutputConfig(filename=output_file)
    speech_synthesizer = speechsdk.SpeechSynthesizer(speech_config=speech_config, audio_config=audio_config)

    ssml = f"""
    <speak version="1.0" xmlns="http://www.w3.org/2001/10/synthesis" xml:lang="{language}">
        <voice name="es-UY-MateoNeural">
            <prosody rate="{speech_rate}">{text}</prosody>
        </voice>
    </speak>
    """

    result = speech_synthesizer.speak_ssml_async(ssml).get()

    if result.reason == speechsdk.ResultReason.SynthesizingAudioCompleted:
        print(f'Speech synthesized successfully and saved to {output_file}.')
    elif result.reason == speechsdk.ResultReason.Canceled:
        cancellation_details = result.cancellation_details
        print(f'Speech synthesis canceled: {cancellation_details.reason}')
        if cancellation_details.reason == speechsdk.CancellationReason.Error:
            print(f'Error details: {cancellation_details.error_details}')

Solutions tried

I tried using the code shared by the Azure portal, but I got the same problem:

speech_config = speechsdk.SpeechConfig(subscription=speech_key, region=service_region)
# Note: the voice setting will not overwrite the voice element in input SSML.
speech_config.speech_synthesis_voice_name = "es-UY-MateoNeural"

text = "Hola, soy Mateo"

# use the default speaker as audio output.
speech_synthesizer = speechsdk.SpeechSynthesizer(speech_config=speech_config)

result = speech_synthesizer.speak_text_async(text).get()
# Check result
if result.reason == speechsdk.ResultReason.SynthesizingAudioCompleted:
    print("Speech synthesized for text [{}]".format(text))
elif result.reason == speechsdk.ResultReason.Canceled:
    cancellation_details = result.cancellation_details
    print("Speech synthesis canceled: {}".format(cancellation_details.reason))
    if cancellation_details.reason == speechsdk.CancellationReason.Error:
        print("Error details: {}".format(cancellation_details.error_details))

I tried other ways, but I always got a barrier like

HTTPError: 400 Client Error: Unexpected end of file has occurred. The following elements are not closed: prosody, voice, speak. Line 5, position 4976. for url: https://eastus.tts.speech.microsoft.com/cognitiveservices/v1

Context

Take into mind that the Version 1.32.1 was installed

import azure.cognitiveservices.speech as speechsdk 

FYI, I can get the access token in several ways. Here's one:

!curl -v -X POST "https://eastus.api.cognitive.microsoft.com/sts/v1.0/issueToken" -H "Ocp-Apim-Subscription-Key: xxxxxxxxx" -H "Content-type: application/x-www-form-urlencoded" -H "Content-Length: 0"

SOS

How can I make this work? What am I doing wrong?

Thanks for your support!

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

1 answer

Sort by: Most helpful
  1. Geronimo Tutusaus 10 Reputation points
    2023-11-08T21:22:10.2766667+00:00

    I found the problem here: https://github.com/Azure-Samples/cognitive-services-speech-sdk/issues/1810. Here's what you can read there.

    "Thank you for reporting this issue. Ubuntu 22.04 moved to OpenSSL version 3. The Cognitive Services Speech SDK has not been updated to support OpenSSL 3 and instead is still using OpenSSL 1.1.1. We have labeled the issue as 'accepted' here and are now also tracking a fix for this in on our backlog (# 4471701). We will respond here once we have an update."

    Here are the lines I added to solve this issue temporarily:

    !wget http://archive.ubuntu.com/ubuntu/pool/main/o/openssl/libssl1.1_1.1.1f-1ubuntu2_amd64.deb
    !sudo dpkg -i libssl1.1_1.1.1f-1ubuntu2_amd64.deb
    
    2 people found this answer helpful.
    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.