Discussion Forums  >  Plugins, Customizing, Source Code

Replies: 12    Views: 83

QC
Aspiring developer
Profile
Posts: 50
Reg: Apr 20, 2013
Milwaukee, WI
6,650
08/07/13 10:10 AM (12 years ago)

Want to add text to speech to buttons menu for Android

I have added text to speech in a plain menu. New to android programming and loving the BT stuff! What I would like to do is to add text to speech on the buttons when a users presses the button the button uses the json titletext and speaks what the users has touched. I am thinking it has to be handled in this section of the code. But not sure how to transform the titletext json data to speech. public void onClick(View view){ BT_debugger.showIt(activityName + ":button clicked"); int buttonIndex = view.getId(); //the BT_item BT_item tappedItem = (BT_item) childItems.get(buttonIndex); String loadScreenWithItemId = BT_strings.getJsonPropertyValue(tappedItem.getJsonObject(), "loadScreenWithItemId", ""); String loadScreenWithNickname = BT_strings.getJsonPropertyValue(tappedItem.getJsonObject(), "loadScreenWithNickname", ""); Thanks for the help and any suggestions, Kathy
 
LA
Aspiring developer
Profile
Posts: 3280
Reg: Aug 16, 2012
Jerseyville, IL
42,900
like
08/07/13 11:31 AM (12 years ago)
Hi @QC, You wanting a text box where a user can type and it tells the user back in voice or you want everything to voice, such as: buttons, text field, etc...? LA
 
QC
Aspiring developer
Profile
Posts: 50
Reg: Apr 20, 2013
Milwaukee, WI
6,650
like
08/07/13 11:56 AM (12 years ago)
no text box when a user clicks on a button I want it to speak the titletext of the button So if I have a menu full of buttons like say button 1 has a title of dog and button 2 has a title of cat, when the user presses button one the apps will say dog, if the user presses button 2 the app will say cat. K
 
LA
Aspiring developer
Profile
Posts: 3280
Reg: Aug 16, 2012
Jerseyville, IL
42,900
like
08/07/13 12:02 PM (12 years ago)
@QC, You can load the xml layout of that screen and use the contentDescription tag and put it what you want the button to say, like "Dog", and it will say it. LA
 
QC
Aspiring developer
Profile
Posts: 50
Reg: Apr 20, 2013
Milwaukee, WI
6,650
like
08/07/13 12:19 PM (12 years ago)
ok but that means I have to put 100 contentDescriptions tags in my layout and that seemed overly complicated. I have the titletext for the button and that has what I need to translate to speech. right now for BT there is one layout for the multiple screens I have. I was hoping that there was a way to take the titletext of the button and get text to speech to work when button is touched private static final String[] HELLOS = {titleText }; int helloLength = HELLOS.length; String hello = HELLOS[ (helloLength)]; tts.speak(hello, TextToSpeech.QUEUE_FLUSH, // Drop all pending entries in the playback queue. null); been playing around
 
LA
Aspiring developer
Profile
Posts: 3280
Reg: Aug 16, 2012
Jerseyville, IL
42,900
like
08/07/13 12:31 PM (12 years ago)
Sure you prob can code it to work for your screen but why don't you just implement the TalkBack feature in Accessibility or call it in your code? LA
 
QC
Aspiring developer
Profile
Posts: 50
Reg: Apr 20, 2013
Milwaukee, WI
6,650
like
08/07/13 01:50 PM (12 years ago)
hmmm didn't know about that, will have to take a look at that feature. New to android programming
 
QC
Aspiring developer
Profile
Posts: 50
Reg: Apr 20, 2013
Milwaukee, WI
6,650
like
08/08/13 06:35 PM (12 years ago)
I am using an emulator to test my code, can I enable it in an emulator and if so how? I have been googling it and in theory you can I just can figure out how to enable talkback in an emulator. Thanks again.
 
QC
Aspiring developer
Profile
Posts: 50
Reg: Apr 20, 2013
Milwaukee, WI
6,650
like
08/08/13 06:49 PM (12 years ago)
I am using an emulator to test my code, can I enable it in an emulator and if so how? I have been googling it and in theory you can I just can figure out how to enable talkback in an emulator. Thanks again.
 
QC
Aspiring developer
Profile
Posts: 50
Reg: Apr 20, 2013
Milwaukee, WI
6,650
like
08/09/13 06:21 AM (12 years ago)
looks like I do have to do the contentDescription tag. So it looks like once I figure out how to turn on talkback in the emulator I put this into the button.xml This will be so awesome.... can't wait to get it to work and get this to my disabled friend. This will help so much for so many people.
 
LA
Aspiring developer
Profile
Posts: 3280
Reg: Aug 16, 2012
Jerseyville, IL
42,900
like
08/09/13 08:27 AM (12 years ago)
Hi QC, I am a person with a disability also. What type of App you creating? LA
 
QC
Aspiring developer
Profile
Posts: 50
Reg: Apr 20, 2013
Milwaukee, WI
6,650
like
08/15/13 03:57 PM (12 years ago)
For a friend of mine who has ALS
 
QC
Aspiring developer
Profile
Posts: 50
Reg: Apr 20, 2013
Milwaukee, WI
6,650
like
08/20/13 06:21 PM (12 years ago)
ok so talkback is now talking but I am not getting the text if I click a button is says clicked and K2 (or something not sure) I want it to say the titleText of each button each of my buttons has a title. Any ideas what I am doing wrong? I added the context description to the menu_buttonitems.xml <TextView android:id="@+id/titleView" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" android:contentDescription="@+id/titleText" android:layout_below="@+id/backgroundImageView"> </TextView>
 

Login + Screen Name Required to Post

pointerLogin to participate so you can start earning points. Once you're logged in (and have a screen name entered in your profile), you can subscribe to topics, follow users, and start learning how to make apps like the pros.