Qt TextToSpeech 引擎
Qt TextToSpeechQt 5 引擎支持不同平台的多种引擎实现,并在功能、可用性和运行时成本之间做出不同的权衡。
可以在构建QTextToSpeech 实例时选择引擎,也可以通过设置engine 属性在已实例化的对象上选择引擎。如果没有指定引擎,则将使用当前平台的首选引擎。调用availableEngines() 可获取当前系统可使用的引擎列表。这将包括一个用于测试的 "模拟 "引擎,该引擎不应部署到目标系统上。
在设置引擎时,应用程序可以将包含引擎特定参数键/值对的QVariantMap 传递给引擎。以下各节列出了每个引擎支持的配置参数。引擎不支持的参数将被静默忽略。
WinRT
winrt "引擎使用Windows.Media.SpeechSynthesis 命名空间的 API。它需要最新的 Windows SDK,而且在使用 MinGW 编译器时不可用。该引擎可访问当前 Windows 版本上安装的所有语音。
该引擎使用QAudioSink Qt Multimedia将合成器生成的 PCM 数据流播放到音频设备。
名称 | 类型 | 备注 |
---|---|---|
audioDevice | QAudioDevice |
SAPI
sapi "引擎使用 Windows SDK 中的SAPI 5.3框架。与 "winrt "引擎相比,它提供的语音选择有限,质量也有所下降。
SAPI 引擎不支持任何特定的引擎参数。
达尔文
达尔文 "引擎使用AVFoundation框架,该框架可在 iOS 设备和 macOS 10.15 上使用。该框架的文档说明也支持 macOS 10.14,但默认情况下该平台上没有声音。
达尔文引擎不支持任何特定引擎参数。
安卓
android "引擎是安卓平台上唯一可用的引擎。它使用TextToSpeech软件包,而该软件包又支持多个引擎后端。
注: "android "引擎不具备PauseResume 功能。
名称 | 类型 | 备注 |
---|---|---|
安卓引擎 | QString | Qt 中没有获取已安装引擎列表的 API。 |
Flite
flite "引擎使用flite合成器。该引擎占用空间小,特别适用于嵌入式环境。该插件至少需要 Flite 2.2,并使用QAudioSink 从 Qt Multimedia来渲染生成的 PCM 数据流。
引擎插件会在LD_LIBRARY_PATH
环境变量中列出的目录中搜索语音库,并回退到/usr/lib
、/usr/lib64
和/usr/lib/x86_64-linux-gnu
等常用库位置进行搜索。
如果 Flite 被用作静态库,那么所需的语音库也需要静态链接到引擎插件中。目前还没有在配置 Qt 时选择此类语音库的构建系统 API。
名称 | 类型 | 备注 |
---|---|---|
audioDevice | QAudioDevice |
语音发送器
speechd" 引擎与speech-dispatcher守护进程通信,至少需要 libspeechd 0.9。
注意: speech-dispatcher 引擎不具备WordByWordProgress 或Synthesize 功能。
语音分送引擎不支持任何引擎特定参数。
© 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.