Azure Text-to Speech Error Code: 0x38 (SPXERR_AUDIO_SYS_LIBRARY_NOT_FOUND) when using Python 3.10 on Wep App Service

Jared Rice 30 Reputation points
2023-02-26T19:48:36.7366667+00:00

I followed these 2 guides and everything works fine on my local windows 10 machine using python 3.10., but when I deploy my code using VS Code to my linux basic web app service, running python 3.10, I receive the following error.

Guides:

https://learn.microsoft.com/en-us/azure/cognitive-services/speech-service/quickstarts/setup-platform?tabs=linux%2Cubuntu%2Cdotnet%2Cjre%2Cmaven%2Cnodejs%2Cmac%2Cpypi&pivots=programming-language-python

and
https://learn.microsoft.com/en-us/azure/cognitive-services/speech-service/get-started-text-to-speech?tabs=linux%2Cterminal&pivots=programming-language-python

Troubleshooting:

https://learn.microsoft.com/en-us/azure/cognitive-services/speech-service/troubleshooting?tabs=powershell#spxerr_audio_sys_library_not_found

Code:

def response_to_speech(response):

    subscription_key = os.getenv("AZURE_SPEECH")
    region = os.getenv("AZURE_REGION")

    speech_config = speechsdk.SpeechConfig(subscription=subscription_key, region=region)
    audio_config = speechsdk.audio.AudioOutputConfig(use_default_speaker=True)
    speech_config.speech_synthesis_voice_name='en-US-JennyNeural'

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

    audio = speech_synthesizer.speak_text_async(response).get()

    return audio

Dependencies:

Python 3.10.9

libasound2 is already the newest version (1.2.4-1.1).
build-essential is already the newest version (12.9).
libssl-dev is already the newest version (1.1.1n-0+deb11u3).
wget is already the newest version (1.21-1+deb11u1).

Requirement already satisfied: azure-cognitiveservices-speech in ./antenv/lib/python3.10/site-packages (1.25.0)

Error:

Exception Value: Exception with error code: 
[CALL STACK BEGIN]
/tmp/8db182897509f5b/antenv/lib/python3.10/site-packages/azure/cognitiveservices/speech/libMicrosoft.CognitiveServices.Speech.core.so(+0x185fa4) [0x7f1b1a187fa4]
/tmp/8db182897509f5b/antenv/lib/python3.10/site-packages/azure/cognitiveservices/speech/libMicrosoft.CognitiveServices.Speech.core.so(+0x1ee61a) [0x7f1b1a1f061a]
/tmp/8db182897509f5b/antenv/lib/python3.10/site-packages/azure/cognitiveservices/speech/libMicrosoft.CognitiveServices.Speech.core.so(synthesizer_create_speech_synthesizer_from_config+0xf3) [0x7f1b1a09c9d0]
/usr/lib/x86_64-linux-gnu/libffi.so.7(+0x6d1d) [0x7f1b35120d1d]
/usr/lib/x86_64-linux-gnu/libffi.so.7(+0x6289) [0x7f1b35120289]
/opt/python/3.10.9/lib/python3.10/lib-dynload/_ctypes.cpython-310-x86_64-linux-gnu.so(+0x11c19) [0x7f1b35137c19]
/opt/python/3.10.9/lib/python3.10/lib-dynload/_ctypes.cpython-310-x86_64-linux-gnu.so(+0x11493) [0x7f1b35137493]
/opt/python/3.10.9/lib/libpython3.10.so.1.0(PyObject_Call+0xc3) [0x7f1b38e0d333]
/opt/python/3.10.9/lib/libpython3.10.so.1.0(_PyEval_EvalFrameDefault+0x2a4b) [0x7f1b38df148b]
/opt/python/3.10.9/lib/libpython3.10.so.1.0(_PyFunction_Vectorcall+0x78) [0x7f1b38e00218]
/opt/python/3.10.9/lib/libpython3.10.so.1.0(PyObject_Call+0x11a) [0x7f1b38e0d38a]
/opt/python/3.10.9/lib/libpython3.10.so.1.0(_PyEval_EvalFrameDefault+0x2a4b) [0x7f1b38df148b]
/opt/python/3.10.9/lib/libpython3.10.so.1.0(_PyFunction_Vectorcall+0x78) [0x7f1b38e00218]
/opt/python/3.10.9/lib/libpython3.10.so.1.0(_PyObject_FastCallDictTstate+0x16d) [0x7f1b38df82dd]
/opt/python/3.10.9/lib/libpython3.10.so.1.0(+0x15f5e5) [0x7f1b38e095e5]
/opt/python/3.10.9/lib/libpython3.10.so.1.0(_PyObject_MakeTpCall+0x273) [0x7f1b38df9143]
/opt/python/3.10.9/lib/libpython3.10.so.1.0(_PyEval_EvalFrameDefault+0x6079) [0x7f1b38df4ab9]
[CALL STACK END]
Exception with an error code: 0x38 (SPXERR_AUDIO_SYS_LIBRARY_NOT_FOUND)

Traceback:


