windows phone 8 - SRGS lexicon not loading (or being used) in WP8 -
i'm trying use windows phone 8 speech recognition recognize custom pronunciation of words. i'm try use samples provided on msdn, coming short. first of all, i'm using lexicon file (.pls) because "sapi" namespace inline pronunciations failing (for both pron
, display
attributes) - maybe i'll save different question. anyway, here's 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 srgs grammar. load this:
dim srgsgrammar uri = new uri("ms-appx:///srgsgrammar.xml", urikind.absolute) _myrecognizer.grammars.addgrammarfromuri("srgsgrammar", srgsgrammar)
i've tried adding type="application/pls+xml"
lexicon
element, gives format exception.
seems work fine. notice <lexicon/>
tag in though. here's 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 in app's root, set content , copy if newer).
then hit button called "speak", dim recoresult = await _myrecognizer.recognizeasync()
. whatchamacallit , gives me low confidence , says rule used "thecolor" , text "blue". doesn't use pls far can see. if again , time blue, close 100% confidence.
i want whatchamacallit in pls recognized, not blue in srgs grammar, thing gets high confidence "blue" (99%) , result text.
my pls appears load (i can't 100% sure, uri other 1 give above causes filenotfound exception, that's why think loading).
note - how use lexicon speechsynthesizer? not question about, although both use whatchamacallit example in pls. also, using ssml advanced text-to-speech on windows phone 8 gave me hope it's implementation of pls i've seen, alas different technology , doesn't work in example.
has got custom pronunciations work in wp8 via pls file (or inline in <token/>
sapi
)? if so, can help?
todd, tried replicate problem since had strong suspicion had uri-scheme. didn't have complete code able replicate putting grammar , lexicon files in root folder of app's local storage.
when used type="application/pls+xml" in c#, didn't 80045003 error. rather, kept getting this:
winrt information: grammar error found: c:\data\users\defapps\appdata{a7c75bfd-f873-4da9-834c-c4ca3d97aa6b}\local\srgsgrammar.xml, line 4: cannot compile lexicon file "ms-appdata:///local/srgslexicon.xml": 0x80004003
which think file pointer not found error. , when paid closer attention error message, noticed file paths parser thinks has grammar file , lexicon file different, tho using "ms-appdata:///" reference both files.
it turns out grammar parser cannot accept of special uri-schemes. used full path of file path error message pls file uri attribute , worked. you'll notice i'm still using type="application/pls+xml"
so i'm not sure work around acceptable solution... believe gets root of problem.
this code (in c#) makes work
srgslexicon.pls (unchanged)
srgsgrammar.xml (using file path rather uri-scheme)
<?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="c:\data\users\defapps\appdata\{a7c75bfd-f873-4da9-834c-c4ca3d97aa6b}\local\srgslexicon.pls" type="application/pls+xml" /> <rule id="thecolor"> <item>blue</item> </rule> </grammar>
my app code (c#)
public mainpage() { initializecomponent(); var srgsgrammar = new uri("ms-appx:////srgsgrammar.xml", urikind.absolute); _recognizerui.recognizer.grammars.addgrammarfromuri("srgsgrammar", srgsgrammar); } readonly speechrecognizerui _recognizerui = new speechrecognizerui(); private async void test_onclick(object sender, routedeventargs e) { //i used these next 2 lines show filepath of srgsgrammar.xml file, , used same folder //structure lexicon pls file uri (just changed file name) //var filename = (await storagefile.getfilefromapplicationuriasync(new uri("ms-appdata:///local/srgsgrammar.xml"))).path; //messagebox.show(filename); var recoresult = await _recognizerui.recognizewithuiasync(); var x = recoresult.recognitionresult.textconfidence; messagebox.show(((int)x).tostring()); //show confidence }
i hope helps @ all. think grammar parser doesn't know uri-scheme.
Comments
Post a Comment