cognitive-services-speech-sdk: Failed to initialize platform (azure-c-shared). Error: 2176

I’ve updated .NET to 8.0 and moved to Docker and now I cannot use Speech service anymore due to this error when creating SpeechSynthesizer class instance.

Stacktrace:

System.ApplicationException: Runtime error: Failed to initialize platform (azure-c-shared). Error: 2176
2024-01-06T17:53:47.649086302Z    at Microsoft.CognitiveServices.Speech.Internal.SpxExceptionThrower.ThrowIfFail(IntPtr hr)
2024-01-06T17:53:47.649089762Z    at Microsoft.CognitiveServices.Speech.SpeechSynthesizer.FromConfig(SpeechConfig speechConfig)
2024-01-06T17:53:47.649092962Z    at Microsoft.CognitiveServices.Speech.SpeechSynthesizer..ctor(SpeechConfig speechConfig)

Speech log file:

[631194]: 4ms SPX_DBG_TRACE_VERBOSE:  resource_manager.cpp:133 Created 'CSpxThreadService' as '303073113'
[631194]: 4ms SPX_DBG_TRACE_VERBOSE:  resource_manager.cpp:133 Created 'CSpxThreadService' as '303073113'
[631194]: 4ms SPX_TRACE_WARNING: resource_manager.cpp:141 Failed to create 'CSpxCodecAdapter' as '199052375'. Are all required extension libraries loaded?
[631194]: 4ms SPX_DBG_TRACE_VERBOSE:  usp_tts_engine_adapter.cpp:60 CSpxUspTtsEngineAdapter
[631194]: 4ms SPX_DBG_TRACE_VERBOSE:  resource_manager.cpp:133 Created 'CSpxUspTtsEngineAdapter' as '919101823'
[631194]: 4ms SPX_TRACE_ERROR: AZ_LOG_ERROR:  shim_openssl.c:55 libssl could not be loaded
[631194]: 4ms SPX_TRACE_ERROR: AZ_LOG_ERROR:  tlsio_openssl.c:2175 Could not load libssl
[631194]: 4ms SPX_TRACE_ERROR:  exception.cpp:130 About to throw Runtime error: Failed to initialize platform (azure-c-shared). Error: 2176 
[CALL STACK BEGIN]

/app/runtimes/linux-x64/native/libMicrosoft.CognitiveServices.Speech.core.so(+0x1decbb) [0x7ece7c5decbb]
/app/runtimes/linux-x64/native/libMicrosoft.CognitiveServices.Speech.core.so(+0x207afd) [0x7ece7c607afd]
/lib/x86_64-linux-gnu/libc.so.6(+0x8dea7) [0x7f0fd1a35ea7]
/app/runtimes/linux-x64/native/libMicrosoft.CognitiveServices.Speech.core.so(+0x208c2e) [0x7ece7c608c2e]
/app/runtimes/linux-x64/native/libMicrosoft.CognitiveServices.Speech.core.so(+0x1b9c7b) [0x7ece7c5b9c7b]
/app/runtimes/linux-x64/native/libMicrosoft.CognitiveServices.Speech.core.so(+0x1b9531) [0x7ece7c5b9531]
/app/runtimes/linux-x64/native/libMicrosoft.CognitiveServices.Speech.core.so(+0x1e5c5d) [0x7ece7c5e5c5d]
/app/runtimes/linux-x64/native/libMicrosoft.CognitiveServices.Speech.core.so(+0x1cabf6) [0x7ece7c5cabf6]
/app/runtimes/linux-x64/native/libMicrosoft.CognitiveServices.Speech.core.so(+0x1dba0e) [0x7ece7c5dba0e]
/app/runtimes/linux-x64/native/libMicrosoft.CognitiveServices.Speech.core.so(+0xf28a5) [0x7ece7c4f28a5]
/app/runtimes/linux-x64/native/libMicrosoft.CognitiveServices.Speech.core.so(+0x1e5c5d) [0x7ece7c5e5c5d]
/app/runtimes/linux-x64/native/libMicrosoft.CognitiveServices.Speech.core.so(+0x1d2a1f) [0x7ece7c5d2a1f]
/app/runtimes/linux-x64/native/libMicrosoft.CognitiveServices.Speech.core.so(+0x21619a) [0x7ece7c61619a]
/app/runtimes/linux-x64/native/libMicrosoft.CognitiveServices.Speech.core.so(synthesizer_create_speech_synthesizer_from_config+0xf3) [0x7ece7c4bd331]
[0x7f0f58dd9aad]
[CALL STACK END]


[631194]: 4ms SPX_DBG_TRACE_VERBOSE:  usp_tts_engine_adapter.cpp:65 ~CSpxUspTtsEngineAdapter: this=0x0x7ece6c0cbf60
[631194]: 4ms SPX_DBG_TRACE_SCOPE_ENTER:  synthesizer.cpp:42 ~CSpxSynthesizer
[631194]: 4ms SPX_DBG_TRACE_VERBOSE:  create_object_helpers.h:78 SpxTerm: ptr=0x0x7ece6c1ca168
[631194]: 4ms SPX_DBG_TRACE_SCOPE_ENTER:  thread_service.cpp:45 Term
[631194]: 4ms SPX_DBG_TRACE_SCOPE_EXIT:  thread_service.cpp:45 Term
[631194]: 4ms SPX_DBG_TRACE_VERBOSE:  create_object_helpers.h:78 SpxTerm: ptr=0x0x7ece6c1c9a78
[631194]: 4ms SPX_DBG_TRACE_SCOPE_EXIT:  synthesizer.cpp:42 ~CSpxSynthesizer
[631194]: 4ms SPX_DBG_TRACE_SCOPE_ENTER:  thread_service.cpp:45 Term
[631194]: 4ms SPX_DBG_TRACE_SCOPE_EXIT:  thread_service.cpp:45 Term
[631194]: 4ms SPX_DBG_TRACE_SCOPE_ENTER:  thread_service.cpp:45 Term
[631194]: 4ms SPX_DBG_TRACE_SCOPE_EXIT:  thread_service.cpp:45 Term
[631194]: 4ms SPX_DBG_TRACE_VERBOSE:  handle_table.h:111 CSpxHandleTable::TrackHandle p=0x0x7ece6c1ca200
[631194]: 4ms SPX_DBG_TRACE_VERBOSE:  handle_table.h:121 CSpxHandleTable::TrackHandle class=ExceptionWithCallStack, h=0x0x7ece6c1ca200, p=0x0x7ece6c1ca200, tot=1
[631194]: 4ms SPX_RETURN_ON_FAIL:  speechapi_c_factory.cpp:566 hr = 0x7ece6c1ca200
[631194]: 4ms SPX_DBG_TRACE_SCOPE_EXIT:  speechapi_c_factory.cpp:556 synthesizer_create_speech_synthesizer_from_config
[631194]: 5ms SPX_DBG_TRACE_VERBOSE:  handle_table.h:180 CSpxHandleTable::StopTracking(h) h=0x0x7ece6c1ca200
[631194]: 5ms SPX_DBG_TRACE_VERBOSE:  handle_table.h:195 CSpxHandleTable::StopTracking(h) class=ExceptionWithCallStack, h=0x0x7ece6c1ca200, p=0x0x7ece6c1ca200, tot=0

To Reproduce

Steps to reproduce the behavior:

  1. Create Docker container based on latest ASP.NET 8.0 image: 8.0.0-bookworm-slim-amd64, 8.0-bookworm-slim-amd64, 8.0.0-bookworm-slim, 8.0-bookworm-slim, 8.0.0, 8.0, latest Dockerfile Debian 12 12/19/2023
  2. Run container
  3. Create SpeechSynthesizer object

Expected behavior

Object should be created and I can access Speech Service.

Version of the Cognitive Services Speech SDK

Nuget: Microsoft.CognitiveServices.Speech 1.34.0

Azure Resource: Standard Speech Service based on Norh Europe https://northeurope.api.cognitive.microsoft.com/

