Hello I am working on an app that reads text using azure tts; my python script that uses Azure TTS runs fine. When I deploy the script using pyinstaller I get error:
SPXERR_AUDIO_SYS_LIBRARY_NOT_FOUND
similar issue was reported by [https://learn.microsoft.com/en-us/answers/questions/1184428/azure-text-to-speech-error-code-0x38-(spxerr-audio](https://learn.microsoft.com/en-us/answers/questions/1184428/azure-text-to-speech-error-code-0x38-(spxerr-audio)
but the solution provided does not solve my problem since i want to read the text in the speaker.
Complete Error Info:
PS E:\Sohaib\upwork\TranslateAndTTS\TranslateAndTTS\dist> .\translateandread.exe
Traceback (most recent call last):
File "translatepb.py", line 144, in <module>
File "translatepb.py", line 90, in mainrun
File "translatepb.py", line 60, in speakstr
File "translatepb.py", line 121, in azureSpeak
File "azure\cognitiveservices\speech\speech.py", line 2149, in __init__
File "azure\cognitiveservices\speech\interop.py", line 62, in _call_hr_fn
File "azure\cognitiveservices\speech\interop.py", line 55, in _raise_if_failed
File "azure\cognitiveservices\speech\interop.py", line 50, in __try_get_error
RuntimeError: Exception with error code:
[CALL STACK BEGIN]
> pal_string_to_wstring
- synthesizer_create_speech_synthesizer_from_config
- synthesizer_create_speech_synthesizer_from_config
- ffi_prep_go_closure
- ffi_call_go
- ffi_call
- 00007FFFA7023CC5 (SymFromAddr() error: Attempt to access invalid address.)
- 00007FFFA7022BEA (SymFromAddr() error: Attempt to access invalid address.)
- 00007FFFA70227E8 (SymFromAddr() error: Attempt to access invalid address.)
- PyList_AsTuple
- PyEval_EvalFrameDefault
- PyFunction_Vectorcall
- PyList_AsTuple
- PyEval_EvalFrameDefault
- PyFunction_Vectorcall
- PyObject_GetBuffer
[CALL STACK END]
Exception with an error code: 0x38 (SPXERR_AUDIO_SYS_LIBRARY_NOT_FOUND)
Python Code:
def azureSpeak(text):
# Add your key and endpoint
key = config.get('azureTTS', 'key')
location = config.get('azureTTS', 'location')
voiceid = config.get('azureTTS', 'voiceid')
speech_config = speechsdk.SpeechConfig(subscription=key, region=location)
audio_config = speechsdk.audio.AudioOutputConfig(use_default_speaker=True)
# The language of the voice that speaks.
speech_config.speech_synthesis_voice_name = voiceid
speech_synthesizer = speechsdk.SpeechSynthesizer(speech_config=speech_config, audio_config=audio_config)
speech_synthesis_result = speech_synthesizer.speak_text_async(text).get()
if speech_synthesis_result.reason == speechsdk.ResultReason.SynthesizingAudioCompleted:
print("Speech synthesized for text [{}]".format(text))
# save to .wav file
timestr = time.strftime("%Y%m%d-%H%M%S")
filename = os.path.join(wav_files_path, timestr+'.wav')
stream = speechsdk.AudioDataStream(speech_synthesis_result)
stream.save_to_wav_file(filename)
elif speech_synthesis_result.reason == speechsdk.ResultReason.Canceled:
cancellation_details = speech_synthesis_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 set the speech resource key and region values?")