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

Agenda

  • what ?s
  • an app for counting things

Exercise

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:

  • At the top of the screen, let’s place a text field and an Insert button.
  • For the rest of the screen, let’s have a list view.
  • When the user types or speaks a name in the text field and hits Insert, add an entry into the list.
  • Each entry in the list show’s the items name, its current count, and a widget for incrementing or decrementing.
  • When the user taps on an item, let’s speak the item’s name out using text-to-speech synthesis.

That’s it.

iOS

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.

Android

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.

Haiku

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

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *