Commit 0bce87ad authored by Thomas Gubler's avatar Thomas Gubler

linux speech synthesis: switch to eSpeak

Conflicts:
	QGCExternalLibs.pri
	src/GAudioOutput.cc
parent 75a27239
...@@ -461,14 +461,10 @@ WindowsBuild { ...@@ -461,14 +461,10 @@ WindowsBuild {
} }
# #
# Festival Lite speech synthesis engine # eSpeak Speech Synthesizer
# #
LinuxBuild { LinuxBuild {
LIBS += \ LIBS += \
-lflite_cmu_us_kal \ -lespeak
-lflite_usenglish \
-lflite_cmulex \
-lflite
} }
...@@ -51,10 +51,14 @@ This file is part of the QGROUNDCONTROL project ...@@ -51,10 +51,14 @@ This file is part of the QGROUNDCONTROL project
#endif #endif
#ifdef Q_OS_LINUX #ifdef Q_OS_LINUX
extern "C" { // Using eSpeak for speech synthesis: following https://github.com/mondhs/espeak-sample/blob/master/sampleSpeak.cpp
#include <flite/flite.h> #include <espeak/speak_lib.h>
cst_voice *register_cmu_us_kal(const char *voxdir); espeak_POSITION_TYPE espeak_position_type;
}; espeak_AUDIO_OUTPUT espeak_output = AUDIO_OUTPUT_PLAYBACK;
int espeak_buflength = 500;
int espeak_options = 0;
char *espeak_path = NULL;
unsigned int espeak_flags=espeakCHARS_AUTO;
#endif #endif
#ifdef _MSC_VER #ifdef _MSC_VER
...@@ -97,7 +101,17 @@ GAudioOutput::GAudioOutput(QObject *parent) : QObject(parent), ...@@ -97,7 +101,17 @@ GAudioOutput::GAudioOutput(QObject *parent) : QObject(parent),
#ifdef Q_OS_LINUX #ifdef Q_OS_LINUX
flite_init(); espeak_Initialize(espeak_output, espeak_buflength, espeak_path, espeak_options );
const char *espeak_langNativeString = "en-uk"; //Default to US English
espeak_VOICE espeak_voice;
memset(&espeak_voice, 0, sizeof(espeak_VOICE)); // Zero out the voice first
espeak_voice.languages = espeak_langNativeString;
espeak_voice.name = "klatt";
espeak_voice.variant = 0;
espeak_voice.gender = 2;
espeak_SetVoiceByProperties(&espeak_voice);
espeak_PARAMETER rateParam = espeakRATE;
// espeak_SetParameter(rateParam , 150, 0);
#endif #endif
#if _MSC_VER #if _MSC_VER
...@@ -206,20 +220,13 @@ bool GAudioOutput::say(QString text, int severity) ...@@ -206,20 +220,13 @@ bool GAudioOutput::say(QString text, int severity)
#endif #endif
#ifdef Q_OS_LINUX #ifdef Q_OS_LINUX
QTemporaryFile file; unsigned int espeak_size, espeak_position = 0, espeak_end_position = 0, *espeak_unique_identifier = NULL;
file.setFileTemplate("XXXXXX.wav"); void* espeak_user_data = NULL;
espeak_size = strlen(text.toStdString().c_str());
if (file.open()) // qDebug() << "eSpeak: Saying " << text;
{ espeak_Synth( text.toStdString().c_str(), espeak_size, espeak_position, espeak_position_type, espeak_end_position, espeak_flags,
cst_voice *v = register_cmu_us_kal(NULL); espeak_unique_identifier, espeak_user_data );
cst_wave *wav = flite_text_to_wave(text.toStdString().c_str(), v); // qDebug() << "Done talking " << text;
// file.fileName() returns the unique file name
cst_wave_save(wav, file.fileName().toStdString().c_str(), "riff");
m_media->setCurrentSource(Phonon::MediaSource(QUrl::fromLocalFile(file.fileName().toStdString().c_str())));
m_media->play();
res = true;
}
#endif #endif
#ifdef Q_OS_MAC #ifdef Q_OS_MAC
......
...@@ -40,7 +40,6 @@ This file is part of the PIXHAWK project ...@@ -40,7 +40,6 @@ This file is part of the PIXHAWK project
#include <AudioOutput> #include <AudioOutput>
#endif #endif
#ifdef Q_OS_LINUX #ifdef Q_OS_LINUX
//#include <flite/flite.h>
#include <phonon/MediaObject> #include <phonon/MediaObject>
#include <phonon/AudioOutput> #include <phonon/AudioOutput>
#endif #endif
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment