theshell/thewaveworker.h

93 lines
1.9 KiB
C
Raw Normal View History

2016-03-29 17:42:24 +11:00
#ifndef THEWAVEWORKER_H
#define THEWAVEWORKER_H
#include <QObject>
#include <QProcess>
#include <QFrame>
#include <QSoundEffect>
#include <QSound>
#include <QUrl>
#include <QDebug>
#include <QMap>
#include <QTime>
#include <QAudioRecorder>
#include <QAudioEncoderSettings>
#include <QAudioProbe>
2016-06-03 17:26:25 +10:00
#include <QThread>
#include <QNetworkAccessManager>
#include <QNetworkRequest>
#include <QNetworkReply>
#include <QSettings>
#include <QXmlSimpleReader>
#include <QXmlInputSource>
#include <QEventLoop>
2016-06-03 19:37:59 +10:00
#include <QDir>
#include <QApplication>
#include <QGeoPositionInfoSource>
2016-03-29 17:42:24 +11:00
class theWaveWorker : public QObject
{
Q_OBJECT
enum SpeechState {
Idle,
TimerGetTime,
};
QMap<QString, int> numberDictionary;
public:
explicit theWaveWorker(QObject *parent = 0);
2016-06-03 17:26:25 +10:00
~theWaveWorker();
2016-03-29 17:42:24 +11:00
signals:
void outputSpeech(QString);
void outputResponse(QString);
void outputFrame(QFrame *);
void complete();
void startedListening();
void stoppedListening();
void finished();
void resetFrames();
2016-06-03 17:26:25 +10:00
void showCallFrame(bool emergency);
2016-03-29 17:42:24 +11:00
void showMessageFrame();
2016-06-03 17:26:25 +10:00
void showHelpFrame();
void showWikipediaFrame(QString title, QString text);
void launchApp(QString app);
2016-03-29 17:42:24 +11:00
void setTimer(QTime);
public slots:
void begin();
2016-06-03 17:26:25 +10:00
void processSpeech(QString speech, bool voiceFeedback = true);
2016-03-29 17:42:24 +11:00
void quit();
void soundBuffer(QAudioBuffer buffer);
2016-03-29 17:42:24 +11:00
private slots:
void outputAvailable();
private:
QProcess *speechProc;
QString buffer;
void speak(QString speech, bool restartOnceComplete = false);
SpeechState state = Idle;
QSoundEffect* startListeningSound, *okListeningSound, *errorListeningSound, *stopListeningSound;
QAudioRecorder* recorder = NULL;
2016-03-29 17:42:24 +11:00
QGeoPositionInfoSource* geolocationSource;
QGeoCoordinate currentCoordinates;
2016-03-29 17:42:24 +11:00
bool stopEverything = false;
bool resetOnNextBegin = false;
2016-06-03 17:26:25 +10:00
QSettings settings;
2016-03-29 17:42:24 +11:00
};
#endif // THEWAVEWORKER_H