Irregular runtime error occurred when calling ssml_to_speech_async in aspeak

Question:

An RuntimeError occurred while calling ssml_to_speech_async of the instance of SpeechToFileService in aspeak in python.

This error seemed to occurred randomly. Even if args and environment is absolutely same, it doesn’t occur every time. Sometimes when I reboot the computer or test next day, the error doesn’t occurred for hours.

This error seems can’t be catch through try.

I have searched the error code, memory address, but there is no similar help.

This is Traceback text (memory address 00007FFE37F772C4, 00007FFE37FC76A8, 00007FFE37FC87A8 is fixed for every time.)

CRITICAL: Traceback (most recent call last):
  ......
  File "E:***tts.py", line 17, in tts
    return provider.ssml_to_speech_async(ssml,path=path)  # type: ignore
  File "F:ProgramDataMiniconda3libsite-packagesaspeakapiapi.py", line 110, in wrapper
    self._setup_synthesizer(kwargs['path'])
  File "F:ProgramDataMiniconda3libsite-packagesaspeakapiapi.py", line 139, in _setup_synthesizer
    self._synthesizer = speechsdk.SpeechSynthesizer(self._config, self._output)
  File "F:ProgramDataMiniconda3libsite-packagesazurecognitiveservicesspeechspeech.py", line 1598, in __init__
    self._impl = self._get_impl(impl.SpeechSynthesizer, speech_config, audio_config,
  File "F:ProgramDataMiniconda3libsite-packagesazurecognitiveservicesspeechspeech.py", line 1703, in _get_impl
    _impl = synth_type._from_config(speech_config._impl, None if audio_config is None else audio_config._impl)
RuntimeError: Exception with an error code: 0x8 (SPXERR_FILE_OPEN_FAILED)
[CALL STACK BEGIN]

    > pal_string_to_wstring

    - pal_string_to_wstring

    - synthesizer_create_speech_synthesizer_from_config

    - synthesizer_create_speech_synthesizer_from_config

    - 00007FFE37F772C4 (SymFromAddr() error: 试图访问无效的地址。)

    - 00007FFE37FC76A8 (SymFromAddr() error: 试图访问无效的地址。)

    - 00007FFE37FC87A8 (SymFromAddr() error: 试图访问无效的地址。)

    - PyArg_CheckPositional

    - Py_NewReference

    - PyEval_EvalFrameDefault

    - Py_NewReference

    - PyEval_EvalFrameDefault

    - PyFunction_Vectorcall

    - PyFunction_Vectorcall

    - PyMem_RawStrdup

    - Py_NewReference



[CALL STACK END]

The code that I call ssml_to_speech_async

from aspeak import SpeechToFileService,AudioFormat,FileFormat

provider=None
fmt=AudioFormat(FileFormat.MP3,-1)

def init():
    global provider
    provider=SpeechToFileService(locale="zh-CN",audio_format=fmt)

def tts(ssml:str,path:str):
    if provider is None:
        init()
    return provider.ssml_to_speech_async(ssml,path=path)  # type: ignore
Asked By: flt

||

Answers:

With the help of Issue on github, I found the problem is there is special character in filename. For example, char /.

If anyone met this error, try to use this regular expression to replace these characters: [*/\|<>? :.'"!]

However, it can solve this question, but some other characters may be replaced, like (space)

Answered By: flt
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.