Platform, Operating System, and Programming Language

  • OS: Docker, image based on latest ASP.NET 8.0
  • Programming language: C#

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 7
  • Comments: 22 (3 by maintainers)

Commits related to this issue

Most upvoted comments

I am using the Speech SDK in a docker container running on .NET 8. Here is my workaround, which installs libssl 1.1.1

FROM mcr.microsoft.com/dotnet/aspnet:8.0

# Install prerequisites for Azure Speech Services
# See https://docs.microsoft.com/en-us/azure/cognitive-services/speech-service/quickstarts/setup-platform
RUN apt-get update
RUN apt-get -y install build-essential libssl-dev libasound2 wget

# Next four lines are needed in order to be able to run on .NET 8.0
# until this issue is fixed by Microsoft: https://github.com/Azure-Samples/cognitive-services-speech-sdk/issues/2204
# These lines will install OpenSSL 1.1.1 which is needed by the Speech SDK.
RUN wget http://nz2.archive.ubuntu.com/ubuntu/pool/main/o/openssl/libssl1.1_1.1.1f-1ubuntu2.20_amd64.deb
RUN dpkg -i libssl1.1_1.1.1f-1ubuntu2.20_amd64.deb

RUN wget http://nz2.archive.ubuntu.com/ubuntu/pool/main/o/openssl/libssl-dev_1.1.1f-1ubuntu2.20_amd64.deb
RUN dpkg -i libssl-dev_1.1.1f-1ubuntu2.20_amd64.deb

Both failures are the azure-c-shared library used as the networking stack by the SDK failing to load because the version of OpenSSL it binds to (1.1.1) isn’t installed.

There is a workstream to support OpenSSL 3.0 in progress, but it isn’t complete yet.

following https://gist.github.com/joulgs/c8a85bb462f48ffc2044dd878ecaa786?permalink_comment_id=4720594 to install libssl1.1_1.1.0g-2ubuntu4_amd64.deb and it is working now

╰─❯ dpkg -l |grep libssl
ii  libssl-dev:amd64                           3.0.2-0ubuntu1.14                       amd64        Secure Sockets Layer toolkit - development files
ii  libssl1.1:amd64                            1.1.0g-2ubuntu4                         amd64        Secure Sockets Layer toolkit - shared libraries
ii  libssl3:amd64                              3.0.2-0ubuntu1.14                       amd64        Secure Sockets Layer toolkit - shared libraries
ii  libssl3:i386                               3.0.2-0ubuntu1.14                       i386         Secure Sockets Layer toolkit - shared libraries

I am using the Speech SDK in a docker container running on .NET 8. Here is my workaround, which installs libssl 1.1.1

FROM mcr.microsoft.com/dotnet/aspnet:8.0

# Install prerequisites for Azure Speech Services
# See https://docs.microsoft.com/en-us/azure/cognitive-services/speech-service/quickstarts/setup-platform
RUN apt-get update
RUN apt-get -y install build-essential libssl-dev libasound2 wget

# Next four lines are needed in order to be able to run on .NET 8.0
# until this issue is fixed by Microsoft: https://github.com/Azure-Samples/cognitive-services-speech-sdk/issues/2204
# These lines will install OpenSSL 1.1.1 which is needed by the Speech SDK.
RUN wget http://nz2.archive.ubuntu.com/ubuntu/pool/main/o/openssl/libssl1.1_1.1.1f-1ubuntu2.20_amd64.deb
RUN dpkg -i libssl1.1_1.1.1f-1ubuntu2.20_amd64.deb

RUN wget http://nz2.archive.ubuntu.com/ubuntu/pool/main/o/openssl/libssl-dev_1.1.1f-1ubuntu2.20_amd64.deb
RUN dpkg -i libssl-dev_1.1.1f-1ubuntu2.20_amd64.deb

Hi! I tried to replicate this with a python environment and openssl seems to not be installing. For anyone else who is interested, , my DockerFile is the following

ARG PYTHON_VERSION=3.11
FROM python:${PYTHON_VERSION} as developer


