diff options
-rw-r--r-- | backends/text-to-speech/windows/windows-text-to-speech.cpp | 19 | ||||
-rw-r--r-- | backends/text-to-speech/windows/windows-text-to-speech.h | 8 |
2 files changed, 25 insertions, 2 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 cae1e6be78..aad50c61ff 100644 --- a/backends/text-to-speech/windows/windows-text-to-speech.cpp +++ b/backends/text-to-speech/windows/windows-text-to-speech.cpp @@ -41,15 +41,30 @@ #include "common/ustr.h" #include "common/config-manager.h" -WindowsTextToSpeechManager::WindowsTextToSpeechManager() { - debug("hi"); +ISpVoice *_voice; + +WindowsTextToSpeechManager::WindowsTextToSpeechManager() + : _speechState(BROKEN){ init(); } void WindowsTextToSpeechManager::init() { + if (FAILED(::CoInitialize(NULL))) + return; + + HRESULT hr = CoCreateInstance(CLSID_SpVoice, NULL, CLSCTX_ALL, IID_ISpVoice, (void **)&_voice); + if (!SUCCEEDED(hr)) { + warning("Could not initialize TTS voice"); + return; + } + updateVoices(); + _speechState = READY; } WindowsTextToSpeechManager::~WindowsTextToSpeechManager() { + if (_voice) + _voice->Release(); + ::CoUninitialize(); } bool WindowsTextToSpeechManager::say(Common::String str) { 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 a00ed58b8b..5daf57c44c 100644 --- a/backends/text-to-speech/windows/windows-text-to-speech.h +++ b/backends/text-to-speech/windows/windows-text-to-speech.h @@ -32,6 +32,13 @@ class WindowsTextToSpeechManager : public Common::TextToSpeechManager { public: + enum SpeechState { + READY, + PAUSED, + SPEAKING, + BROKEN + }; + WindowsTextToSpeechManager(); virtual ~WindowsTextToSpeechManager(); @@ -60,6 +67,7 @@ private: void init(); virtual void updateVoices(); void createVoice(int typeNumber, Common::TTSVoice::Gender, char *description); + SpeechState _speechState; }; #endif |