Traceback (most recent call last):
  File "/tmp/8db182897509f5b/antenv/lib/python3.10/site-packages/django/core/handlers/exception.py", line 56, in inner
    response = get_response(request)
  File "/tmp/8db182897509f5b/antenv/lib/python3.10/site-packages/django/core/handlers/base.py", line 197, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/tmp/8db182897509f5b/antenv/lib/python3.10/site-packages/django/contrib/auth/decorators.py", line 23, in _wrapped_view
    return view_func(request, *args, **kwargs)
  File "/tmp/8db182897509f5b/src/views/chat.py", line 85, in as_view
    audio_response = response_to_speech(text_response)
  File "/tmp/8db182897509f5b/src/views/chat.py", line 129, in response_to_speech
    speech_synthesizer = speechsdk.SpeechSynthesizer(speech_config=speech_config, audio_config=audio_config)
  File "/tmp/8db182897509f5b/antenv/lib/python3.10/site-packages/azure/cognitiveservices/speech/speech.py", line 2147, in __init__
    _call_hr_fn(fn=_sdk_lib.synthesizer_create_speech_synthesizer_from_config, *[
  File "/tmp/8db182897509f5b/antenv/lib/python3.10/site-packages/azure/cognitiveservices/speech/interop.py", line 62, in _call_hr_fn
    _raise_if_failed(hr)
  File "/tmp/8db182897509f5b/antenv/lib/python3.10/site-packages/azure/cognitiveservices/speech/interop.py", line 55, in _raise_if_failed
    __try_get_error(_spx_handle(hr))
  File "/tmp/8db182897509f5b/antenv/lib/python3.10/site-packages/azure/cognitiveservices/speech/interop.py", line 50, in __try_get_error
    raise RuntimeError(message)
Azure AI Speech
Azure AI Speech
An Azure service that integrates speech processing into apps and services.
1,940 questions
Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
8,434 questions
{count} vote

Accepted answer
  1. romungi-MSFT 48,671 Reputation points Microsoft Employee
    2023-02-27T08:49:40.7133333+00:00

    Jared Rice I think on the remote app service the default audio config needs to be set to an audio file instead of default as in local machine it cannot default to a speaker in this case.

    Try adding the following to update audio_config

        file_name = "outputaudio.wav"
        file_config = speechsdk.audio.AudioOutputConfig(filename=file_name)
        speech_synthesizer = speechsdk.SpeechSynthesizer(speech_config=speech_config, audio_config=file_config)
    
    
    2 people found this answer helpful.

2 additional answers

Sort by: Most helpful
  1. Jeanine van Rooyen 1 Reputation point
    2023-03-19T20:59:48.27+00:00

    file_name = "outputaudio.wav"your text

    0 comments No comments

  2. Rebecca Peltz 30 Reputation points
    2025-03-07T19:08:19.1966667+00:00

    I get a (SPXERR_AUDIO_SYS_LIBRARY_NOT_FOUND) error when I stream audio on Azure. I switched to streaming because the Azure server did not like me writing a file.

    So my code works with streaming (or writing a file) locally , but it fails on the Azure server. What is the SPXERR_AUDIO_SYS_LIBRARY_NOT_FOUND error that I'm getting from the server?

    Is there a way to get help from someone at Azure?

    2025-03-07T18:58:12.4613574Z /opt/python/3.12.8/lib/libpython3.12.so.1.0(+0x24b859) [0x7cbe564fb859]

    2025-03-07T18:58:12.4613639Z /opt/python/3.12.8/lib/libpython3.12.so.1.0(_PyObject_MakeTpCall+0x2cb) [0x7cbe564b992b]

    2025-03-07T18:58:12.4613659Z /opt/python/3.12.8/lib/libpython3.12.so.1.0(_PyEval_EvalFrameDefault+0x713) [0x7cbe564c2353]

    2025-03-07T18:58:12.4613676Z /opt/python/3.12.8/lib/libpython3.12.so.1.0(+0x11399a) [0x7cbe563c399a]

    2025-03-07T18:58:12.4613693Z /opt/python/3.12.8/lib/libpython3.12.so.1.0(_PyObject_FastCallDictTstate+0x1d5) [0x7cbe564bc3a5]

    2025-03-07T18:58:12.4613911Z [CALL STACK END]

    2025-03-07T18:58:12.4613954Z

    2025-03-07T18:58:12.4613978Z Exception with an error code: 0x38 (SPXERR_AUDIO_SYS_LIBRARY_NOT_FOUND)

    2025-03-07T18:58:12.4614016Z 169.254.129.1 - - [07/Mar/2025:18:58:12 +0000] "GET /synthesize?text=Hello%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20&voice=en-US-AvaMultilingualNeural HTTP/1.1" 500 33 "https://flasktranslatorapp-bvepdbcvgmh7ffek.westus2-01.azurewebsites.net/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.0.0 Safari/537.36"

    2025-03-07T18:59:57.6958825Z 169.254.129.1 - - [07/Mar/2025:18:59:57 +0000] "GET /admin/host/status HTTP/1.1" 404 207 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.0.0 Safari/537.36"Ending Log Tail of existing logs ---Starting Live Log Stream ---

    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.