I'm trying to use Windows Phone 8 speech recognition to recognize custom pronunciation of words. I'm try to use the samples provided on MSDN, but am coming up short. First of all, I'm using a lexicon file (.pls) because the "sapi" namespace for inline pronunciations is failing (for both pron
and display
attributes) - but maybe I'll save that for a different question. So anyway, here's what I have:
<?xml version="1.0" encoding="utf-8" ?>
<grammar version="1.0" xml:lang="en-US" tag-format="semantics/1.0" root="thecolor"
xmlns="http://www.w3.org/2001/06/grammar" >
<lexicon uri="ms-appx:///SRGSLexicon.pls" />
<rule id="thecolor">
<item>blue</item>
</rule>
</grammar>
That's my SRGS grammar. I load it like this:
Dim SRGSGrammar As Uri = New Uri("ms-appx:///SRGSGrammar.xml", UriKind.Absolute)
_myRecognizer.Grammars.AddGrammarFromUri("SRGSGrammar", SRGSGrammar)
I've also tried adding type="application/pls+xml"
to the lexicon
element, but that gives a format exception.
Seems to work just fine. Notice the <lexicon/>
tag in though. Here's my PLS file:
<?xml version="1.0" encoding="utf-8" ?>
<lexicon version="1.0"
xmlns="http://www.w3.org/2005/01/pronunciation-lexicon"
alphabet="x-microsoft-ups" xml:lang="en-US">
<lexeme>
<grapheme> blue </grapheme>
<phoneme> W S1 AX T CH AX M AX K S2 AA L IH T </phoneme>
</lexeme>
</lexicon>
(Note: both of these files are in my app's root, set to Content and Copy if Newer).
Then I hit a button called "speak", which does Dim recoResult = Await _myRecognizer.RecognizeAsync()
. I then say whatchamacallit and it gives me very low confidence and says the rule used is "thecolor" and the text is "blue". It doesn't even use the PLS as far as I can see. If I do this again and this time say blue, I get close to 100% confidence.
I want whatchamacallit in the PLS to be recognized, not blue in the SRGS grammar, but the only thing that gets very high confidence is "blue" (99%) and that is also the result text.
My PLS appears to load (I can't be 100% sure, but any URI other than the one I give above causes a FileNotFound exception, so that's why I think it is loading).
Note - How do I use a lexicon with SpeechSynthesizer? is not what this question is about, although we both use whatchamacallit example in the PLS. Also, Using SSML for advanced text-to-speech on Windows Phone 8 gave me some hope as it's the only implementation of a PLS I've seen, but alas it is for a different technology and doesn't work in my example.
Has anyone got custom pronunciations to work in WP8 via a PLS file (or inline in <Token/>
with sapi
)? If so, can you help?