diff options
-rw-r--r-- | backends/text-to-speech/windows/windows-text-to-speech.cpp | 1 | ||||
-rw-r--r-- | common/text-to-speech.cpp | 6 |
2 files changed, 6 insertions, 1 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 58389e5141..d102300028 100644 --- a/backends/text-to-speech/windows/windows-text-to-speech.cpp +++ b/backends/text-to-speech/windows/windows-text-to-speech.cpp @@ -181,6 +181,7 @@ void WindowsTextToSpeechManager::setVoice(unsigned index) { if(_speechState == BROKEN || _speechState == NO_VOICE) return; _voice->SetVoice((ISpObjectToken *) _ttsState->_availableVoices[index].getData()); + _ttsState->_activeVoice = index; } void WindowsTextToSpeechManager::setRate(int rate) { diff --git a/common/text-to-speech.cpp b/common/text-to-speech.cpp index 9289cba214..f9dc4c69aa 100644 --- a/common/text-to-speech.cpp +++ b/common/text-to-speech.cpp @@ -98,6 +98,7 @@ TextToSpeechManager::~TextToSpeechManager() { } void TextToSpeechManager::pushState() { + stop(); TTSState *newState = new TTSState; newState->_pitch = _ttsState->_pitch; newState->_volume = _ttsState->_volume; @@ -110,6 +111,7 @@ void TextToSpeechManager::pushState() { } bool TextToSpeechManager::popState() { + stop(); if (_ttsState->_next == nullptr) return true; @@ -118,11 +120,13 @@ bool TextToSpeechManager::popState() { delete oldState; + // The voice has to be saved, because some backends change it when changing language + int voice = _ttsState->_activeVoice; setLanguage(_ttsState->_language); setPitch(_ttsState->_pitch); setVolume(_ttsState->_volume); setRate(_ttsState->_rate); - setVoice(_ttsState->_activeVoice); + setVoice(voice); return false; } |