7#include "texttospeechconfiginterface.h"
8#include "textedittexttospeech_debug.h"
9#include <KLocalizedString>
10#include <QTextToSpeech>
11using namespace TextEditTextToSpeech;
13TextToSpeechConfigInterface::TextToSpeechConfigInterface(
QObject *parent)
18TextToSpeechConfigInterface::~TextToSpeechConfigInterface() =
default;
24 voices = mTextToSpeech->availableVoices();
26 qCWarning(TEXTEDITTEXTTOSPEECH_LOG) <<
"Text To Speech is not created. ";
31QStringList TextToSpeechConfigInterface::availableEngines()
const
34 return mTextToSpeech->availableEngines();
36 qCWarning(TEXTEDITTEXTTOSPEECH_LOG) <<
"Text To Speech is not created. ";
43 return mTextToSpeech->availableLocales();
45 qCWarning(TEXTEDITTEXTTOSPEECH_LOG) <<
"Text To Speech is not created. ";
49QLocale TextToSpeechConfigInterface::locale()
const
52 return mTextToSpeech->locale();
54 qCWarning(TEXTEDITTEXTTOSPEECH_LOG) <<
"Text To Speech is not created. ";
58void TextToSpeechConfigInterface::setEngine(
const QString &engineName)
60 if (!mTextToSpeech || (mTextToSpeech && (mTextToSpeech->engine() != engineName))) {
62 mTextToSpeech =
new QTextToSpeech(engineName,
this);
66void TextToSpeechConfigInterface::testEngine(
const EngineSettings &engineSettings)
69 qCWarning(TEXTEDITTEXTTOSPEECH_LOG) <<
"Text To Speech is not created. ";
72 const int rate = engineSettings.rate;
73 const double rateDouble = rate / 100.0;
74 mTextToSpeech->setRate(rateDouble);
75 const int pitch = engineSettings.pitch;
76 const double pitchDouble = pitch / 100.0;
77 mTextToSpeech->setPitch(pitchDouble);
78 const int volume = engineSettings.volume;
79 const double volumeDouble =
volume / 100.0;
80 mTextToSpeech->setVolume(volumeDouble);
81 mTextToSpeech->setLocale(
QLocale(engineSettings.localeName));
82 mTextToSpeech->setVoice(engineSettings.voice);
85 mTextToSpeech->say(
i18n(
"Morning, this is the test for testing settings."));
90 d <<
" Rate " << t.rate;
91 d <<
" pitch " << t.pitch;
92 d <<
" volume " << t.volume;
93 d <<
" voice " << t.voice;
94 d <<
" localeName " << t.localeName;
98#include "moc_texttospeechconfiginterface.cpp"
QString i18n(const char *text, const TYPE &arg...)
QDebug operator<<(QDebug dbg, const DcrawInfoContainer &c)