From 7ec4f03a0824d2ee16c24cf995ce4900ecb556af Mon Sep 17 00:00:00 2001 From: Jaromir Wysoglad Date: Thu, 1 Aug 2019 21:24:23 +0200 Subject: TTS: Make state switching faster on Linux --- backends/text-to-speech/linux/linux-text-to-speech.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'backends') 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 a2a09aebdc..c5ff8e0858 100644 --- a/backends/text-to-speech/linux/linux-text-to-speech.cpp +++ b/backends/text-to-speech/linux/linux-text-to-speech.cpp @@ -147,6 +147,8 @@ bool LinuxTextToSpeechManager::say(Common::String str, Action action, Common::St if (isSpeaking() && action == INTERRUPT) stop(); + if (str.size() != 0) + _speechState = SPEAKING; if(spd_say(_connection, SPD_MESSAGE, str.c_str()) == -1) { //restart the connection if (_connection != 0) @@ -154,24 +156,28 @@ bool LinuxTextToSpeechManager::say(Common::String str, Action action, Common::St init(); return true; } + return false; } bool LinuxTextToSpeechManager::stop() { if (_speechState == READY || _speechState == BROKEN) return true; + _speechState = READY; return spd_cancel(_connection) == -1; } bool LinuxTextToSpeechManager::pause() { if (_speechState == READY || _speechState == PAUSED || _speechState == BROKEN) return true; + _speechState = PAUSED; return spd_pause(_connection) == -1; } bool LinuxTextToSpeechManager::resume() { if (_speechState == READY || _speechState == SPEAKING || _speechState == BROKEN) return true; + _speechState = SPEAKING; return spd_resume(_connection) == -1; } -- cgit v1.2.3