gpt4 book ai didi

python - docker运行时错误: Failed to initialize platform (azure-c-shared).错误:2153

转载 作者:行者123 更新时间:2023-12-03 01:59:24 27 4
gpt4 key购买 nike

我使用“azure.cognitiveservices.speech”编写了一个文本到语音应用程序,然后基于此我构建了一个 docker 镜像并将应用程序作为容器运行。它确实在我的本地工作,但作为容器运行应用程序失败。该错误似乎发生在“speech_synthesizer =peechsdk.SpeechSynthesizer(speech_config=speech_config,audio_config=audio_config)”处。

这是错误信息:

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)

这是我的 docker 文件的内容

# 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"]

我花了很多时间解决这个问题,但还是不行。有没有人可以帮忙找到问题并解决?我真的很感激😭

最佳答案

我在使用azure.cognitiveservices.speech作为speechsdk

时也遇到了类似的错误

enter image description here

正确安装pip install azure-cognitiveservices-speech-sdk

出现上述错误大多是由于

#0 7.558 The conflict is caused by:
#0 7.558 The user requested protobuf==3.19.0
#0 7.558 streamlit 1.24.0 depends on protobuf<5 and >=3.20
#0 7.558
#0 7.558 To fix this you could try to:
#0 7.558 1. loosen the range of package versions you've specified
#0 7.558 2. remove package versions to allow pip attempt to solve the dependency conflict

在这里,我更新了我的 requirement.txt 文件。

streamlit==1.24.0
azure-cognitiveservices-speech==1.20.0
altair==4.1.0
blinker>=1.0.0
pympler>=0.9
numpy>=1
python-dateutil>=2

这是我的Dockerfile:

# Use a base image with Python and specify the version
FROM python:3.9-slim

# Update the protobuf library to a compatible version
RUN pip install --no-cache-dir protobuf==3.19.0

ENV PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python

# 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"]

在这里,我对我的应用程序进行了 docker 化,并且我能够在 Docker 容器中看到我的应用程序。

enter image description here

我可以使用 docker run -p 8501:8501 text-to-speech-app

从容器运行应用程序

enter image description here

输出:

enter image description here

关于python - docker运行时错误: Failed to initialize platform (azure-c-shared).错误:2153,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/76987349/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com