Fix voice compilation (#2571)

This commit is contained in:
David Chavez 2023-03-02 21:58:27 +01:00 committed by GitHub
parent d3f864cea9
commit 981c6348ab
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -12,7 +12,7 @@
#include <spdlog/fmt/fmt.h>
#include <spdlog/fmt/xchar.h>
ISpVoice* mVoice = NULL;
ISpVoice* ispVoice = NULL;
SAPISpeechSynthesizer::SAPISpeechSynthesizer() {
}
@ -20,13 +20,13 @@ SAPISpeechSynthesizer::SAPISpeechSynthesizer() {
bool SAPISpeechSynthesizer::DoInit() {
CoInitializeEx(NULL, COINIT_MULTITHREADED);
HRESULT CoInitializeEx(LPVOID pvReserved, DWORD dwCoInit);
CoCreateInstance(CLSID_SpVoice, NULL, CLSCTX_ALL, IID_ISpVoice, (void**)&mVoice);
CoCreateInstance(CLSID_SpVoice, NULL, CLSCTX_ALL, IID_ISpVoice, (void**)&ispVoice);
return true;
}
void SAPISpeechSynthesizer::DoUninitialize() {
mVoice->Release();
mVoice = NULL;
ispVoice->Release();
ispVoice = NULL;
CoUninitialize();
}
@ -43,7 +43,7 @@ void SpeakThreadTask(std::string text, std::string language) {
auto speakText = fmt::format(
L"<speak version='1.0' xmlns='http://www.w3.org/2001/10/synthesis' xml:lang='{}'>{}</speak>", wLanguage, wText);
mVoice->Speak(speakText.c_str(), SPF_IS_XML | SPF_ASYNC | SPF_PURGEBEFORESPEAK, NULL);
ispVoice->Speak(speakText.c_str(), SPF_IS_XML | SPF_ASYNC | SPF_PURGEBEFORESPEAK, NULL);
}
void SAPISpeechSynthesizer::Speak(const char* text, const char* language) {