Question

I used SpeechRecognizerUI to read user's voice input. I was expecting to get dollar amount so $200 or $20.32 or $0.43 is an example. However, the response from backend is always like "20 point 32" or "20 dot 32" or "zero point forty five. Is there a better way to use the API samrtly so that I can get "200, 20.32, 0.45"? Thanks!

Was it helpful?

Solution 2

You can load your own grammar to SpeechRecognizer as described here: Adding, loading, and preloading grammars for Windows Phone 8.

In your case will be useful SRGS grammar.

You should create grammar like this (I get this from Microsoft Speech example):

<grammar version="1.0" xml:lang="en-US" mode="voice" root="amount"
xmlns="http://www.w3.org/2001/06/grammar" tag-format="semantics/1.0">

<rule id="amount">
  <item repeat="1-3">
    <ruleref uri="#number"/>
  </item>

  <item repeat="0-1">
    <ruleref uri="#dot"/>
  <item>

  <item repeat="0-2">
    <ruleref uri="#number"/>
  </item>
</rule>

<rule id="dot">
  <one-of>
    <item> point <tag> out = "." ; </tag> </item>
    <item> dot <tag> out = "." ; </tag> </item>
  </one-of>  
</rule>

<rule id="number">
  <one-of>
    <item> one <tag> out = 1; </tag> </item>
    <item> two <tag> out = 2; </tag> </item>
    <item> three <tag> out = 3; </tag> </item>
    <item> four <tag> out = 4; </tag> </item>
    <item> five <tag> out = 5; </tag> </item>
    <item> six <tag> out = 6; </tag> </item>
    <item> seven <tag> out = 7; </tag> </item>
    <item> eight <tag> out = 8; </tag> </item>
    <item> nine <tag> out = 9; </tag> </item>
    <item> ten <tag> out = 10; </tag> </item>
  </one-of>
</rule>

</grammar>

OTHER TIPS

You could try looking in the alternates, but aside from that, I don't see any way to control text normalization in dictation grammars.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top