From 5a847ad4b2748bf4a2d7545be00060420b74b6fe Mon Sep 17 00:00:00 2001 From: Ravi Ranjan Date: Sat, 7 Mar 2015 20:59:20 +0530 Subject: [PATCH 1/2] Change the Text to speech api (previous api of http://mary.dfki.de is not working) Issue #53 --- src/definitions/definitions.h.in | 3 ++- src/miscellaneous/iofactory.cpp | 10 ++++++++-- .../learnspellings/learnspellingssimulator.cpp | 2 +- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/definitions/definitions.h.in b/src/definitions/definitions.h.in index d8de778..2171ecc 100755 --- a/src/definitions/definitions.h.in +++ b/src/definitions/definitions.h.in @@ -73,7 +73,8 @@ #define CERTIFICATE_PATH "certificate.pem" #define KEY_PATH "key.pk8" //#define TTS_SERVICE_URL "http://translate.google.com/translate_tts?tl=en&q=%1" -#define TTS_SERVICE_URL "http://mary.dfki.de:59125/process?INPUT_TEXT=%1&INPUT_TYPE=TEXT&OUTPUT_TYPE=AUDIO&AUDIO=WAVE_FILE&LOCALE=en_US" +//#define TTS_SERVICE_URL "http://mary.dfki.de:59125/process?INPUT_TEXT=%1&INPUT_TYPE=TEXT&OUTPUT_TYPE=AUDIO&AUDIO=WAVE_FILE&LOCALE=en_US" +#define TTS_SERVICE_URL "http://tts-api.com/tts.mp3?q=%1" #define STORE_API_KEY "BuildmLearnToolkit" #define STORE_ENDPOINT "http://croozeus.com/buildmlearn/api/v1/storeAPI.php" diff --git a/src/miscellaneous/iofactory.cpp b/src/miscellaneous/iofactory.cpp index 57821e3..329abb1 100755 --- a/src/miscellaneous/iofactory.cpp +++ b/src/miscellaneous/iofactory.cpp @@ -35,7 +35,9 @@ #include #include #include - +#include +#include + #if !defined(Q_OS_OS2) #if QT_VERSION >= 0x050000 #include @@ -51,7 +53,11 @@ IOFactory::IOFactory() { void IOFactory::playWaveFile(const QString &file_path) { #if QT_VERSION >= 0x050000 - QSound::play(file_path); + QMediaPlayer *player = new QMediaPlayer(); + player->setMedia(QUrl::fromLocalFile(file_path)); + player->setVolume(100); + player->play(); + //QSound::play(file_path); #elif !defined(Q_OS_OS2) Phonon::AudioOutput *out = new Phonon::AudioOutput(Phonon::MusicCategory, qApp); out->setVolume(100.0f); diff --git a/src/templates/learnspellings/learnspellingssimulator.cpp b/src/templates/learnspellings/learnspellingssimulator.cpp index 183fbe2..f525c73 100755 --- a/src/templates/learnspellings/learnspellingssimulator.cpp +++ b/src/templates/learnspellings/learnspellingssimulator.cpp @@ -160,7 +160,7 @@ void LearnSpellingsSimulator::playWord() { // Store downloaded sound file. QString sound_file_name = qApp->templateManager()->tempDirectory() + QDir::separator() + - "sound_" + QDateTime::currentDateTime().toString("yyyy-MM-dd-hhmmss") + ".wav"; + "sound_" + QDateTime::currentDateTime().toString("yyyy-MM-dd-hhmmss") + ".mp3"; QFile sound_file(sound_file_name); sound_file.open(QIODevice::WriteOnly | QIODevice::Truncate | QIODevice::Unbuffered); sound_file.write(output); From 596084d890b8aa6d7777f9611bb2a8a722721ce0 Mon Sep 17 00:00:00 2001 From: Ravi Ranjan Date: Tue, 10 Mar 2015 19:39:30 +0530 Subject: [PATCH 2/2] Checked the code with Qt4 --- src/miscellaneous/iofactory.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/miscellaneous/iofactory.cpp b/src/miscellaneous/iofactory.cpp index 329abb1..d07c77d 100755 --- a/src/miscellaneous/iofactory.cpp +++ b/src/miscellaneous/iofactory.cpp @@ -35,12 +35,11 @@ #include #include #include -#include #include #if !defined(Q_OS_OS2) #if QT_VERSION >= 0x050000 -#include +#include #else #include #include @@ -57,7 +56,6 @@ void IOFactory::playWaveFile(const QString &file_path) { player->setMedia(QUrl::fromLocalFile(file_path)); player->setVolume(100); player->play(); - //QSound::play(file_path); #elif !defined(Q_OS_OS2) Phonon::AudioOutput *out = new Phonon::AudioOutput(Phonon::MusicCategory, qApp); out->setVolume(100.0f);