FROM mcr.microsoft.com/dotnet/aspnet:8.0

# Install prerequisites for Azure Speech Services
# See https://docs.microsoft.com/en-us/azure/cognitive-services/speech-service/quickstarts/setup-platform
RUN apt-get update
RUN apt-get -y install build-essential libssl-dev libasound2 wget
RUN apt-get install -y --no-install-recommends \
graphviz \
&& rm -rf /var/lib/apt/lists/*


# New and updated link
RUN wget http://archive.ubuntu.com/ubuntu/pool/main/o/openssl/libssl1.1_1.1.0g-2ubuntu4_amd64.deb
RUN dpkg -i libssl1.1_1.1.0g-2ubuntu4_amd64.deb



RUN python -m venv /venv
ENV PATH=/venv/bin:$PATH

This one got it going in my python:3.12.2 image. Credit to @boskjoett这个在我的 python:3.12.2 图像中得到了它。归功于@boskjoett

# The following two RUNs install OpenSSL 1.1.1 without which Azure SDK errors in docker
# Update and install necessary packages
RUN apt-get update && apt-get install -y \
    wget \
    libasound2

# Install OpenSSL 1.1.1f
RUN wget http://security.ubuntu.com/ubuntu/pool/main/o/openssl/libssl1.1_1.1.1f-1ubuntu2.22_amd64.deb \
    && dpkg -i libssl1.1_1.1.1f-1ubuntu2.22_amd64.deb \
    && wget http://security.ubuntu.com/ubuntu/pool/main/o/openssl/libssl-dev_1.1.1f-1ubuntu2.22_amd64.deb \
    && dpkg -i libssl-dev_1.1.1f-1ubuntu2.22_amd64.deb

# Cleanup to reduce image size
RUN apt-get clean && rm -rf /var/lib/apt/lists/* \
    && rm *.deb

This one got it going in my python:3.12.2 image. Credit to @boskjoett这个在我的 python:3.12.2 图像中得到了它。归功于@boskjoett

# The following two RUNs install OpenSSL 1.1.1 without which Azure SDK errors in docker
# Update and install necessary packages
RUN apt-get update && apt-get install -y \
    wget \
    libasound2

# Install OpenSSL 1.1.1f
RUN wget http://security.ubuntu.com/ubuntu/pool/main/o/openssl/libssl1.1_1.1.1f-1ubuntu2.22_amd64.deb \
    && dpkg -i libssl1.1_1.1.1f-1ubuntu2.22_amd64.deb \
    && wget http://security.ubuntu.com/ubuntu/pool/main/o/openssl/libssl-dev_1.1.1f-1ubuntu2.22_amd64.deb \
    && dpkg -i libssl-dev_1.1.1f-1ubuntu2.22_amd64.deb

# Cleanup to reduce image size
RUN apt-get clean && rm -rf /var/lib/apt/lists/* \
    && rm *.deb

Great, it worked This is a temporary solution, because Microsoft is too inefficient (this problem is probably more than a year old), and if you want to solve it, you can only do it this way Or change to restapi

This one got it going in my python:3.12.2 image. Credit to @boskjoett

# The following two RUNs install OpenSSL 1.1.1 without which Azure SDK errors in docker
# Update and install necessary packages
RUN apt-get update && apt-get install -y \
    wget \
    libasound2

# Install OpenSSL 1.1.1f
RUN wget http://security.ubuntu.com/ubuntu/pool/main/o/openssl/libssl1.1_1.1.1f-1ubuntu2.22_amd64.deb \
    && dpkg -i libssl1.1_1.1.1f-1ubuntu2.22_amd64.deb \
    && wget http://security.ubuntu.com/ubuntu/pool/main/o/openssl/libssl-dev_1.1.1f-1ubuntu2.22_amd64.deb \
    && dpkg -i libssl-dev_1.1.1f-1ubuntu2.22_amd64.deb

# Cleanup to reduce image size
RUN apt-get clean && rm -rf /var/lib/apt/lists/* \
    && rm *.deb

@muralidhar972 We don’t have packages available for preview yet.