7 #include <ConfigHolder.h>
11 #include <QApplication>
12 #include "WinSpeaker.h"
13 WinSpeaker winSpeaker
;
16 using freeRecite::configHolder
;
20 QSettings
settings("QFreeRecite");
22 QString
getWordPath(const QString
&word
) {
23 QString filePath
= settings
.value("PronouncePath").toString()
24 + word
.at(0) + "/" + word
+ ".wav";
26 if(QFile::exists(filePath
)) {
30 filePath
= settings
.value("GlobalPath").toString() + "patchWRPTTS/"
31 + word
.at(0) + "/" + word
+ ".wav";
33 if(QFile::exists(filePath
)) {
37 filePath
= settings
.value("HomePath").toString()
38 + "patchWRPTTS/" + word
+ ".wav";
40 if(QFile::exists(filePath
)) {
45 static QString oldWord
= "";
48 if(!word
.contains(' ') && !word
.contains('-'))
49 QProcess::startDetached(settings
.value("GlobalPath").toString() + "gws",
56 void speak(const QString
&word
) {
57 QString fileName
= getWordPath(word
.toLower());
58 if(fileName
.isEmpty())
60 QFileInfo
finfo(fileName
);
62 winSpeaker
.speak(finfo
.absoluteFilePath().toStdString());
64 QProcess::startDetached("aplay",
65 QStringList(finfo
.absoluteFilePath()));
69 void play(const QString
&sound
) {
70 if(!settings
.value("SoundEffectOpen").toBool())
72 std::string fileName
= configHolder
.musicDir()
73 + sound
.toStdString() + ".wav";
75 //If thread can't play it, then paly in a new process!
76 winSpeaker
.speak(fileName
);
78 QProcess::startDetached("aplay",
79 QStringList(fileName
.c_str()));