I wrote a text to speech app using "azure.cognitiveservices.speech" , then based on this I build a docker image and run app as a container. It did work in my local, but run the app as a container failed. The error seems happen at "speech_synthesizer = speechsdk.SpeechSynthesizer(speech_config=speech_config, audio_config=audio_config)".
this is the error info:
RuntimeError: Exception with error code:
[CALL STACK BEGIN] /usr/local/lib/python3.9/site-packages/azure/cognitiveservices/speech/libMicrosoft.CognitiveServices.Speech.core.so(+0x1f5298) [0xffff9a645298]
/usr/local/lib/python3.9/site-packages/azure/cognitiveservices/speech/libMicrosoft.CognitiveServices.Speech.core.so(+0x1fed3c) [0xffff9a64ed3c]
/lib/aarch64-linux-gnu/libc.so.6(+0x83dc8) [0xffffb3bb3dc8] /usr/local/lib/python3.9/site-packages/azure/cognitiveservices/speech/libMicrosoft.CognitiveServices.Speech.core.so(+0x1ffcb4) [0xffff9a64fcb4]
/usr/local/lib/python3.9/site-packages/azure/cognitiveservices/speech/libMicrosoft.CognitiveServices.Speech.core.so(+0x1c21f4) [0xffff9a6121f4]
/usr/local/lib/python3.9/site-packages/azure/cognitiveservices/speech/libMicrosoft.CognitiveServices.Speech.core.so(+0x1bc574) [0xffff9a60c574]
/usr/local/lib/python3.9/site-packages/azure/cognitiveservices/speech/libMicrosoft.CognitiveServices.Speech.core.so(+0x1fbc64) [0xffff9a64bc64]
/usr/local/lib/python3.9/site-packages/azure/cognitiveservices/speech/libMicrosoft.CognitiveServices.Speech.core.so(+0x1d5744) [0xffff9a625744]
/usr/local/lib/python3.9/site-packages/azure/cognitiveservices/speech/libMicrosoft.CognitiveServices.Speech.core.so(+0x1cf534) [0xffff9a61f534]
/usr/local/lib/python3.9/site-packages/azure/cognitiveservices/speech/libMicrosoft.CognitiveServices.Speech.core.so(+0xda940) [0xffff9a52a940]
/usr/local/lib/python3.9/site-packages/azure/cognitiveservices/speech/libMicrosoft.CognitiveServices.Speech.core.so(+0x1fbc64) [0xffff9a64bc64]
/usr/local/lib/python3.9/site-packages/azure/cognitiveservices/speech/libMicrosoft.CognitiveServices.Speech.core.so(+0x1c8448) [0xffff9a618448]
/usr/local/lib/python3.9/site-packages/azure/cognitiveservices/speech/libMicrosoft.CognitiveServices.Speech.core.so(+0x2177a4) [0xffff9a6677a4]
/usr/local/lib/python3.9/site-packages/azure/cognitiveservices/speech/libMicrosoft.CognitiveServices.Speech.core.so(synthesizer_create_speech_synthesizer_from_config+0x10c) [0xffff9a4fd4b0]
/lib/aarch64-linux-gnu/libffi.so.8(+0x63e0) [0xffffb20663e0]
/lib/aarch64-linux-gnu/libffi.so.8(+0x5b24) [0xffffb2065b24]
/usr/local/lib/python3.9/lib-dynload/_ctypes.cpython-39-aarch64-linux-gnu.so(+0xf058) [0xffffb209f058]
[CALL STACK END]
Runtime error: Failed to initialize platform (azure-c-shared). Error: 2153
Traceback:
File "/usr/local/lib/python3.9/site-packages/streamlit/runtime/scriptrunner/script_runner.py", line 552, in _run_script
exec(code, module.__dict__)
File "/app/myapp.py", line 134, in <module>
main()
File "/app/myapp.py", line 80, in main
azure_text_to_speech_file(text, accent)
File "/app/speech_synthesis.py", line 28, in azure_text_to_speech_file
speech_synthesizer = speechsdk.SpeechSynthesizer(speech_config=speech_config, audio_config=audio_config)
File "/usr/local/lib/python3.9/site-packages/azure/cognitiveservices/speech/speech.py", line 2149, in __init__
_call_hr_fn(fn=_sdk_lib.synthesizer_create_speech_synthesizer_from_config, *[
File "/usr/local/lib/python3.9/site-packages/azure/cognitiveservices/speech/interop.py", line 62, in _call_hr_fn
_raise_if_failed(hr)
File "/usr/local/lib/python3.9/site-packages/azure/cognitiveservices/speech/interop.py", line 55, in _raise_if_failed
__try_get_error(_spx_handle(hr))
File "/usr/local/lib/python3.9/site-packages/azure/cognitiveservices/speech/interop.py", line 50, in __try_get_error
raise RuntimeError(message)
and this is the content of my docker file
# Use a base image with Python and specify the version
FROM python:3.9-slim
# Set the working directory inside the container
WORKDIR /app
# Copy the requirements file into the container
COPY requirements.txt .
# Install the required packages
RUN pip install --no-cache-dir -r requirements.txt
# Copy the rest of the application code into the container
COPY . .
# Expose the port your Streamlit app is using
EXPOSE 8501
# Command to run your Streamlit application
CMD ["streamlit", "run", "myapp.py"]
I spent a lot of time to slove this problem, but it still can't work. Is there anyone who can help find the problem and solve it ?I am really appreciate
I also got the similar error while using
azure.cognitiveservices.speech as speechsdkProper install
pip install azure-cognitiveservices-speech-sdkMostly the above errors occurs due to the
Here I updated my requirement.txt file.
Here is my Dockerfile:
Here I dockerized my application and Iam able see my application in my Docker container.
Iam able run the application from the container using
docker run -p 8501:8501 text-to-speech-appOutput: