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
This code is derived from the QuickStart SpeechSDK Tutorial found here:https://learn.microsoft.com/en-us/azure/cognitive-services/speech-service/get-started-speech-to-text?tabs=linux%2Cterminal&pivots=programming-language-python
It works perfectly under my MacOS Ventura 13.0 detecting speech. However, when I try it on my Linux Machine running Ubuntu 22.10 using the exact same hardware for audio detection it throws the following error:
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 tried changing the microphone using the device_name= "hw:CARD=U0x4b40x306,DEV=0
however this did not work either. Most of the solutions for this bug do not mention my combination of OS and Language, therefore are not really applicable.