Skip to content

Commit 62aec03

Browse files
shaunrenjulliard
authored andcommitted
sapi: Implement ISpeechVoice::GetVoices.
1 parent 0f8b59a commit 62aec03

File tree

2 files changed

+48
-4
lines changed

2 files changed

+48
-4
lines changed

dlls/sapi/tests/tts.c

+29-2
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,7 @@ static IClassFactory test_engine_cf = { &ClassFactoryVtbl };
416416

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

422422
ISpVoice *voice;
@@ -432,13 +432,18 @@ static void test_spvoice(void)
432432
DWORD regid;
433433
DWORD start, duration;
434434
ISpeechVoice *speech_voice;
435+
ISpeechObjectTokens *speech_tokens;
436+
LONG count;
437+
BSTR req = NULL, opt = NULL;
435438
HRESULT hr;
436439

437440
if (waveOutGetNumDevs() == 0) {
438441
skip("no wave out devices.\n");
439442
return;
440443
}
441444

445+
RegDeleteTreeA(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Speech\\Voices\\WinetestVoice");
446+
442447
check_apttype();
443448
ok(test_apt_data.type == APTTYPE_UNITIALIZED, "got apt type %d.\n", test_apt_data.type);
444449

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

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

694+
count = -1;
695+
hr = ISpeechVoice_GetVoices(speech_voice, NULL, NULL, &speech_tokens);
696+
ok(hr == S_OK, "got %#lx.\n", hr);
697+
hr = ISpeechObjectTokens_get_Count(speech_tokens, &count);
698+
ok(hr == S_OK, "got %#lx.\n", hr);
699+
ok(count > 0, "got %ld.\n", count);
700+
ISpeechObjectTokens_Release(speech_tokens);
701+
702+
req = SysAllocString(L"Vendor=Winetest");
703+
opt = SysAllocString(L"Language=409;Gender=Male");
704+
705+
count = 0xdeadbeef;
706+
hr = ISpeechVoice_GetVoices(speech_voice, req, opt, &speech_tokens);
707+
ok(hr == S_OK, "got %#lx.\n", hr);
708+
hr = ISpeechObjectTokens_get_Count(speech_tokens, &count);
709+
ok(hr == S_OK, "got %#lx.\n", hr);
710+
ok(count == 1, "got %ld.\n", count);
711+
ISpeechObjectTokens_Release(speech_tokens);
712+
688713
hr = ISpeechVoice_Speak(speech_voice, NULL, SVSFPurgeBeforeSpeak, NULL);
689714
ok(hr == S_OK, "got %#lx.\n", hr);
690715

@@ -695,8 +720,10 @@ static void test_spvoice(void)
695720
ISpVoice_Release(voice);
696721
ISpObjectToken_Release(token);
697722
ISpMMSysAudio_Release(audio_out);
723+
SysFreeString(req);
724+
SysFreeString(opt);
698725

699-
RegDeleteTreeA( HKEY_LOCAL_MACHINE, "Software\\Wine\\Winetest\\sapi" );
726+
RegDeleteTreeA(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Speech\\Voices\\WinetestVoice");
700727
}
701728

702729
START_TEST(tts)

dlls/sapi/tts.c

+19-2
Original file line numberDiff line numberDiff line change
@@ -401,9 +401,26 @@ static HRESULT WINAPI speech_voice_Skip(ISpeechVoice *iface, const BSTR type, LO
401401
static HRESULT WINAPI speech_voice_GetVoices(ISpeechVoice *iface, BSTR required, BSTR optional,
402402
ISpeechObjectTokens **tokens)
403403
{
404-
FIXME("(%p, %s, %s, %p): stub.\n", iface, debugstr_w(required), debugstr_w(optional), tokens);
405404

406-
return E_NOTIMPL;
405+
ISpObjectTokenCategory *cat;
406+
IEnumSpObjectTokens *token_enum;
407+
HRESULT hr;
408+
409+
TRACE("(%p, %s, %s, %p).\n", iface, debugstr_w(required), debugstr_w(optional), tokens);
410+
411+
if (!tokens) return E_POINTER;
412+
413+
if (FAILED(hr = create_token_category(SPCAT_VOICES, &cat)))
414+
return hr;
415+
416+
if (SUCCEEDED(hr = ISpObjectTokenCategory_EnumTokens(cat, required, optional, &token_enum)))
417+
{
418+
hr = IEnumSpObjectTokens_QueryInterface(token_enum, &IID_ISpeechObjectTokens, (void **)tokens);
419+
IEnumSpObjectTokens_Release(token_enum);
420+
}
421+
422+
ISpObjectTokenCategory_Release(cat);
423+
return hr;
407424
}
408425

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

0 commit comments

Comments
 (0)