From 52d079182c33dd9d26f69519961e00fc2733166b Mon Sep 17 00:00:00 2001 From: Elias Hautala Date: Mon, 26 Jun 2023 14:33:56 +0300 Subject: Add cmake and qmake project files to quickspeech example Adds cmake and qmake project files to the quickspeech example which allows the example to be built and deployd. Fixes: QTBUG-113820 Pick-to: 6.5 6.6 Change-Id: Ie52f70ccfbd173c43621a20604fffd46182f9e20 Reviewed-by: Nicholas Bennett --- examples/speech/quickspeech/main.qml | 194 ----------------------------------- 1 file changed, 194 deletions(-) delete mode 100644 examples/speech/quickspeech/main.qml (limited to 'examples/speech/quickspeech/main.qml') diff --git a/examples/speech/quickspeech/main.qml b/examples/speech/quickspeech/main.qml deleted file mode 100644 index 3d7b019..0000000 --- a/examples/speech/quickspeech/main.qml +++ /dev/null @@ -1,194 +0,0 @@ -// Copyright (C) 2022 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause - -import QtQuick -import QtQuick.Controls -import QtQuick.Layouts -import QtTextToSpeech - -ApplicationWindow { - id: root - visible: true - title: qsTr("Text to Speech") - 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: - statusLabel.text = qsTr("Ready") - break - case TextToSpeech.Speaking: - statusLabel.text = qsTr("Speaking") - break - case TextToSpeech.Paused: - statusLabel.text = qsTr("Paused...") - break - case TextToSpeech.Error: - statusLabel.text = qsTr("Error!") - break - } - } -//! [stateChanged] - -//! [sayingWord] - onSayingWord: (word, id, start, length)=> { - input.select(start, start + length) - } -//! [sayingWord] - } - - ColumnLayout { - anchors.fill: parent - anchors.margins: 8 - id: inputForm - - TextArea { - id: input - wrapMode: TextEdit.WordWrap - text: qsTr("Hello, world!") - Layout.fillWidth: true - Layout.minimumHeight: implicitHeight - font.pointSize: 24 - } -//! [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() - visible: tts.engineCapabilities & TextToSpeech.Capabilities.PauseResume - } -//! [pause] -//! [resume] - Button { - text: qsTr("Resume") - enabled: tts.state == TextToSpeech.Paused - onClicked: tts.resume() - visible: tts.engineCapabilities & TextToSpeech.Capabilities.PauseResume - } -//! [resume] - Button { - text: qsTr("Stop") - enabled: [TextToSpeech.Speaking, TextToSpeech.Paused].includes(tts.state) - onClicked: tts.stop() - } - } - - GridLayout { - columns: 2 - - Text { - text: qsTr("Engine:") - } - ComboBox { - id: enginesComboBox - Layout.fillWidth: true - model: tts.availableEngines() - onActivated: { - tts.engine = textAt(currentIndex) - updateLocales() - updateVoices() - } - } - Text { - text: qsTr("Locale:") - } - ComboBox { - id: localesComboBox - Layout.fillWidth: true - onActivated: { - let locales = tts.availableLocales() - tts.locale = locales[currentIndex] - updateVoices() - } - } - Text { - text: qsTr("Voice:") - } - ComboBox { - id: voicesComboBox - Layout.fillWidth: true - } - Text { - text: qsTr("Volume:") - } - Slider { - id: volumeSlider - from: 0 - to: 1.0 - stepSize: 0.2 - value: 0.8 - Layout.fillWidth: true - } - Text { - text: qsTr("Pitch:") - } - Slider { - id: pitchSlider - from: -1.0 - to: 1.0 - stepSize: 0.5 - value: 0 - Layout.fillWidth: true - } - Text { - text: qsTr("Rate:") - } - Slider { - id: rateSlider - from: -1.0 - to: 1.0 - stepSize: 0.5 - value: 0 - Layout.fillWidth: true - } - } - } - footer: Label { - id: statusLabel - } - - Component.onCompleted: { - enginesComboBox.currentIndex = tts.availableEngines().indexOf(tts.engine) - updateLocales() - updateVoices() - - tts.onStateChanged(tts.state) - } - - function updateLocales() { - let allLocales = tts.availableLocales().map((locale) => locale.nativeLanguageName) - let currentLocaleIndex = allLocales.indexOf(tts.locale.nativeLanguageName) - localesComboBox.model = allLocales - localesComboBox.currentIndex = currentLocaleIndex - } - - function updateVoices() { - voicesComboBox.model = tts.availableVoices().map((voice) => voice.name) - let indexOfVoice = tts.availableVoices().indexOf(tts.voice) - voicesComboBox.currentIndex = indexOfVoice - } -} -- cgit v1.2.3