0

I understand that SAPI can use SSML with the SPF_PARSE_SSML however I have not been able to get this to work, always getting a SPERR_UNSUPPORTED_FORMAT error. Is something else needed to enable it? Special voices, some extra flag?

I tried setting different voices explicitly (my Win 10 machine seems to have a "Microsoft Hazel Desktop" and "Microsoft Zira Desktop"), different tags, with/without XML declaration.

#include <Windows.h>
#include <sapi.h>
#include <stdexcept>
int main()
{
    HRESULT hr;
    if (FAILED(hr = CoInitialize(NULL)))
        return 1;
    ISpVoice *voice;
    if (FAILED(hr = CoCreateInstance(CLSID_SpVoice, NULL, CLSCTX_ALL, IID_ISpVoice, (void **)& voice)))
        return 1;
    // Works
    const wchar_t *text = L"Testing SAPI support for S S M L";
    if (FAILED(hr = voice->Speak(text, SPF_IS_NOT_XML, NULL)))
        return 1;
    // Fails 0x80045003 SPERR_UNSUPPORTED_FORMAT
    const wchar_t *ssml =
        L"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
        L"<speak xmlns=\"http://www.w3.org/2001/10/synthesis\" xmlns:dc=\"http://purl.org/dc/elements/1.1/\" version=\"1.0\">\n"
        L"Testing SAPI support for <break time=\"500ms\"/>S<break time=\"500ms\"/>S<break time=\"500ms\"/>M<break time=\"500ms\"/>L.\n"
        L"</speak>";
    if (FAILED(hr = voice->Speak(ssml, SPF_IS_XML | SPF_PARSE_SSML, NULL)))
        return 1;
    return 0;
}
Fire Lancer
  • 29,364
  • 31
  • 116
  • 182
  • maybe related: [Can C# SAPI speak SSML string?](https://stackoverflow.com/questions/11215761/can-c-sharp-sapi-speak-ssml-string) – Thomas Jun 21 '19 at 18:58
  • I get the impression that SSML is only supported via the REST API. – Thomas Jun 21 '19 at 19:19
  • @Thomas You mean the Microsoft Azure stuff? This is for local TTS, not cloud. – Fire Lancer Jun 24 '19 at 08:49
  • I understand that what you want is local. But from what I read I get the impression SSML via SAPI is not supported locally. I might be wrong. – Thomas Jun 24 '19 at 11:15

0 Answers0