kxxt / aspeak

A simple text-to-speech client for Azure TTS API.
MIT License
494 stars 57 forks source link

RuntimeError in ssml_to_speech_async #27

Closed flt6 closed 2 years ago

flt6 commented 2 years ago

An RuntimeError occurred while calling ssml_to_speech_async of instance of SpeechToFileService.

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:\ProgramData\Miniconda3\lib\site-packages\aspeak\api\api.py", line 110, in wrapper
    self._setup_synthesizer(kwargs['path'])
  File "F:\ProgramData\Miniconda3\lib\site-packages\aspeak\api\api.py", line 139, in _setup_synthesizer
    self._synthesizer = speechsdk.SpeechSynthesizer(self._config, self._output)
  File "F:\ProgramData\Miniconda3\lib\site-packages\azure\cognitiveservices\speech\speech.py", line 1598, in __init__
    self._impl = self._get_impl(impl.SpeechSynthesizer, speech_config, audio_config,
  File "F:\ProgramData\Miniconda3\lib\site-packages\azure\cognitiveservices\speech\speech.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]

tts.py

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

The thing is, this error seemed to occurred randomly, and only when I created(Finished) over 20 ssml_to_speech_async instance does it occurs. This error seems can't be catch through try

kxxt commented 2 years ago

This is probably a bug in azure-cognitiveservices-speech, which I can do nothing about it.

You should open an issue in https://github.com/Azure-Samples/cognitive-services-speech-sdk .