TTS: Implement our own queuing for linux

It seems like, that at least some versions of speech-dispatcher
aren't able to successfuly pause and resume. For me, when trying
to pause, it still finishes the speech just being said instead
of pausing it and then it puts it at the end of the speech queue
with some speech-dispatcher internal commands added to it, which
are also hearable.

There is no way to find out where the speech ended when calling
pause, so it is just stopped and when resume is called it is
read from it's start again.
This commit is contained in:
Jaromir Wysoglad 2019-08-02 17:03:17 +02:00 committed by Filippos Karapetis
parent 7613bcaa5f
commit 21fb4cef06
2 changed files with 71 additions and 30 deletions

View file

@ -29,6 +29,7 @@
#include "common/text-to-speech.h"
#include "common/str.h"
#include "common/list.h"
class LinuxTextToSpeechManager : public Common::TextToSpeechManager {
public:
@ -39,6 +40,14 @@ public:
BROKEN
};
enum SpeechEvent {
SPEECH_ENDED,
SPEECH_PAUSED,
SPEECH_CANCELED,
SPEECH_RESUMED,
SPEECH_BEGUN
};
LinuxTextToSpeechManager();
virtual ~LinuxTextToSpeechManager();
@ -62,7 +71,7 @@ public:
virtual void setLanguage(Common::String language);
void updateState(SpeechState state);
void updateState(SpeechEvent event);
virtual void freeVoiceData(void *data);
@ -70,9 +79,12 @@ private:
void init();
virtual void updateVoices();
void createVoice(int typeNumber, Common::TTSVoice::Gender, Common::TTSVoice::Age, char *description);
SpeechState _speechState;
Common::String strToUtf8(Common::String str, Common::String charset);
bool spdSay(const char *str);
SpeechState _speechState;
Common::String _lastSaid;
Common::List<Common::String> _speechQueue;
};
#endif