I am creating an application for blind and visually impaired person, I created a local database which contains column for Primary Key(Beacon Attachments ) and another column for information which i want to give to the user if they are near that beacon . It’s working fine but I want to ask user if they want to hear more info about the POI(point of interest) they are in or no, through the voice command can i do this inside each zone . As of now it’s giving me error when i call speechToText from each zone.
ProximityZone zone = new ProximityZoneBuilder()
.forTag("proximity-for-multiple-bea-iaj")
.inNearRange()
.onEnter(new Function1<ProximityZoneContext, Unit>() {
@Override
public Unit invoke(ProximityZoneContext context) {
List<ProximityContent> nearbyContent = new ArrayList<>();
String information = context.getAttachments().get("proximity-for-multiple-bea-iaj/title1");
// get data from database , if the key matches
String information1 = databaseAccess.getInformation(information);
Log.d("app", "Enter: " + information);
if (information == null) {
information = "unknown";
}
textToSpeech.speak(information,TextToSpeech.QUEUE_FLUSH, null, null);
/////------ Here i want to ask if they want to hear more--------////////
textToSpeech.speak("Do you want to hear more information ?" , TextToSpeech.QUEUE_FLUSH, null ,null );
// call Speech To text method
if(answer == "yes" ){
// give more information
textToSpeech(information1);
}
else {
textToSpeech("Ok, skipping more information");
}
nearbyContent.add(new ProximityContent(information, information1));
proximityContentAdapter.setNearbyContent(nearbyContent);
proximityContentAdapter.notifyDataSetChanged();
return null;
}
})
.onExit(new Function1<ProximityZoneContext, Unit>() {
@Override
public Unit invoke(ProximityZoneContext context) {
List<ProximityContent> nearbyContent = new ArrayList<>();
String information1 = context.getAttachments().get("proximity-for-multiple-bea-iaj/title2");
Log.d("app", "Exit: " + information1);
textToSpeech2.speak(information1,TextToSpeech.QUEUE_FLUSH, null, null);
nearbyContent.add(new ProximityContent(information1, null));
proximityContentAdapter.setNearbyContent(nearbyContent);
proximityContentAdapter.notifyDataSetChanged();
return null;
}
})
.build();