how to fix Exception with an error code: 0x38 (SPXERR_AUDIO_SYS_LIBRARY_NOT_FOUND) in azure app service

Erdison 0 Reputation points
2023-11-09T15:44:41.67+00:00

hello

deployed an Flask app in Azure Webb App,
the app uses azure.cognitiveservices.speech library in a function to open mic and recognize audio:

def record_audio():
    language = None

    auto_detect_source_language_config = speechsdk.languageconfig.AutoDetectSourceLanguageConfig(
        languages=["it-IT", "en-US", "en-GB"])
    speech_recognizer = speechsdk.SpeechRecognizer(speech_config=speech_config,
                                                  auto_detect_source_language_config=auto_detect_source_language_config)
    
    result = speech_recognizer.recognize_once()
    if result.reason == speechsdk.ResultReason.RecognizedSpeech:
        language = result.properties[speechsdk.PropertyId.SpeechServiceConnection_AutoDetectSourceLanguageResult].split("-")[0]
        
        question_text = result.text #grabbing the text of the audio given by user

        answer = search_azure_api_speak_version(question_text, API_URL) #calling the api to get the text version of the answer
        if answer.strip():
      
            translated = translate_text(answer_cleaned, language)#translating..
            audio_data = text_to_speech(translated, language)#converting in audio
            return question_text, audio_data #returning the audio and the question pair

        return "", text_to_speech("No answer found for the question.",language)

    elif result.reason == speechsdk.ResultReason.NoMatch:
        return "No speech could be recognized", ""

    elif not speechsdk.audio.AudioConfig().is_microphone_available():
        return "Microphone not available. Please ensure that a microphone is connected.", ""

    elif result.reason == speechsdk.ResultReason.Canceled:
        cancellation_details = result.cancellation_details
        print(f"Speech Recognition canceled: {cancellation_details.reason}")
        if cancellation_details.reason == speechsdk.CancellationReason.Error:
            return f"Error details: {cancellation_details.error_details}", "", ""
        return "", "", ""
    else:
        return "Speech recognition failed", ""

Locally everything is ok, it can open the mic, but in cloud i get the error(full error):

{"error":"An unexpected error occurred while processing the audio: Exception with error code: \n

[CALL STACK BEGIN]\n\n/tmp/8dbe12210ad515c/antenv/lib/python3.11/site-packages/azure/cognitiveservices/speech/libMicrosoft.CognitiveServices.Speech.core.so

(+0x193021) [0x798a3b7b7021]\n/tmp/8dbe12210ad515c/antenv/lib/python3.11/site-packages/azure/cognitiveservices/speech/libMicrosoft.CognitiveServices.Speech.

core.so(+0xe9b41)

Speech.core.so(+0x1d9678) [0x798a3b7fd678]\n/tmp/8dbe12210ad515c/antenv/lib/python3.11/site-packages/azure/cognitiveservices/speech/lib

Microsoft.CognitiveServices.Speech.core.so(+0xf61e8) [0x798a3b71a1e8]\n/tmp/8dbe12210ad515c/antenv/lib/python3.11/site-packages/azure/cognitiveservices/speech/libMicrosoft.CognitiveServices.Speech.core.so(+0x18f338) [0x798a3b7b3338]\n/tmp/8dbe12210ad515c/antenv/lib/python3.11/site-packages/azure/cognitiveservices/speech/libMicrosoft.CognitiveServices.Speech.core.so(+0x192cc5) [0x798a3b7b6cc5]\n/tmp/8dbe12210ad515c/antenv/lib/python3.11/site-packages/azure/cognitiveservices/speech/lib

just wondering if is possible to do the same in Web App service as in locally.

thanks!

Azure AI Search
Azure AI Search
An Azure search service with built-in artificial intelligence capabilities that enrich information to help identify and explore relevant content at scale.
1,027 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Deleted

    This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.


    Comments have been turned off. Learn more

  2. brtrach-MSFT 16,431 Reputation points Microsoft Employee
    2023-11-11T19:30:23.7766667+00:00

    @Erdison The error message you provided indicates that there is an issue with the audio system library not being found. Due to the PaaS nature of Web Apps and your dependencies, you would likely find it easier to use a Web App for Containers. This will allow you to have more control over the environment, such as adding audio systems for your service. More information can be found here.

    To resolve this issue, you can try installing the required audio system library in your Azure Web App. You can do this by adding the following code to your Flask app:

    import os
    os.system('sudo apt-get install libasound2-dev')
    

    This code will install the required audio system library in your Azure Web App.


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.