Skip to content

Commit

Permalink
sapi: Implement ISpeechVoice::GetVoices.
Browse files Browse the repository at this point in the history
  • Loading branch information
shaunren authored and julliard committed Feb 20, 2024
1 parent 0f8b59a commit 62aec03
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 4 deletions.
31 changes: 29 additions & 2 deletions dlls/sapi/tests/tts.c
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ static IClassFactory test_engine_cf = { &ClassFactoryVtbl };

static void test_spvoice(void)
{
static const WCHAR test_token_id[] = L"HKEY_LOCAL_MACHINE\\Software\\Wine\\Winetest\\sapi\\tts\\TestEngine";
static const WCHAR test_token_id[] = L"HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Speech\\Voices\\Tokens\\WinetestVoice";
static const WCHAR test_text[] = L"Hello! This is a test sentence.";

ISpVoice *voice;
Expand All @@ -432,13 +432,18 @@ static void test_spvoice(void)
DWORD regid;
DWORD start, duration;
ISpeechVoice *speech_voice;
ISpeechObjectTokens *speech_tokens;
LONG count;
BSTR req = NULL, opt = NULL;
HRESULT hr;

if (waveOutGetNumDevs() == 0) {
skip("no wave out devices.\n");
return;
}

RegDeleteTreeA(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Speech\\Voices\\WinetestVoice");

check_apttype();
ok(test_apt_data.type == APTTYPE_UNITIALIZED, "got apt type %d.\n", test_apt_data.type);

Expand Down Expand Up @@ -588,6 +593,7 @@ static void test_spvoice(void)
hr = ISpObjectToken_CreateKey(token, L"Attributes", &attrs_key);
ok(hr == S_OK, "got %#lx.\n", hr);
ISpDataKey_SetStringValue(attrs_key, L"Language", L"409");
ISpDataKey_SetStringValue(attrs_key, L"Vendor", L"Winetest");
ISpDataKey_Release(attrs_key);

hr = ISpVoice_SetVoice(voice, token);
Expand Down Expand Up @@ -685,6 +691,25 @@ static void test_spvoice(void)
hr = ISpVoice_QueryInterface(voice, &IID_ISpeechVoice, (void **)&speech_voice);
ok(hr == S_OK, "got %#lx.\n", hr);

count = -1;
hr = ISpeechVoice_GetVoices(speech_voice, NULL, NULL, &speech_tokens);
ok(hr == S_OK, "got %#lx.\n", hr);
hr = ISpeechObjectTokens_get_Count(speech_tokens, &count);
ok(hr == S_OK, "got %#lx.\n", hr);
ok(count > 0, "got %ld.\n", count);
ISpeechObjectTokens_Release(speech_tokens);

req = SysAllocString(L"Vendor=Winetest");
opt = SysAllocString(L"Language=409;Gender=Male");

count = 0xdeadbeef;
hr = ISpeechVoice_GetVoices(speech_voice, req, opt, &speech_tokens);
ok(hr == S_OK, "got %#lx.\n", hr);
hr = ISpeechObjectTokens_get_Count(speech_tokens, &count);
ok(hr == S_OK, "got %#lx.\n", hr);
ok(count == 1, "got %ld.\n", count);
ISpeechObjectTokens_Release(speech_tokens);

hr = ISpeechVoice_Speak(speech_voice, NULL, SVSFPurgeBeforeSpeak, NULL);
ok(hr == S_OK, "got %#lx.\n", hr);

Expand All @@ -695,8 +720,10 @@ static void test_spvoice(void)
ISpVoice_Release(voice);
ISpObjectToken_Release(token);
ISpMMSysAudio_Release(audio_out);
SysFreeString(req);
SysFreeString(opt);

RegDeleteTreeA( HKEY_LOCAL_MACHINE, "Software\\Wine\\Winetest\\sapi" );
RegDeleteTreeA(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Speech\\Voices\\WinetestVoice");
}

START_TEST(tts)
Expand Down
21 changes: 19 additions & 2 deletions dlls/sapi/tts.c
Original file line number Diff line number Diff line change
Expand Up @@ -401,9 +401,26 @@ static HRESULT WINAPI speech_voice_Skip(ISpeechVoice *iface, const BSTR type, LO
static HRESULT WINAPI speech_voice_GetVoices(ISpeechVoice *iface, BSTR required, BSTR optional,
ISpeechObjectTokens **tokens)
{
FIXME("(%p, %s, %s, %p): stub.\n", iface, debugstr_w(required), debugstr_w(optional), tokens);

return E_NOTIMPL;
ISpObjectTokenCategory *cat;
IEnumSpObjectTokens *token_enum;
HRESULT hr;

TRACE("(%p, %s, %s, %p).\n", iface, debugstr_w(required), debugstr_w(optional), tokens);

if (!tokens) return E_POINTER;

if (FAILED(hr = create_token_category(SPCAT_VOICES, &cat)))
return hr;

if (SUCCEEDED(hr = ISpObjectTokenCategory_EnumTokens(cat, required, optional, &token_enum)))
{
hr = IEnumSpObjectTokens_QueryInterface(token_enum, &IID_ISpeechObjectTokens, (void **)tokens);
IEnumSpObjectTokens_Release(token_enum);
}

ISpObjectTokenCategory_Release(cat);
return hr;
}

static HRESULT WINAPI speech_voice_GetAudioOutputs(ISpeechVoice *iface, BSTR required, BSTR optional,
Expand Down

0 comments on commit 62aec03

Please sign in to comment.