diff options
author | Jaromir Wysoglad | 2019-07-31 15:10:12 +0200 |
---|---|---|
committer | Filippos Karapetis | 2019-09-01 22:47:55 +0300 |
commit | 6703f88f7f91bc22ce5ea3593a1699f1dc4fa7c0 (patch) | |
tree | b277c6509b1bd632669b5de0fd1d0f66a567b880 /backends/text-to-speech/windows/windows-text-to-speech.cpp | |
parent | bbbb608c528699f281fdd5a8a7d814dd44b9aa41 (diff) | |
download | scummvm-rg350-6703f88f7f91bc22ce5ea3593a1699f1dc4fa7c0.tar.gz scummvm-rg350-6703f88f7f91bc22ce5ea3593a1699f1dc4fa7c0.tar.bz2 scummvm-rg350-6703f88f7f91bc22ce5ea3593a1699f1dc4fa7c0.zip |
TTS: Implement speech queueing on Linux and Win
Diffstat (limited to 'backends/text-to-speech/windows/windows-text-to-speech.cpp')
-rw-r--r-- | backends/text-to-speech/windows/windows-text-to-speech.cpp | 22 |
1 files changed, 12 insertions, 10 deletions
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 21ab0242b1..196a909f2e 100644 --- a/backends/text-to-speech/windows/windows-text-to-speech.cpp +++ b/backends/text-to-speech/windows/windows-text-to-speech.cpp @@ -96,12 +96,15 @@ WindowsTextToSpeechManager::~WindowsTextToSpeechManager() { ::CoUninitialize(); } -bool WindowsTextToSpeechManager::say(Common::String str, Common::String charset) { - if(_speechState == BROKEN || _speechState == NO_VOICE) { +bool WindowsTextToSpeechManager::say(Common::String str, Action action, Common::String charset) { + if (_speechState == BROKEN || _speechState == NO_VOICE) { warning("The tts cannot speak in this state"); return true; } + if (isSpeaking() && action == DROP) + return true; + if (charset.empty()) { #ifdef USE_TRANSLATION charset = TransMan.getCurrentCharset(); @@ -109,19 +112,18 @@ bool WindowsTextToSpeechManager::say(Common::String str, Common::String charset) charset = "ASCII"; #endif } - if (isPaused()) { - resume(); - } - _audio->SetState(SPAS_STOP, 0); - _audio->SetState(SPAS_RUN, 0); // 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); - WCHAR *strW = Win32::ansiToUnicode(str.c_str(), Win32::getCodePageId(charset)); - bool result = _voice->Speak(strW, SPF_ASYNC | SPF_PURGEBEFORESPEAK, NULL) != S_OK; + + if ((isPaused() || isSpeaking()) && action == INTERRUPT) + stop(); + + bool result = _voice->Speak(strW, SPF_ASYNC, NULL) != S_OK; free(strW); - _speechState = SPEAKING; + if (!isPaused()) + _speechState = SPEAKING; return result; } |