Search code examples
c#text-to-speechsapi

How to use x-sampa phonetic transcription on SAPI 5


I have a bunch of x-sampa phonetic transcriptions like "p_hleIs that I would like to use with SAPI 5.

Is this possible?


Solution

  • I don't believe so, no. It does, however, support IPA which, from what I understand, X-SAMPA was extended so that it could translate well to IPA.

    W3.org Actually covers how to do this when you ingest XML grammars into SAPI. If you wanted to use IPA on the fly, however, in C++ I do something like:

    m_cpVoice->Speak(L"His name is <phoneme alphabet=\"ipa\" ph=\"ɹəˈbɛːɹɾoʊ bɛˈniːnji\">Roberto Benigni</phoneme>", SVSFIsXML, NULL);
    

    If you can't use wide chars for whatever reason, you might have to translate to unicode like:

    m_cpVoice->Speak(L"His name is<phoneme alphabet=\"ipa\" ph=\"&#x2C8;l&#x251; &#x2C8;vi&#x2D0;&#x27E;&#x259; &#x2C8;&#x294;e&#x26A; &#x2C8;b&#x25B;l&#x259;\"">La vita e bella </phoneme>", SVSFIsXML, NULL);
    

    Which admittedly looks terrible.

    It's probably not all the different to do in C#.