TTS: Add *_NO_REPEAT actions
This commit is contained in:
parent
98cea3e2ce
commit
4bae32ffe7
5 changed files with 22 additions and 2 deletions
|
@ -81,6 +81,7 @@ void LinuxTextToSpeechManager::init() {
|
|||
warning("Couldn't initialize text to speech through speech-dispatcher");
|
||||
return;
|
||||
}
|
||||
_lastSaid = "";
|
||||
|
||||
_connection->callback_begin = speech_begin_callback;
|
||||
spd_set_notification_on(_connection, SPD_BEGIN);
|
||||
|
@ -138,6 +139,12 @@ bool LinuxTextToSpeechManager::say(Common::String str, Action action, Common::St
|
|||
if (action == DROP && isSpeaking())
|
||||
return true;
|
||||
|
||||
if (action == INTERRUPT_NO_REPEAT && _lastSaid == str && isSpeaking())
|
||||
return true;
|
||||
|
||||
if (action == QUEUE_NO_REPEAT && _lastSaid == str && isSpeaking())
|
||||
return true;
|
||||
|
||||
if (charset.empty()) {
|
||||
#ifdef USE_TRANSLATION
|
||||
charset = TransMan.getCurrentCharset();
|
||||
|
@ -148,10 +155,11 @@ bool LinuxTextToSpeechManager::say(Common::String str, Action action, Common::St
|
|||
|
||||
str = strToUtf8(str, charset);
|
||||
|
||||
if (isSpeaking() && action == INTERRUPT)
|
||||
if (isSpeaking() && action == INTERRUPT || action == INTERRUPT_NO_REPEAT)
|
||||
stop();
|
||||
if (str.size() != 0)
|
||||
_speechState = SPEAKING;
|
||||
_lastSaid = str;
|
||||
if(spd_say(_connection, SPD_MESSAGE, str.c_str()) == -1) {
|
||||
//restart the connection
|
||||
if (_connection != 0)
|
||||
|
|
|
@ -72,6 +72,7 @@ private:
|
|||
void createVoice(int typeNumber, Common::TTSVoice::Gender, Common::TTSVoice::Age, char *description);
|
||||
SpeechState _speechState;
|
||||
Common::String strToUtf8(Common::String str, Common::String charset);
|
||||
Common::String _lastSaid;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -88,6 +88,7 @@ void WindowsTextToSpeechManager::init() {
|
|||
_speechState = READY;
|
||||
else
|
||||
_speechState = NO_VOICE;
|
||||
_lastSaid = "";
|
||||
}
|
||||
|
||||
WindowsTextToSpeechManager::~WindowsTextToSpeechManager() {
|
||||
|
@ -105,6 +106,12 @@ bool WindowsTextToSpeechManager::say(Common::String str, Action action, Common::
|
|||
if (isSpeaking() && action == DROP)
|
||||
return true;
|
||||
|
||||
if (isSpeaking() && action == INTERRUPT_NO_REPEAT && _lastSaid == str)
|
||||
return true;
|
||||
|
||||
if (isSpeaking() && action == QUEUE_NO_REPEAT && _lastSaid == str)
|
||||
return true;
|
||||
|
||||
if (charset.empty()) {
|
||||
#ifdef USE_TRANSLATION
|
||||
charset = TransMan.getCurrentCharset();
|
||||
|
@ -112,6 +119,7 @@ bool WindowsTextToSpeechManager::say(Common::String str, Action action, Common::
|
|||
charset = "ASCII";
|
||||
#endif
|
||||
}
|
||||
_lastSaid = str;
|
||||
// We have to set the pitch by prepending xml code at the start of the said string;
|
||||
Common::String pitch= Common::String::format("<pitch absmiddle=\"%d\">", _ttsState->_pitch / 10);
|
||||
str.replace((uint32)0, 0, pitch);
|
||||
|
|
|
@ -71,6 +71,7 @@ private:
|
|||
void createVoice(void *cpVoiceToken);
|
||||
Common::String lcidToLocale(Common::String lcid);
|
||||
SpeechState _speechState;
|
||||
Common::String _lastSaid;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -138,7 +138,9 @@ class TextToSpeechManager {
|
|||
public:
|
||||
enum Action {
|
||||
INTERRUPT,
|
||||
INTERRUPT_NO_REPEAT,
|
||||
QUEUE,
|
||||
QUEUE_NO_REPEAT,
|
||||
DROP
|
||||
};
|
||||
/**
|
||||
|
@ -156,7 +158,7 @@ public:
|
|||
* @param charset The encoding of the string. If empty this is assumed to be the
|
||||
* encoding used for the GUI.
|
||||
*/
|
||||
bool say(String str, String charset = "") { return say(str, INTERRUPT, charset); }
|
||||
bool say(String str, String charset = "") { return say(str, INTERRUPT_NO_REPEAT, charset); }
|
||||
|
||||
/**
|
||||
* Says the given string
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue