0x38 (SPXERR_AUDIO_SYS_LIBRARY_NOT_FOUND) "GET /socket.io/?EIO=4&transport=polling&t=OweNACu
Hello,
I build a small app using Python=3.9, flask and openai. This app is running perfectly on my local computer. But when I deploy the same files in the app on azure it givess me the error:
Exception with an error code: 0x38 (SPXERR_AUDIO_SYS_LIBRARY_NOT_FOUND) "GET /socket.io/?EIO=4&transport=polling&t=OweNACu HTTP/1.1" 200 97 "https://gpt3-app.azurewebsites.net/"
The function of the app is to listen the input from the microphone, convert it into text, pass this text to gpt, generate response from gpt and then speak the response into the speaker using azure speech SDK.
How I can solve the above error? and how my app working fine on azure as it is working on local computer. I'm attaching my files here.
app.pdf
Azure OpenAI Service
Azure App Service
-
dupammi • 8,535 Reputation points • Microsoft External Staff
2024-04-04T11:41:47.4066667+00:00 Hi @Atif Altaf
Thank you for using the Microsoft Q&A forum.
The error code 0x38 (SPXERR_AUDIO_SYS_LIBRARY_NOT_FOUND) indicates that the audio system library is not found. This error can occur when the default audio configuration is set to use the speaker, which is not available on the remote app service. To resolve this error, you can update the audio configuration to use an audio file instead of the default speaker.
You can update the audio configuration by adding the following code to your app:
file_name = "outputaudio.wav" file_config = speechsdk.audio.AudioOutputConfig(filename=file_name) speech_synthesizer = speechsdk.SpeechSynthesizer(speech_config=speech_config, audio_config=file_config)
This code sets the audio configuration to use an audio file named "outputaudio.wav" instead of the default speaker.
Additionally, ensure that you have installed the Speech SDK for Python on the remote app service. You can install the Speech SDK by running
pip install azure-cognitiveservices-speech
in the terminal.For more information, you can refer to the Azure documentation on troubleshooting the SPXERR_AUDIO_SYS_LIBRARY_NOT_FOUND error. Hope this helps.
Thank you.
-
Atif Altaf • 0 Reputation points
2024-04-04T12:14:03.7733333+00:00 Thanks for your answer @dupammi
how does the outputaudio.wav file speak into the speaker on Azure?
I want that the response recorded in the file speak into the speaker. -
Atif Altaf • 0 Reputation points
2024-04-04T13:22:06.75+00:00 I add this code but still same issue and error. How it recognize my speak and give response into the speaker?
-
dupammi • 8,535 Reputation points • Microsoft External Staff
2024-04-05T04:34:44.0266667+00:00 Hi @Atif Altaf
Thank you for your follow-up question.
- How does the outputaudio.wav file speak into the speaker on Azure?
Below is the repro I tried at my end. Instead of using the outputaudio.wav, the synthesized speech is played directly through the speaker using theAudio
object created withIPython.display
. Theautoplay=True
parameter ensures that the synthesized speech plays, after its generated.from IPython.display import Audio
- How does it recognize my speech and give a response into the speaker? In cloud environments like Azure ML notebooks, access to the microphone might be restricted. To work around this issue, you can simulate the speech recognition part by providing a static text input instead of listening for speech input. To work around this issue, the app can simulate the speech recognition part by providing a static text input instead of listening for speech input. The static text recognition and response generation are handled by the code interacting with the OpenAI API (
generate_chat_completion
function). Once the response is generated, it's passed to thesynthesize_speech
function, which synthesizes the speech using Azure's Cognitive Services Speech SDK. The synthesized speech is then played through the speaker using theAudio
object withautoplay=True
, ensuring that the response can be played after it's generated.
def generate_chat_completion(prompt): response = openai.Completion.create( engine="test", prompt=prompt, temperature=0.7, max_tokens=800, top_p=0.95, frequency_penalty=0, presence_penalty=0, stop=None ) return response.choices[0].text.strip() def synthesize_speech(text): speech_config = speechsdk.SpeechConfig(subscription="YOUR_SUBSCRIPTION", region="YOUR_REGION") speech_synthesizer = speechsdk.SpeechSynthesizer(speech_config=speech_config) if isinstance(text, list): # If text is a list, synthesize speech for each item and play the audio sequentially for item in text: result = speech_synthesizer.speak_text_async(item).get() if result.reason == speechsdk.ResultReason.SynthesizingAudioCompleted: print("Speech synthesized to speaker for text [{}]".format(item)) audio_data = result.audio_data Audio(data=audio_data, autoplay=True) elif result.reason == speechsdk.ResultReason.Canceled: cancellation_details = result.cancellation_details print("Speech synthesis canceled: {}".format(cancellation_details.reason)) if cancellation_details.reason == speechsdk.CancellationReason.Error: if cancellation_details.error_details: print("Error details: {}".format(cancellation_details.error_details)) print("Did you update the subscription info?") else: # If text is a string, synthesize speech for the single item result = speech_synthesizer.speak_text_async(text).get() if result.reason == speechsdk.ResultReason.SynthesizingAudioCompleted: print("Speech synthesized to speaker for text [{}]".format(text)) audio_data = result.audio_data return Audio(data=audio_data, autoplay=True) elif result.reason == speechsdk.ResultReason.Canceled: cancellation_details = result.cancellation_details print("Speech synthesis canceled: {}".format(cancellation_details.reason)) if cancellation_details.reason == speechsdk.CancellationReason.Error: if cancellation_details.error_details: print("Error details: {}".format(cancellation_details.error_details)) print("Did you update the subscription info?") # Example usage user_input = "A one sentence relaxing speech" # Generate chat completion chat_response = generate_chat_completion(user_input) # Synthesize speech for the chat response synthesize_speech(chat_response)
Result:
I hope you understand. Thank you.
- How does the outputaudio.wav file speak into the speaker on Azure?
-
dupammi • 8,535 Reputation points • Microsoft External Staff
2024-04-06T01:54:41.6366667+00:00 Hi @Atif Altaf
Following up to see if you got a chance to check my above suggestion and it that was helpful.
Thank you.
-
Atif Altaf • 0 Reputation points
2024-04-06T07:55:14.61+00:00 Hy @dupammi
Yes, it was helpful. but it is not solving my problem. My Problem is that: I want to deploy a flask app on azure in such a way that it takes input using a microphone, recognizes voice and converts it into text, passes it to gpt, gpt generates a response and the generated response will be spoken into the speaker.
How I can solve it? -
dupammi • 8,535 Reputation points • Microsoft External Staff
2024-04-08T04:15:32.96+00:00 Hi @Atif Altaf
To deploy a Flask app on Azure that takes input using a microphone, recognizes voice and converts it into text, passes it to GPT, generates a response, and speaks the response into the speaker using Azure Speech SDK, you can follow the steps I mentioned in my previous response. It covers the later part of your use case i.e. passing the text to GPT, generates response, and speaks out using the Azure Speech SDK.
Regarding your latest question, you can use the Web Speech API in JavaScript to capture the audio input from the microphone and send it to the Flask app for speech recognition. Once the recognized text is passed to GPT to generate a response, you can use the Azure Speech SDK to synthesize the generated response into speech and play it through the speaker.
If you face any issues during the deployment or implementation, you can raise a support case through the Azure portalfor further assistance.
I hope you understand. Thank you!
-
Rebecca Peltz • 30 Reputation points
2025-03-07T19:17:15.1166667+00:00 I set up my original code to create a wav file. It worked locally but failed when I deployed to Azure. I don't think Azure likes writing a file to the file system. Is there a way around that?
I thought by setting it up as streaming it would fix it. Again it worked locally, but when it was deployed to Azure it failed with this error: SPXERR_AUDIO_SYS_LIBRARY_NOT_FOUND.
I don't think we have be shown a good solution for using speech syntheses on a web app where you have a backend generating audio and Azure forwarding it to the front end.
Does the format have to be a wav format? It's not clear looking at this list of available output formats
Sign in to comment