How do I use a lexicon with SpeechSynthesizer?

前端 未结 3 1096
逝去的感伤
逝去的感伤 2020-12-31 06:15

I\'m performing some text-to-speech and I\'d like to specify some special pronunciations in a lexicon file. I have ran MSDN\'s AddLexicon example verbatim, and it speaks the

3条回答
  •  孤独总比滥情好
    2020-12-31 06:19

    After a lot of research and pitfalls I can assure you that your assumption is just plain wrong. For some reason System.Speech.Synthesis.SpeechSynthesizer.AddLexicon() adds the lexicon to an internal list, but doesn't use it at all. Seems like nobody tried using it before and this bug went unnoticed.

    Microsoft.Speech.Synthesis.SpeechSynthesizer.AddLexicon() (which belongs to the Microsoft Speech SDK) on the other hand works as expected (it passes the lexicon on to the COM object which interprets it as advertised).

    Please refer to this guide on how to install the SDK: http://msdn.microsoft.com/en-us/library/hh362873%28v=office.14%29.aspx

    Notes:

    • people reported the 64-bit version to cause COM exceptions (because the library does not get installed correctly), I confirmed this on a 64bit Windows 7 machine
      • using the x86 version circumvents the problem
    • be sure to install the runtime before the SDK
    • be sure to also install a runtime language (as adviced on the linked page) as the SDK does not use the default system speech engine

提交回复
热议问题