[dasher: 103/217] Win32 Speak will use voice with language of current alphabet.
- From: Patrick Welche <pwelche src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [dasher: 103/217] Win32 Speak will use voice with language of current alphabet.
- Date: Sat, 27 Feb 2016 12:08:59 +0000 (UTC)
commit f66f3d97ecfc5e104cdd970ac4369b5764d7122e
Author: ipomoena <amajorek google com>
Date: Tue Nov 3 17:21:54 2015 -0800
Win32 Speak will use voice with language of current alphabet.
https://github.com/ipomoena/dasher/issues/31
Src/Win32/Common/WinCommon.h | 3 ++-
Src/Win32/Dasher.cpp | 29 ++++++++++++++---------------
Src/Win32/Dasher.h | 2 +-
3 files changed, 17 insertions(+), 17 deletions(-)
---
diff --git a/Src/Win32/Common/WinCommon.h b/Src/Win32/Common/WinCommon.h
index 059efdf..fd9e34d 100644
--- a/Src/Win32/Common/WinCommon.h
+++ b/Src/Win32/Common/WinCommon.h
@@ -8,7 +8,8 @@
#ifndef __WinCommon_h__
#define __WinCommon_h__
-
+// Windows Vista
+#define _WIN32_WINNT 0x6000
//#pragma message("Compiling WinCommon.h.........................")
#define NOMINMAX
diff --git a/Src/Win32/Dasher.cpp b/Src/Win32/Dasher.cpp
index 5e341c9..fed7590 100644
--- a/Src/Win32/Dasher.cpp
+++ b/Src/Win32/Dasher.cpp
@@ -284,28 +284,27 @@ bool CDasher::SupportsSpeech() {
return m_pDefaultVoice != 0;
}
-ISpVoice* CDasher::getVoice(string lang)
+ISpVoice* CDasher::getVoice(const string& lang)
{
auto it = m_voicesByLangCode.find(lang);
if (it != m_voicesByLangCode.end())
return it->second;
- // temporary hack to see how language selection works
- if (lang=="pl")
- {
- CComPtr<IEnumSpObjectTokens> cpEnum;
- HRESULT hr = SpEnumTokens(SPCAT_VOICES, L"", L"Language=415", &cpEnum);
+
+ wstring wideLang = UTF8string_to_wstring(lang);
+ long lcid = LocaleNameToLCID(wideLang.c_str(), 0);
+ if (lcid) {
+ CString langFilter;
+ langFilter.Format(L"Language=%lx", lcid);
+ CComPtr<ISpObjectToken> cpToken;
+ HRESULT hr = SpFindBestToken(SPCAT_VOICES, L"", langFilter, &cpToken);
if (SUCCEEDED(hr)) {
- CComPtr<ISpObjectToken> cpToken;
- hr = cpEnum->Next(1, &cpToken, NULL);
+ CComPtr<ISpVoice> pVoice;
+ HRESULT hr = pVoice.CoCreateInstance(CLSID_SpVoice);
if (SUCCEEDED(hr)) {
- CComPtr<ISpVoice> pVoice;
- HRESULT hr = pVoice.CoCreateInstance(CLSID_SpVoice);
+ hr = pVoice->SetVoice(cpToken);
if (SUCCEEDED(hr)) {
- hr = pVoice->SetVoice(cpToken);
- if (SUCCEEDED(hr)) {
- m_voicesByLangCode[lang] = pVoice;
- return pVoice;
- }
+ m_voicesByLangCode[lang] = pVoice;
+ return pVoice;
}
}
}
diff --git a/Src/Win32/Dasher.h b/Src/Win32/Dasher.h
index a45aa60..3ae5de9 100644
--- a/Src/Win32/Dasher.h
+++ b/Src/Win32/Dasher.h
@@ -77,7 +77,7 @@ private:
CDasherWindow *m_pWindow;
CEdit *m_pEdit;
#ifdef WIN32_SPEECH
- ISpVoice* getVoice(string lang);
+ ISpVoice* getVoice(const string& lang);
CComPtr<ISpVoice> m_pDefaultVoice;
bool m_bAttemptedSpeech;
map<string, CComPtr<ISpVoice> > m_voicesByLangCode;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]