1

I've been doing some work to add words and pronunciations to the Windows speech dictionary via the SpLexicon Interface of SAPI 5.4 (which I think is the only way to do it) via the AddPronunciation function, or in my case:

// Initialize SpLexicon instance
SpLexicon lex = new SpLexicon();

// Specify the word to add to the speech dictionary
string myWord = "father";

// Set the language ID (US English)
int langid = new System.Globalization.CultureInfo("en-US").LCID;

// Specify the word's part of speech
SpeechPartOfSpeech mySpeechPart = SpeechPartOfSpeech.SPSNoun;

// Specify the word's pronunciation in SAPI phone symbols
string myPronunciation = "f aa dh er";

// Call actual speech API method for adding word data to the speech dictionary
lex.AddPronunciation(myWord, langid, mySpeechPart, myPronunciation);

I'm referencing the American English Phoneme Table for determining what SAPI symbols to use. I've noticed though that using the emphasis markers "1" or "2" as well as the syllable marker "-" doesn't seem to affect the TTS pronunciation. Are these modifier symbols only used for XML input, or am I possibly doing something wrong?

Exergist
  • 157
  • 12
  • Does it work if you specify the pronunciation via SSML? Also, try using a langID of 0 (zero), as that uses a different phoneme to ID converter. – Eric Brown Dec 14 '18 at 23:59
  • Thanks for checking this out Eric! I actually did a bunch of testing in VS today and in fact it DOES work as described. Looking back I'm not sure what caused the problem, but I still need to integrate this with the rest of my project. The primary and/or secondary stress marker should go at the end of a syllable (after the last phoneme of a syllable). One thing I thought was odd though was that I could have two primary stressors, two secondary stressors, or a mix of both and all the pronunciation variations would sound the same. I'll update this post with my new findings in the next few days. – Exergist Dec 15 '18 at 04:39
  • As an extension of this @EricBrown I've posted a new question (hopefully the last for my project). Maybe when you have time you could check it out: https://stackoverflow.com/questions/56245050/how-to-get-speech-recognition-to-detect-sapi-emphasis-markers – Exergist May 21 '19 at 19:15
  • @EricBrown in the example shown above does anything need to happen with the `lex` object for proper disposal? Perhaps set it to null? Or is it okay to let it go out of scope? – Exergist May 30 '19 at 19:16
  • Setting it to null is probably preferable; it's a COM interface, so either one will work. Do you absolutely have to know when the object is finalized? If so, you'll probably have to look at Marshal.FinalReleaseComObject, but I wouldn't do that unless you absolutely have to. – Eric Brown May 31 '19 at 20:20
  • I'm sniffing around all my code for any leaks, and I didn't know if I needed to dispose of SAPI 5.4-related COM stuff. I didn't know if there was a managed/unmanaged gray area with the SAPI stuff. – Exergist May 31 '19 at 21:07
  • @EricBrown I use the above SAPI objects as part of a form. Would you suggest I follow this post (https://stackoverflow.com/a/20074069/9559499) and implement a finalizer? – Exergist Jun 06 '19 at 20:59

0 Answers0