Qt TextToSpeech

The Qt TextToSpeech module enables a Qt application to read out text by using speech synthesis. This is especially useful in scenarios where the end-user cannot access the application's visual interface, for example, when driving or operating machinery. In such setups, the module can be used to read out incoming notifications or to provide turn-by-turn navigation instructions.

The module does not provide a text-to-speech engine itself. Instead, it uses engines native to the operating system. See Qt TextToSpeech 引擎 for more details about this.

使用模塊

QML API

模塊的 QML 類型是可用的透過 QtTextToSpeech 導入。要使用類型,添加以下 import 語句到 .qml 文件:

import QtTextToSpeech
					

C++ API

使用 Qt 模塊的 C++ API 要求直接 (或透過其它依賴) 鏈接到模塊庫。幾個構建工具對此有專用支持,包括 CMake and qmake .

構建采用 CMake

使用 find_package() 命令定位所需模塊組件在 Qt6 包:

find_package(Qt6 REQUIRED COMPONENTS TextToSpeech)
target_link_libraries(mytarget PRIVATE Qt6::TextToSpeech)
					

更多細節,見 構建采用 CMake 概述。

采用 qmake 構建

要配置采用 qmake 構建模塊,添加模塊作為值為 QT 變量在工程的 .pro 文件:

QT += texttospeech
					

概述和重要話題

QML 類型

The following lists some important QML types.

TextToSpeech

Type provides access to text-to-speech engines

VoiceSelector

Provides attached properties for selecting the voice of a TextToSpeech element

C++ 類

The following lists some important C++ Classes.

QTextToSpeech

方便地訪問 TTS (文本轉語音) 引擎

QVoice

Represents a particular voice

參考和範例

許可和歸屬

Qt TextToSpeech 在商業許可下是可用的來自 Qt 公司 。此外,它在自由軟件許可下也是可用的: GNU LGPL (次一般公共許可) 第 3 版 ,或 GNU GPL (一般公共許可) 第 2 版 。見 Qt 許可 進一步瞭解細節。