Speech SDK trowing error: Exception with an error code: 0xe (SPXERR_MIC_NOT_AVAILABLE)

Fabian Lechner 0 Reputation points
2023-03-13T09:08:44.1966667+00:00

I have a small script in python:

def listen(language):
    speech_config.speech_recognition_language=language
    audio_config = speechsdk.audio.AudioConfig(use_default_microphone=True)
    speech_recognizer = speechsdk.SpeechRecognizer(speech_config=speech_config, audio_config=audio_config)
    print("Speak into your microphone.")
    speech_recognition_result = speech_recognizer.recognize_once_async().get()
    if speech_recognition_result.reason == speechsdk.ResultReason.RecognizedSpeech:
        print("Recognized: {}".format(speech_recognition_result.text))
        return speech_recognition_result.text

which is working perfectly on my MacOS Ventura 13.0. However, when i transfer it to my Linux system Running Ubuntu 22.10 i get the following stack of errors:

Exception in Tkinter callback
Traceback (most recent call last):
  File "/usr/lib/python3.10/tkinter/__init__.py", line 1921, in __call__
    return self.func(*args)
  File "/home/fabian/Schreibtisch/Chatbot/gui.py", line 184, in <lambda>
    command=lambda: main(set_language,"doctor"),
  File "/home/fabian/Schreibtisch/Chatbot/ada_dialog_functions.py", line 233, in main
    gender_age=ask_age_gender(language,language_voice_id,language_country_id)
  File "/home/fabian/Schreibtisch/Chatbot/ada_dialog_functions.py", line 188, in ask_age_gender
    answer=listen(language_country_id)
  File "/home/fabian/Schreibtisch/Chatbot/ada_dialog_functions.py", line 15, in listen
    speech_recognizer = speechsdk.SpeechRecognizer(speech_config=speech_config, audio_config=audio_config)
  File "/home/fabian/.local/lib/python3.10/site-packages/azure/cognitiveservices/speech/speech.py", line 1004, in __init__
    _call_hr_fn(
  File "/home/fabian/.local/lib/python3.10/site-packages/azure/cognitiveservices/speech/interop.py", line 62, in _call_hr_fn
    _raise_if_failed(hr)
  File "/home/fabian/.local/lib/python3.10/site-packages/azure/cognitiveservices/speech/interop.py", line 55, in _raise_if_failed
    __try_get_error(_spx_handle(hr))
  File "/home/fabian/.local/lib/python3.10/site-packages/azure/cognitiveservices/speech/interop.py", line 50, in __try_get_error
    raise RuntimeError(message)
RuntimeError: Exception with error code: 
[CALL STACK BEGIN]

/home/fabian/.local/lib/python3.10/site-packages/azure/cognitiveservices/speech/libMicrosoft.CognitiveServices.Speech.extension.audio.sys.so(+0xe0f1) [0x7f53e240e0f1]
/home/fabian/.local/lib/python3.10/site-packages/azure/cognitiveservices/speech/libMicrosoft.CognitiveServices.Speech.core.so(+0x1c9cf8) [0x7f53e31c9cf8]
/home/fabian/.local/lib/python3.10/site-packages/azure/cognitiveservices/speech/libMicrosoft.CognitiveServices.Speech.core.so(+0xf4c35) [0x7f53e30f4c35]
/home/fabian/.local/lib/python3.10/site-packages/azure/cognitiveservices/speech/libMicrosoft.CognitiveServices.Speech.core.so(+0x18251b) [0x7f53e318251b]
/home/fabian/.local/lib/python3.10/site-packages/azure/cognitiveservices/speech/libMicrosoft.CognitiveServices.Speech.core.so(+0xe7ad3) [0x7f53e30e7ad3]
/home/fabian/.local/lib/python3.10/site-packages/azure/cognitiveservices/speech/libMicrosoft.CognitiveServices.Speech.core.so(+0x1c9cf8) [0x7f53e31c9cf8]
/home/fabian/.local/lib/python3.10/site-packages/azure/cognitiveservices/speech/libMicrosoft.CognitiveServices.Speech.core.so(+0xf4c35) [0x7f53e30f4c35]
/home/fabian/.local/lib/python3.10/site-packages/azure/cognitiveservices/speech/libMicrosoft.CognitiveServices.Speech.core.so(+0x180101) [0x7f53e3180101]
/home/fabian/.local/lib/python3.10/site-packages/azure/cognitiveservices/speech/libMicrosoft.CognitiveServices.Speech.core.so(+0x18334f) [0x7f53e318334f]
/home/fabian/.local/lib/python3.10/site-packages/azure/cognitiveservices/speech/libMicrosoft.CognitiveServices.Speech.core.so(+0x1309e7) [0x7f53e31309e7]
/home/fabian/.local/lib/python3.10/site-packages/azure/cognitiveservices/speech/libMicrosoft.CognitiveServices.Speech.core.so(+0x1309e7) [0x7f53e31309e7]
/home/fabian/.local/lib/python3.10/site-packages/azure/cognitiveservices/speech/libMicrosoft.CognitiveServices.Speech.core.so(+0x15aeb1) [0x7f53e315aeb1]
/home/fabian/.local/lib/python3.10/site-packages/azure/cognitiveservices/speech/libMicrosoft.CognitiveServices.Speech.core.so(+0x134d3d) [0x7f53e3134d3d]
/home/fabian/.local/lib/python3.10/site-packages/azure/cognitiveservices/speech/libMicrosoft.CognitiveServices.Speech.core.so(+0x1dc61d) [0x7f53e31dc61d]
/home/fabian/.local/lib/python3.10/site-packages/azure/cognitiveservices/speech/libMicrosoft.CognitiveServices.Speech.core.so(+0x130815) [0x7f53e3130815]
/home/fabian/.local/lib/python3.10/site-packages/azure/cognitiveservices/speech/libMicrosoft.CognitiveServices.Speech.core.so(+0x1f87f6) [0x7f53e31f87f6]
/home/fabian/.local/lib/python3.10/site-packages/azure/cognitiveservices/speech/libMicrosoft.CognitiveServices.Speech.core.so(recognizer_create_speech_recognizer_from_config+0xf2) [0x7f53e30d121b]
[CALL STACK END]

Exception with an error code: 0xe (SPXERR_MIC_NOT_AVAILABLE)

I have a microphone detected and it is being recognized on other applications. For development i use VS-Code, however even if i run the python program straight out of the terminal it throws this error.

I already found this: https://github.com/Azure-Samples/cognitive-services-speech-sdk/issues/517 However, it did not contribute to my problems solution.

Azure AI Speech
Azure AI Speech
An Azure service that integrates speech processing into apps and services.
{count} votes

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.