aboutsummaryrefslogtreecommitdiff
path: root/backends/text-to-speech
diff options
context:
space:
mode:
authorJaromir Wysoglad2019-08-02 01:50:59 +0200
committerFilippos Karapetis2019-09-01 22:47:55 +0300
commit4bae32ffe7952ca967b16c8043c1957e9a3379b2 (patch)
treee6cc3600965a66dcde468fd7522cf1e47e36ee50 /backends/text-to-speech
parent98cea3e2cef3bf4c723967af60dfb961ab4bafaf (diff)
downloadscummvm-rg350-4bae32ffe7952ca967b16c8043c1957e9a3379b2.tar.gz
scummvm-rg350-4bae32ffe7952ca967b16c8043c1957e9a3379b2.tar.bz2
scummvm-rg350-4bae32ffe7952ca967b16c8043c1957e9a3379b2.zip
TTS: Add *_NO_REPEAT actions
Diffstat (limited to 'backends/text-to-speech')
-rw-r--r--backends/text-to-speech/linux/linux-text-to-speech.cpp10
-rw-r--r--backends/text-to-speech/linux/linux-text-to-speech.h1
-rw-r--r--backends/text-to-speech/windows/windows-text-to-speech.cpp8
-rw-r--r--backends/text-to-speech/windows/windows-text-to-speech.h1
4 files changed, 19 insertions, 1 deletions
diff --git a/backends/text-to-speech/linux/linux-text-to-speech.cpp b/backends/text-to-speech/linux/linux-text-to-speech.cpp
index c63c4c7dc7..97d05a67c1 100644
--- a/backends/text-to-speech/linux/linux-text-to-speech.cpp
+++ b/backends/text-to-speech/linux/linux-text-to-speech.cpp
@@ -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);
@@ -137,6 +138,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
@@ -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)
diff --git a/backends/text-to-speech/linux/linux-text-to-speech.h b/backends/text-to-speech/linux/linux-text-to-speech.h
index 49701abb4c..30fa9b878c 100644
--- a/backends/text-to-speech/linux/linux-text-to-speech.h
+++ b/backends/text-to-speech/linux/linux-text-to-speech.h
@@ -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
diff --git a/backends/text-to-speech/windows/windows-text-to-speech.cpp b/backends/text-to-speech/windows/windows-text-to-speech.cpp
index 0731239054..d0254fccb2 100644
--- a/backends/text-to-speech/windows/windows-text-to-speech.cpp
+++ b/backends/text-to-speech/windows/windows-text-to-speech.cpp
@@ -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);
diff --git a/backends/text-to-speech/windows/windows-text-to-speech.h b/backends/text-to-speech/windows/windows-text-to-speech.h
index 7a02c193ce..d8968243ec 100644
--- a/backends/text-to-speech/windows/windows-text-to-speech.h
+++ b/backends/text-to-speech/windows/windows-text-to-speech.h
@@ -71,6 +71,7 @@ private:
void createVoice(void *cpVoiceToken);
Common::String lcidToLocale(Common::String lcid);
SpeechState _speechState;
+ Common::String _lastSaid;
};
#endif