13#ifdef BUILD_TEXT_TO_SPEECH
17#include "../backend/config/btconfig.h"
22std::unique_ptr<QTextToSpeech> textToSpeech;
27namespace BtTextToSpeech {
29void speakText(QString
const & text) {
31 textToSpeech = newInstance();
33 textToSpeech->say(text);
36std::unique_ptr<QTextToSpeech> newInstance() {
37 std::unique_ptr<QTextToSpeech> tts;
39 auto const configuredEngine =
41 if (QTextToSpeech::availableEngines().contains(configuredEngine)) {
42 tts = std::make_unique<QTextToSpeech>(configuredEngine);
44 tts = std::make_unique<QTextToSpeech>();
47 auto const configuredLocale =
49 if (tts->availableLocales().contains(configuredLocale))
50 tts->setLocale(configuredLocale);
52 auto const configuredVoice =
54 for (
auto const & voice : tts->availableVoices()) {
55 if (voice.name() == configuredVoice) {
64void reset() { textToSpeech.reset(); }
BtConfig & btConfig()
This is a shortchand for BtConfig::getInstance().
T value(QString const &key, T const &defaultValue=T()) const
Returns the settings value for the given global key.