Skip to content

Commit

Permalink
Use NAN instead of default value
Browse files Browse the repository at this point in the history
  • Loading branch information
tim-gromeyer committed May 24, 2023
1 parent 7ffc0be commit b4b6510
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "texttospeechsettings.h"
#include "ui_mainwindow.h"
#include "utils.h"
#include <cmath>

#include <QCloseEvent>
#include <QDebug>
Expand Down Expand Up @@ -166,8 +167,8 @@ MainWindow::MainWindow(QWidget *parent)
settings->value(STR("Engine"), QLatin1String()).toString(),
settings->value(STR("Language"), QLocale::system()).toLocale(),
settings->value(STR("Voice"), QLatin1String()).toString(),
settings->value(STR("Pitch"), -1.0F).toFloat(),
settings->value(STR("Rate"), -1.0F).toFloat());
settings->value(STR("Pitch"), NAN).toFloat(),
settings->value(STR("Rate"), NAN).toFloat());
settings->endGroup();

// Connect the actions
Expand Down Expand Up @@ -378,9 +379,9 @@ void MainWindow::setupTextToSpeech(const QString &engineName,
if (voice.name() == voiceName)
engine->setVoice(voice);
}
if (pitch != -1.0F)
if (!std::isnan(pitch))
engine->setPitch(pitch);
if (rate != -1.0F)
if (!std::isnan(rate))
engine->setRate(rate);
connect(engine, &QTextToSpeech::stateChanged, _instance, &MainWindow::onTTSStateChanged);
qDebug() << "[debug] TTS: Setup finished";
Expand Down

0 comments on commit b4b6510

Please sign in to comment.