在aspeak中调用ssml_to_speech_async时发生不规则运行时错误



在python中的aspeak中调用SpeechToFileService实例的ssml_to_speech_async时发生RuntimeError。

这个错误似乎是随机发生的。即使args和环境完全相同,也不会每次都发生。有时,当我第二天重新启动计算机或进行测试时,错误会持续数小时。

这个错误似乎无法通过try捕捉到。

我已经搜索了错误代码、内存地址,但没有类似的帮助。

这是回溯文本(内存地址00007FFE37F772C400007FFE37FC76A800007FFE37FC87A8每次都是固定的。(

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]

我称之为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

在github上Issue的帮助下,我发现问题是文件名中有特殊字符。例如,char/

如果有人遇到此错误,请尝试使用此正则表达式来替换以下字符:[*/\|<>? :.'"!]

然而,它可以解决这个问题,但其他一些字符可能会被替换,比如(空间(

相关内容

最新更新