teaching machines

CS 491 Lecture 18 – Speech Recognition and Text-to-Speech

November 5, 2013 by . Filed under cs491 mobile, fall 2013, lectures.



Bird watchers sit for hours in the woods and count how many times they see each species of bird. Children on long car trips count how many blue cars they see, and how many red, and how many black. Masters of verbal communication count how many times a speaker says “ahh” or “umm.”

Let’s write an app for counting instances.

For an interface, let’s do the following:

That’s it.


I’ve just learned that iOS doesn’t support programmatic speech synthesis before iOS 7, so you won’t be able to do text-to-speech as easily, if at all. However, the app is still good for building iOS muscle. I suggest the following steps as you build the iOS implementation:

  1. Create your layout as described above.
  2. Make a CountedItem object with properties for name and count.
  3. Your ViewController must maintain a list of CountedItems, probably as an NSMutableArray.
  4. Your ViewController must be the table view’s data source.
  5. An entry’s view in the list can be created by using prototype cells. Check out http://www.colejoplin.com/2012/09/28/ios-tutorial-basics-of-table-views-and-prototype-cells-in-storyboards for details on how to do this.
  6. You’ll may need to make your prototype cell a subclass of UITableViewCell. Talk to me if you discover this is necessary.


An Android implementation of this app is mostly straightforward. I suggest the following steps as you build your app:

  1. Create your layout as described above.
  2. Make a CountedItem object.
  3. Create a separate XML layout defining the view for a single entry in the list of counted items.
  4. Recall that an adapter maps items in a collection to their views. The stock ArrayAdapter only maps items to a string label. We’ve got some funny requirements for our views in this app, so we’ll need to make a custom adapter. Make a subclass of ArrayAdapter, but override getView to load your custom entry layout and set UI state. Refer to http://www.vogella.com/articles/AndroidListView/article.html#adapterown_custom for the particulars of how to do this.
  5. When the user taps on an entry, use Android’s text-to-speech engine to speak the counted item’s name.


Each year, my counts dropped
The Internet told me why
I gave birds tumors