summaryrefslogtreecommitdiffstats
path: root/examples/speech/quickspeech/main.qml
diff options
context:
space:
mode:
authorVolker Hilsheimer <volker.hilsheimer@qt.io>2023-02-13 12:47:31 +0100
committerAxel Spoerl <axel.spoerl@qt.io>2023-02-13 15:46:32 +0100
commited0bafb89a0245c6ea14b59ed177ecbcbe83a2d5 (patch)
treebdd7a1541379a93b0deac3a080a8f982394d4cc9 /examples/speech/quickspeech/main.qml
parent590bcc64c8b9b06f5c0e0c135c24f58d15f4ef56 (diff)
Documentation and example improvements
Mark relevant bits of the examples as snippets and use those in the reference documentation. Replace very short slots in the C++ example with lambdas. Pick-to: 6.5 Change-Id: I8deeeda7924f1721676147718e9a6fbdd408aaa0 Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
Diffstat (limited to 'examples/speech/quickspeech/main.qml')
-rw-r--r--examples/speech/quickspeech/main.qml18
1 files changed, 18 insertions, 0 deletions
diff --git a/examples/speech/quickspeech/main.qml b/examples/speech/quickspeech/main.qml
index 651f8c2..8e069e4 100644
--- a/examples/speech/quickspeech/main.qml
+++ b/examples/speech/quickspeech/main.qml
@@ -13,12 +13,15 @@ ApplicationWindow {
minimumWidth: inputForm.implicitWidth
minimumHeight: inputForm.implicitHeight + footer.implicitHeight
+//! [initialize]
TextToSpeech {
id: tts
volume: volumeSlider.value
pitch: pitchSlider.value
rate: rateSlider.value
+//! [initialize]
+//! [stateChanged]
onStateChanged: (state) => {
switch (state) {
case TextToSpeech.Ready:
@@ -35,6 +38,13 @@ ApplicationWindow {
break
}
}
+//! [stateChanged]
+
+//! [sayingWord]
+ onSayingWord: (start, length)=> {
+ input.select(start, start + length)
+ }
+//! [sayingWord]
}
ColumnLayout {
@@ -49,26 +59,34 @@ ApplicationWindow {
Layout.fillWidth: true
Layout.minimumHeight: implicitHeight
}
+//! [say0]
RowLayout {
Button {
text: qsTr("Speak")
enabled: [TextToSpeech.Paused, TextToSpeech.Ready].includes(tts.state)
onClicked: {
+//! [say0]
let voices = tts.availableVoices()
tts.voice = voices[voicesComboBox.currentIndex]
+//! [say1]
tts.say(input.text)
}
}
+//! [say1]
+//! [pause]
Button {
text: qsTr("Pause")
enabled: tts.state == TextToSpeech.Speaking
onClicked: tts.pause()
}
+//! [pause]
+//! [resume]
Button {
text: qsTr("Resume")
enabled: tts.state == TextToSpeech.Paused
onClicked: tts.resume()
}
+//! [resume]
Button {
text: qsTr("Stop")
enabled: [TextToSpeech.Speaking, TextToSpeech.Paused].includes(tts.state)