Microsoft Speech To text (SPXERR_AUDIO_SYS_LIBRARY_NOT_FOUND)

734 views Asked by At

I have used the algorithm speech to text in my project, without docker, and my project runs beautifully but when I add to my project a dockerfile and compose, the algorithm speech to text stopped working giving me this error:

Traceback (most recent call last):
backend     |   File "/usr/local/lib/python3.9/site-packages/flask/app.py", line 2464, in __call__
backend     |     return self.wsgi_app(environ, start_response)
backend     |   File "/usr/local/lib/python3.9/site-packages/flask/app.py", line 2450, in wsgi_app
backend     |     response = self.handle_exception(e)
backend     |   File "/usr/local/lib/python3.9/site-packages/flask_cors/extension.py", line 165, in wrapped_function
backend     |     return cors_after_request(app.make_response(f(*args, **kwargs)))
backend     |   File "/usr/local/lib/python3.9/site-packages/flask/app.py", line 1867, in handle_exception
backend     |     reraise(exc_type, exc_value, tb)
backend     |   File "/usr/local/lib/python3.9/site-packages/flask/_compat.py", line 39, in reraise
backend     |     raise value
backend     |   File "/usr/local/lib/python3.9/site-packages/flask/app.py", line 2447, in wsgi_app
backend     |     response = self.full_dispatch_request()
backend     |   File "/usr/local/lib/python3.9/site-packages/flask/app.py", line 1952, in full_dispatch_request
backend     |     rv = self.handle_user_exception(e)
backend     |   File "/usr/local/lib/python3.9/site-packages/flask_cors/extension.py", line 165, in wrapped_function
backend     |     return cors_after_request(app.make_response(f(*args, **kwargs)))
backend     |   File "/usr/local/lib/python3.9/site-packages/flask/app.py", line 1821, in handle_user_exception
backend     |     reraise(exc_type, exc_value, tb)
backend     |   File "/usr/local/lib/python3.9/site-packages/flask/_compat.py", line 39, in reraise
backend     |     raise value
backend     |   File "/usr/local/lib/python3.9/site-packages/flask/app.py", line 1950, in full_dispatch_request
backend     |     rv = self.dispatch_request()
backend     |   File "/usr/local/lib/python3.9/site-packages/flask/app.py", line 1936, in dispatch_request
backend     |     return self.view_functions[rule.endpoint](**req.view_args)
backend     |   File "/app/app.py", line 123, in testRealize
backend     |     speech_recognizer = speechsdk.SpeechRecognizer(speech_config=speech_config)
backend     |   File "/usr/local/lib/python3.9/site-packages/azure/cognitiveservices/speech/speech.py", line 802, in __init__
backend     |     self._impl = self._get_impl(impl.SpeechRecognizer, speech_config, audio_config, language, source_language_config, auto_detect_source_language_config)
backend     |   File "/usr/local/lib/python3.9/site-packages/azure/cognitiveservices/speech/speech.py", line 864, in _get_impl
backend     |     return reco_type._from_config(speech_config._impl)
backend     | RuntimeError: Exception with an error code: 0x38 (SPXERR_AUDIO_SYS_LIBRARY_NOT_FOUND)
backend     | [CALL STACK BEGIN]
backend     | 
backend     | /usr/local/lib/python3.9/site-packages/azure/cognitiveservices/speech/libMicrosoft.CognitiveServices.Speech.core.so(+0x1fab3d) [0x7f4916de0b3d]
backend     | /usr/local/lib/python3.9/site-packages/azure/cognitiveservices/speech/libMicrosoft.CognitiveServices.Speech.core.so(+0x1fe082) [0x7f4916de4082]
backend     | /usr/local/lib/python3.9/site-packages/azure/cognitiveservices/speech/libMicrosoft.CognitiveServices.Speech.core.so(+0x1fa526) [0x7f4916de0526]
backend     | /usr/local/lib/python3.9/site-packages/azure/cognitiveservices/speech/libMicrosoft.CognitiveServices.Speech.core.so(+0x1fa660) [0x7f4916de0660]
backend     | /usr/local/lib/python3.9/site-packages/azure/cognitiveservices/speech/libMicrosoft.CognitiveServices.Speech.core.so(+0x1fa6c1) [0x7f4916de06c1]
backend     | /usr/local/lib/python3.9/site-packages/azure/cognitiveservices/speech/libMicrosoft.CognitiveServices.Speech.core.so(+0x10fc59) [0x7f4916cf5c59]
backend     | /usr/local/lib/python3.9/site-packages/azure/cognitiveservices/speech/libMicrosoft.CognitiveServices.Speech.core.so(+0x10fc59) [0x7f4916cf5c59]
backend     | /usr/local/lib/python3.9/site-packages/azure/cognitiveservices/speech/libMicrosoft.CognitiveServices.Speech.core.so(+0x1d3f4e) [0x7f4916db9f4e]
backend     | /usr/local/lib/python3.9/site-packages/azure/cognitiveservices/speech/libMicrosoft.CognitiveServices.Speech.core.so(+0x1e2d82) [0x7f4916dc8d82]
backend     | /usr/local/lib/python3.9/site-packages/azure/cognitiveservices/speech/libMicrosoft.CognitiveServices.Speech.core.so(+0x1e1a08) [0x7f4916dc7a08]
backend     | /usr/local/lib/python3.9/site-packages/azure/cognitiveservices/speech/libMicrosoft.CognitiveServices.Speech.core.so(+0x1e1cf9) [0x7f4916dc7cf9]
backend     | /usr/local/lib/python3.9/site-packages/azure/cognitiveservices/speech/libMicrosoft.CognitiveServices.Speech.core.so(+0x260ad7) [0x7f4916e46ad7]
backend     | /usr/local/lib/python3.9/site-packages/azure/cognitiveservices/speech/libMicrosoft.CognitiveServices.Speech.core.so(recognizer_create_speech_recognizer_from_config+0x109) [0x7f4916e482c2]
backend     | /usr/local/lib/python3.9/site-packages/azure/cognitiveservices/speech/_speech_py_impl.so(+0x10693a) [0x7f491771293a]
backend     | /usr/local/lib/python3.9/site-packages/azure/cognitiveservices/speech/_speech_py_impl.so(+0x8837c) [0x7f491769437c]
backend     | /usr/local/lib/libpython3.9.so.1.0(+0x176b70) [0x7f491a28db70]
backend     | /usr/local/lib/libpython3.9.so.1.0(_PyObject_MakeTpCall+0x7d) [0x7f491a25ffbd]
backend     | [CALL STACK END]

Part of the code where I used the algorithm:

def testRealize():
    begin = datetime.now()

    speech_config = speechsdk.SpeechConfig(
        subscription="ab************************", region="westeurope")
    speech_config.speech_recognition_language = "pt-PT"

    global speech_recognizer
    speech_recognizer = speechsdk.SpeechRecognizer(speech_config=speech_config)

    global all_results
    all_results = []

    print("Speak into your microphone.")
    # result = speech_recognizer.recognize_once_async().get()

    speech_recognizer.session_started.connect(
        lambda evt: print('SESSION STARTED: {}'.format(evt)))
    speech_recognizer.session_stopped.connect(
        lambda evt: print('\nSESSION STOPPED {}'.format(evt)))
    speech_recognizer.recognized.connect(handle_final_result)

    speech_recognizer.start_continuous_recognition()
    # print(result.text)

    # return jsonify({'begin' : begin , 'text' : result.text })
    return jsonify({'begin': begin})


@app.route("/stop", methods=["GET", "POST"])
def stop():
    end = datetime.now()

    speech_recognizer.stop_continuous_recognition_async()
    speech_recognizer.session_started.disconnect_all()
    speech_recognizer.recognized.disconnect_all()
    speech_recognizer.session_stopped.disconnect_all()
    # print(all_results)

    return jsonify({'end': end, 'text': all_results})

The thing is that algorithm runs if I don't use docker but when I use, this error above appears. And I don't know why I am facing this problem. I have to resolve this problem fast. Can you help me, please?

Thanks.

1

There are 1 answers

2
Linminxiang On

In my case, I had to copy some files from the python package into the program execution path.

python package path: ...\Lib\site-packages\azure\cognitiveservices\speech\

file:

Microsoft.CognitiveServices.Speech.core.dll
Microsoft.CognitiveServices.Speech.extension.audio.sys.dll
Microsoft.CognitiveServices.Speech.extension.codec.dll
Microsoft.CognitiveServices.Speech.extension.kws.dll
Microsoft.CognitiveServices.Speech.extension.lu.dll

Hope to help you get some inspiration.