File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Android and the fly likes java code for speech to text Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Mobile » Android
Bookmark "java code for speech to text" Watch "java code for speech to text" New topic

java code for speech to text

Glen Hynes

Joined: Jan 05, 2013
Posts: 2
hello all. the code below is used to convert speech to text on an android app. This code works when the speech button is pressed and whatever you say is transferred into text.
When the speech function closes, the the text is showing.
If you hit the speech button again, the previous text is cleared and the new text shows on the page.
Can anyone help me edit the code so that the previous texts remain on the page?

Steve Luke

Joined: Jan 28, 2003
Posts: 4181

The general strategy would be to get the previous text, append the new String to the old text, then add the text back to the TextView. It may be a little more complicated because you probably want to add a line break, and maybe other conditions (like a fixed number of lines to display, scrolling, or something.

An alternative to the TextView which may better match your goals might be to use a ListView. The ListView can be bound to an ArrayAdapter. Whenever you get a String you would add it to the ArrayAdapter, which would cause the ListView to expand to accommodate the new text. It makes it easier to control the values which get displayed (the number of lines, formatting, etc...)

Glen Hynes

Joined: Jan 05, 2013
Posts: 2

Thanks. this sounds like exactly what i need. now to go and try write this into the code! i am a beginner with java so any help appreciated.
I agree. Here's the link:
subject: java code for speech to text
It's not a secret anymore!