7 #include <ConfigHolder.h>
11 #include <QApplication>
12 #include "WinSpeaker.h"
13 WinSpeaker winSpeaker
;
16 using freeRecite::configHolder
;
20 QSettings
settings("QFreeRecite");
22 void speak(const QString
&word
) {
23 QFileInfo
finfo((settings
.value("PronouncePath").toString().toStdString()
24 + word
.toStdString()[0] + "/"
25 + word
.toStdString() + ".wav").c_str());
29 winSpeaker
.speak(finfo
.absoluteFilePath().toStdString());
31 QProcess::startDetached("aplay",
32 QStringList(finfo
.absoluteFilePath()));
36 void play(const QString
&sound
) {
37 if(!settings
.value("SoundEffectOpen").toBool())
39 std::string fileName
= configHolder
.musicDir()
40 + sound
.toStdString() + ".wav";
42 //If thread can't play it, then paly in a new process!
43 if(!winSpeaker
.speak(fileName
) &&
44 (sound
== "type" || sound
== "ok" || sound
== "fail") ) {
45 QProcess::startDetached("aplay",
46 QStringList(fileName
.c_str()));
47 qApp
->processEvents();
50 QProcess::startDetached("aplay",
51 QStringList(fileName
.c_str()));