Use a std::wstring
. Assuming you want the user to input what to say (barring a textbox and a button):
std::cout << "Enter lines of text to speak:\n";
for (std::wstring text; std::wcin >> text;) {
if (FAILED(hr = pVoice->Speak(text.c_str(), SPF_IS_XML, NULL))) {
std::cout << "Sorry, the text could not be spoken. The error code is " << hr << '\n';
}
}