in installvoices/InstallVoices.cpp [106:167]
voice_map_t SelectedVoicesMap(const std::wstring& voiceList)
{
Aws::SDKOptions options;
InitAPI(options);
PollyClient pc = Aws::MakeShared<Aws::Auth::ProfileConfigFileAWSCredentialsProvider>("InstallVoices", "polly-windows");
voice_map_t pollyVoices;
boolean isSelected(false);
boolean isAllSelected(voiceList.empty());
DescribeVoicesRequest describeVoices;
std::wstring name;
auto voicesOutcome = pc.DescribeVoices(describeVoices);
std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>> converter;
if (voicesOutcome.IsSuccess())
{
auto voiceSet = ArgumentSet(voiceList);
for (auto& voice : voicesOutcome.GetResult().GetVoices())
{
if (!isAllSelected && (voiceSet.find(voice.GetId()) != voiceSet.end())) {
isSelected = true;
}
if (isSelected || isAllSelected)
{
VoiceForSAPI v4sp(voice, false, false, false);
name = converter.from_bytes(VoiceIdMapper::GetNameForVoiceId(voice.GetId()).c_str());
pollyVoices.insert(std::make_pair(name.c_str(), v4sp));
auto e = voice.GetSupportedEngines();
if (std::find(e.begin(), e.end(), Engine::neural) != e.end())
{
name.append(L"_neural");
VoiceForSAPI v4sp_neural(voice, true, false, false);
pollyVoices.insert(std::make_pair(name, v4sp_neural));
}
name = converter.from_bytes(VoiceIdMapper::GetNameForVoiceId(voice.GetId()).c_str());
if (name == L"Lupe" || name == L"Amy") {
VoiceForSAPI v4sp_newscaster(voice, true, true, false);
name.append(L"_newscaster");
pollyVoices.insert(std::make_pair(name, v4sp_newscaster));
}
if (name == L"Matthew" || name == L"Joanna")
{
std::wcout << "Adding newscaster and conversational\n";
VoiceForSAPI v4sp_newscaster(voice, true, true, false);
name.append(L"_newscaster");
pollyVoices.insert(std::make_pair(name, v4sp_newscaster));
VoiceForSAPI v4sp_conversational(voice, true, false, true);
name = converter.from_bytes(VoiceIdMapper::GetNameForVoiceId(voice.GetId()).c_str());
name.append(L"_conversational");
pollyVoices.insert(std::make_pair(name, v4sp_conversational));
}
}
}
}
else
{
std::cout << "Error while getting voices" << std::endl;
std::cout << voicesOutcome.GetError();
}
ShutdownAPI(options);
return pollyVoices;
}