Qt TextToSpeech
通过Qt TextToSpeech 模块,Qt XML 应用程序可使用语音合成技术朗读文本。这在终端用户无法访问应用程序可视化界面的情况下尤其有用,例如在驾驶或操作机器时。在这种情况下,该模块可用于读出收到的通知或提供转弯导航指示。
该模块本身不提供文本到语音引擎。相反,它使用操作系统的本地引擎。有关详情,请参阅Qt TextToSpeech 引擎。
使用模块
QML API
模块的 QML 类型可通过QtTextToSpeech
导入使用。要使用这些类型,请在 .qml 文件中添加以下导入语句:
import QtTextToSpeech
C++ API
使用 Qt 模块的 C++ API 需要直接或通过其他依赖关系与模块库链接。一些编译工具对此提供了专门支持,包括CMake和qmake。
使用 CMake 构建
使用find_package()
命令在Qt6
软件包中找到所需的模块组件:
find_package(Qt6 REQUIRED COMPONENTS TextToSpeech) target_link_libraries(mytarget PRIVATE Qt6::TextToSpeech)
更多详情,请参阅使用 CMake 构建概述。
使用 qmake 构建
要配置使用 qmake 构建的模块,请在项目的 .pro 文件中添加模块作为QT
变量的值:
QT += texttospeech
概述和重要主题
QML 类型
下面列出了一些重要的 QML 类型。
类型提供对文本到语音引擎的访问 | |
为选择 TextToSpeech 元素的语音提供附加属性 | |
类型代表一个特定的语音 |
C++ 类
下面列出了一些重要的 C++ 类。
方便访问文本到语音引擎 | |
代表特定语音 |
参考和示例
许可证和归属
QtTextToSpeech 由Qt Company 根据商业许可提供。此外,它还受自由软件许可证的保护:GNU Lesser General Public License 第 3 版或GNU General Public License 第 2 版。详情请参见Qt Licensing。
此外,Qt 6.9.0 中的 QtTextToSpeech 可包含以下许可下的第三方模块:
© 2025 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.