Haldean Brown
Haldean Brown

Reputation: 12721

Parsing spoken phrases like "thirty one" into integers on Android

I'm using the speech recognition API to get a spoken number from a user -- something like "seventy five" or "two" -- and I'd like to get the decimal number that that corresponds to. All the values are bounded by 100, so it's feasible for me to have a big array of the words corresponding to numbers and look up within that array, but that's really ugly. Do you know of any APIs I could use to get this done easily? Thanks!

Upvotes: 0

Views: 169

Answers (1)

Blacksad
Blacksad

Reputation: 15442

Wit is an API that does what you need. Check out the wit/number entity.

If you just need to parse your text into a structured number, and nothing else, just create one intent with one wit/number entity and it will do the job.

Upvotes: 3

Related Questions