Azure 认知服务和 Python 可执行文件

问题描述

我正在创建一个使用 Azure 认知服务语音方面的程序。当我仅通过控制台打印部署可执行文件(.exe)时,它按预期工作。该程序在 VS Code 环境中与 Azure Voice 完美配合,但是一旦将其部署为可执行文件 (.exe),它就会完全出错并显示以下错误

RuntimeError: Exception with an error code: 0x38 (SPXERR_AUdio_SYS_LIBRARY_NOT_FOUND)
[CALL STACK BEGIN]

    > property_bag_copy

    - synthesizer_create_speech_synthesizer_from_config

    - synthesizer_create_speech_synthesizer_from_config

    - 00007FFECED052D4 (SymFromAddr() error: Attempt to access invalid address.)

    - 00007FFECED4DA6E (SymFromAddr() error: Attempt to access invalid address.)

    - 00007FFECED4E0F3 (SymFromAddr() error: Attempt to access invalid address.)

    - PyArg_ParseTuple_SizeT

    - PyEval_EvalFrameDefault

    - PyFunction_Vectorcall

    - PyEval_EvalFrameDefault

    - PyObject_GC_Del

    - PyFunction_Vectorcall

    - PyType_GenericNew

    - PyType_GenericNew

    - PyObject_MakeTpCall

    - PyEval_EvalFrameDefault



[CALL STACK END]

我已尝试重新安装所有依赖项

解决方法

错误提示找不到音频系统库/

如果无法访问依赖dll,可能会出现此错误:

Microsoft.CognitiveServices.Speech.extension.audio.sys.dll

您可以先将此 dll 添加到您的包中,然后再将其转换为 exe。

enter image description here

该文件将出现在您安装 Python 语音模块的位置。